File tree Expand file tree Collapse file tree 2 files changed +12
-1
lines changed Expand file tree Collapse file tree 2 files changed +12
-1
lines changed Original file line number Diff line number Diff line change @@ -326,6 +326,10 @@ def make_compound_path_from_polys(cls, XY):
326
326
@classmethod
327
327
def make_compound_path (cls , * args ):
328
328
"""Make a compound path from a list of Path objects."""
329
+ # Handle an empty list in args (i.e. no args).
330
+ if not args :
331
+ return Path (np .empty ([0 , 2 ], dtype = np .float32 ))
332
+
329
333
lengths = [len (x ) for x in args ]
330
334
total_length = sum (lengths )
331
335
Original file line number Diff line number Diff line change 7
7
8
8
from matplotlib .path import Path
9
9
from matplotlib .patches import Polygon
10
- from nose .tools import assert_raises
10
+ from nose .tools import assert_raises , assert_equal
11
11
from matplotlib .testing .decorators import image_comparison
12
12
import matplotlib .pyplot as plt
13
13
@@ -70,6 +70,13 @@ def test_point_in_path_nan():
70
70
assert not contains [0 ]
71
71
72
72
73
+ def test_make_compound_path_empty ():
74
+ # We should be able to make a compound path with no arguments.
75
+ # This makes it easier to write generic path based code.
76
+ r = Path .make_compound_path ()
77
+ assert_equal (r .vertices .shape , (0 , 2 ))
78
+
79
+
73
80
if __name__ == '__main__' :
74
81
import nose
75
82
nose .runmodule (argv = ['-s' , '--with-doctest' ], exit = False )
You can’t perform that action at this time.
0 commit comments