File tree 2 files changed +18
-0
lines changed
2 files changed +18
-0
lines changed Original file line number Diff line number Diff line change @@ -330,6 +330,7 @@ def make_compound_path(cls, *args):
330
330
if not args :
331
331
return Path (np .empty ([0 , 2 ], dtype = np .float32 ))
332
332
333
+ # concatenate paths
333
334
vertices = np .concatenate ([x .vertices for x in args ])
334
335
codes = np .empty (len (vertices ), dtype = cls .code_type )
335
336
i = 0
@@ -341,6 +342,16 @@ def make_compound_path(cls, *args):
341
342
codes [i :i + len (path .codes )] = path .codes
342
343
i += len (path .vertices )
343
344
345
+ # remove internal STOP's, replace kinal stop if present
346
+ last_vert = None
347
+ if codes .size > 0 and codes [- 1 ] == cls .STOP :
348
+ last_vert = vertices [- 1 ]
349
+ vertices = vertices [codes != cls .STOP , :]
350
+ codes = codes [codes != cls .STOP ]
351
+ if last_vert is not None :
352
+ vertices = np .append (vertices , [last_vert ], axis = 0 )
353
+ codes = np .append (codes , cls .STOP )
354
+
344
355
return cls (vertices , codes )
345
356
346
357
def __repr__ (self ):
Original file line number Diff line number Diff line change @@ -147,6 +147,13 @@ 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
+ assert np .sum (compound_path .codes == Path .STOP ) == 1
155
+
156
+
150
157
@image_comparison (['xkcd.png' ], remove_text = True )
151
158
def test_xkcd ():
152
159
np .random .seed (0 )
You can’t perform that action at this time.
0 commit comments