File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -335,6 +335,10 @@ def make_compound_path_from_polys(cls, XY):
335335 @classmethod
336336 def make_compound_path (cls , * args ):
337337 """Make a compound path from a list of Path objects."""
338+ # Handle an empty list in args (i.e. no args).
339+ if not args :
340+ return Path (np .empty ([0 , 2 ], dtype = np .float32 ))
341+
338342 lengths = [len (x ) for x in args ]
339343 total_length = sum (lengths )
340344
Original file line number Diff line number Diff line change 77
88from matplotlib .path import Path
99from matplotlib .patches import Polygon
10- from nose .tools import assert_raises
10+ from nose .tools import assert_raises , assert_equal
1111from matplotlib .testing .decorators import image_comparison
1212import matplotlib .pyplot as plt
1313
@@ -82,6 +82,13 @@ def test_log_transform_with_zero():
8282 ax .grid (True )
8383
8484
85+ def test_make_compound_path_empty ():
86+ # We should be able to make a compound path with no arguments.
87+ # This makes it easier to write generic path based code.
88+ r = Path .make_compound_path ()
89+ assert_equal (r .vertices .shape , (0 , 2 ))
90+
91+
8592if __name__ == '__main__' :
8693 import nose
8794 nose .runmodule (argv = ['-s' , '--with-doctest' ], exit = False )
You can’t perform that action at this time.
0 commit comments