Skip to content

Commit ca35514

Browse files
committed
TST: expose error in function region_diff
1 parent dbb66f1 commit ca35514

File tree

1 file changed

+18
-0
lines changed

1 file changed

+18
-0
lines changed

tests/polytope_test.py

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -544,6 +544,24 @@ def test_non_convex_region_diff():
544544
assert not pc.is_fulldim(diff.diff(remaining1).diff(remaining2)), diff
545545

546546

547+
def test_checker_region_diff():
548+
# Test `polytope.polytope.region_diff` when the output should be non-convex
549+
# Set up a square and remove 1/2 by subtracting 2 square boxes on the
550+
# diagonal
551+
domain = pc.Polytope.from_box([(0.0, 1.0), (0.0, 1.0)])
552+
region = pc.Region([
553+
pc.Polytope.from_box([(0.0, 0.5), (0.0, 0.5)]),
554+
pc.Polytope.from_box([(0.5, 1.0), (0.5, 1.0)]),
555+
])
556+
# Do the diff and compare with expected result
557+
diff = pc.polytope.region_diff(domain, region)
558+
remaining1 = pc.Polytope.from_box([(0.5, 1.0), (0.0, 0.5)])
559+
remaining2 = pc.Polytope.from_box([(0.0, 0.5), (0.5, 1.0)])
560+
assert pc.is_fulldim(diff.diff(remaining1)), diff
561+
assert pc.is_fulldim(diff.diff(remaining2)), diff
562+
assert not pc.is_fulldim(diff.diff(remaining1).diff(remaining2)), diff
563+
564+
547565
def test_triangles_region_diff():
548566
# Test `polytope.polytope.region_diff` when the output should be convex
549567
# Test with something else than boxes

0 commit comments

Comments
 (0)