Skip to content

Commit

Permalink
Minor tweaks to PolygonalRegion.
Browse files Browse the repository at this point in the history
  • Loading branch information
Eric-Vin committed Jul 11, 2024
1 parent a34460a commit 8fc2c7c
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 1 deletion.
9 changes: 8 additions & 1 deletion src/scenic/core/regions.py
Original file line number Diff line number Diff line change
Expand Up @@ -3049,7 +3049,14 @@ def __eq__(self, other):

@cached
def __hash__(self):
return hash((self.polygons, self.orientation, self.z))
return hash(
(
tuple(self._points) if self._points else None,
self._polygon,
self.orientation,
self.z,
)
)


class CircularRegion(PolygonalRegion):
Expand Down
9 changes: 9 additions & 0 deletions tests/core/test_regions.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import shapely.geometry
import trimesh.voxel

from scenic.core.distributions import RandomControlFlowError, Range
from scenic.core.object_types import Object, OrientedPoint
from scenic.core.regions import *
from scenic.core.vectors import VectorField
Expand Down Expand Up @@ -222,6 +223,14 @@ def test_polygon_region():
PolygonalRegion([(1, 1), (3, 1), (2, 2), (1.3, 1.15)], z=3).uniformPointInner().z
== 3
)
assert i != d
hash(i)
e = CircularRegion((0, 0), Range(1, 3))
with pytest.raises(RandomControlFlowError):
i == e
with pytest.raises(RandomControlFlowError):
e == i
hash(e)


def test_polygon_unionAll():
Expand Down

0 comments on commit 8fc2c7c

Please sign in to comment.