@@ -544,6 +544,24 @@ def test_non_convex_region_diff():
544
544
assert not pc .is_fulldim (diff .diff (remaining1 ).diff (remaining2 )), diff
545
545
546
546
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
+
547
565
def test_triangles_region_diff ():
548
566
# Test `polytope.polytope.region_diff` when the output should be convex
549
567
# Test with something else than boxes
0 commit comments