Skip to content

Commit

Permalink
'alwaysProvidesOrientation Patch and Test
Browse files Browse the repository at this point in the history
  • Loading branch information
Eric-Vin committed Aug 15, 2024
1 parent 5f134ad commit ec34e76
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 0 deletions.
6 changes: 6 additions & 0 deletions src/scenic/syntax/veneer.py
Original file line number Diff line number Diff line change
Expand Up @@ -249,6 +249,7 @@
import sys
import traceback
import typing
import warnings

from scenic.core.distributions import (
Distribution,
Expand Down Expand Up @@ -1521,6 +1522,11 @@ def alwaysProvidesOrientation(region):
return sample.orientation is not None or sample is nowhere
except RejectionException:
return False
except Exception as e:
warnings.warn(
f"alwaysProvidesOrientation raised the following exception: {repr(e)}"
)
return False


def OffsetBy(offset):
Expand Down
16 changes: 16 additions & 0 deletions tests/syntax/test_specifiers.py
Original file line number Diff line number Diff line change
Expand Up @@ -1198,3 +1198,19 @@ def test_color():
ego = new Object with color (1,1,1,1,1)
"""
sampleEgoFrom(program)


# alwaysProvidesOrientation
def test_alwaysProvidesOrientation_exception():
with pytest.warns(UserWarning):
compileScenic(
"""
from scenic.core.distributions import distributionFunction
@distributionFunction
def foo(bar):
assert False
new Object in foo(Range(0,1))
"""
)

0 comments on commit ec34e76

Please sign in to comment.