File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -325,11 +325,13 @@ def make_compound_path_from_polys(cls, XY):
325325
326326 @classmethod
327327 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+ """
329332 # Handle an empty list in args (i.e. no args).
330333 if not args :
331334 return Path (np .empty ([0 , 2 ], dtype = np .float32 ))
332-
333335 vertices = np .concatenate ([x .vertices for x in args ])
334336 codes = np .empty (len (vertices ), dtype = cls .code_type )
335337 i = 0
@@ -340,6 +342,10 @@ def make_compound_path(cls, *args):
340342 else :
341343 codes [i :i + len (path .codes )] = path .codes
342344 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 ]
343349
344350 return cls (vertices , codes )
345351
Original file line number Diff line number Diff line change @@ -147,6 +147,15 @@ def test_make_compound_path_empty():
147147 assert r .vertices .shape == (0 , 2 )
148148
149149
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+
150159@image_comparison (['xkcd.png' ], remove_text = True )
151160def test_xkcd ():
152161 np .random .seed (0 )
You can’t perform that action at this time.
0 commit comments