@@ -318,29 +318,25 @@ def make_compound_path_from_polys(cls, XY):
318318
319319 @classmethod
320320 def make_compound_path (cls , * args ):
321+ r"""
322+ Concatenate a list of `Path`\s into a single `.Path`, removing all `.STOP`\s.
321323 """
322- Make a compound path from a list of `Path` objects. Blindly removes
323- all `Path.STOP` control points.
324- """
325- # Handle an empty list in args (i.e. no args).
326324 if not args :
327325 return Path (np .empty ([0 , 2 ], dtype = np .float32 ))
328- vertices = np .concatenate ([x .vertices for x in args ])
326+ vertices = np .concatenate ([path .vertices for path in args ])
329327 codes = np .empty (len (vertices ), dtype = cls .code_type )
330328 i = 0
331329 for path in args :
330+ size = len (path .vertices )
332331 if path .codes is None :
333- codes [i ] = cls .MOVETO
334- codes [i + 1 :i + len (path .vertices )] = cls .LINETO
332+ if size :
333+ codes [i ] = cls .MOVETO
334+ codes [i + 1 :i + size ] = cls .LINETO
335335 else :
336- codes [i :i + len (path .codes )] = path .codes
337- i += len (path .vertices )
338- # remove STOP's, since internal STOPs are a bug
339- not_stop_mask = codes != cls .STOP
340- vertices = vertices [not_stop_mask , :]
341- codes = codes [not_stop_mask ]
342-
343- return cls (vertices , codes )
336+ codes [i :i + size ] = path .codes
337+ i += size
338+ not_stop_mask = codes != cls .STOP # Remove STOPs, as internal STOPs are a bug.
339+ return cls (vertices [not_stop_mask ], codes [not_stop_mask ])
344340
345341 def __repr__ (self ):
346342 return f"Path({ self .vertices !r} , { self .codes !r} )"
0 commit comments