File tree Expand file tree Collapse file tree 1 file changed +9
-5
lines changed Expand file tree Collapse file tree 1 file changed +9
-5
lines changed Original file line number Diff line number Diff line change @@ -88,17 +88,21 @@ def _merge(
88
88
if op (inside_a , inside_b ) != inside_region :
89
89
inside_region = not inside_region
90
90
91
- closed = current_endpoint .boundary in "[]"
91
+ # Boundary types can swap when differencing depending on
92
+ # whether the boundary is inside a region.
93
+ is_closed = current_endpoint .boundary in "[]"
92
94
b_in_a = inside_a and current_b == current_endpoint
93
95
a_in_b = inside_b and current_a == current_endpoint
94
- if op == sub and b_in_a or op == xor and (a_in_b or b_in_a ):
95
- closed = not closed
96
- boundary = (")(" , "][" )[closed ][len (endpoints ) % 2 == 0 ]
96
+ if op is sub and b_in_a or op is xor and (a_in_b or b_in_a ):
97
+ is_closed = not is_closed
98
+
99
+ boundary = (")(" , "][" )[is_closed ][len (endpoints ) % 2 == 0 ]
100
+
97
101
if (
98
102
len (endpoints ) > 0
99
103
and endpoints [- 1 ].value == current_endpoint .value
100
104
and endpoints [- 1 ].boundary + boundary not in {"[]" , ")(" }
101
- ):
105
+ ): # Remove redundant endpoints such as `0), [0` or `(0, 0]`.
102
106
endpoints .pop ()
103
107
else :
104
108
endpoints .append (Endpoint (current_endpoint .value , boundary ))
You can’t perform that action at this time.
0 commit comments