File tree 2 files changed +17
-2
lines changed
2 files changed +17
-2
lines changed Original file line number Diff line number Diff line change @@ -325,11 +325,13 @@ def make_compound_path_from_polys(cls, XY):
325
325
326
326
@classmethod
327
327
def make_compound_path (cls , * args ):
328
- """Make a compound path from a list of Path objects."""
328
+ """
329
+ Make a compound path from a list of Path objects. Blindly removes all
330
+ Path.STOP control points.
331
+ """
329
332
# Handle an empty list in args (i.e. no args).
330
333
if not args :
331
334
return Path (np .empty ([0 , 2 ], dtype = np .float32 ))
332
-
333
335
vertices = np .concatenate ([x .vertices for x in args ])
334
336
codes = np .empty (len (vertices ), dtype = cls .code_type )
335
337
i = 0
@@ -340,6 +342,10 @@ def make_compound_path(cls, *args):
340
342
else :
341
343
codes [i :i + len (path .codes )] = path .codes
342
344
i += len (path .vertices )
345
+ # remove STOP's, since internal STOPs are a bug
346
+ not_stop_mask = codes != cls .STOP
347
+ vertices = vertices [not_stop_mask , :]
348
+ codes = codes [not_stop_mask ]
343
349
344
350
return cls (vertices , codes )
345
351
Original file line number Diff line number Diff line change @@ -147,6 +147,15 @@ def test_make_compound_path_empty():
147
147
assert r .vertices .shape == (0 , 2 )
148
148
149
149
150
+ def test_make_compound_path_stops ():
151
+ zero = [0 , 0 ]
152
+ paths = 3 * [Path ([zero , zero ], [Path .MOVETO , Path .STOP ])]
153
+ compound_path = Path .make_compound_path (* paths )
154
+ # the choice to not preserve the terminal STOP is arbitrary, but
155
+ # documented, so we test that it is in fact respected here
156
+ assert np .sum (compound_path .codes == Path .STOP ) == 0
157
+
158
+
150
159
@image_comparison (['xkcd.png' ], remove_text = True )
151
160
def test_xkcd ():
152
161
np .random .seed (0 )
You can’t perform that action at this time.
0 commit comments