8000 Fixed zero args to make_compound_path. · matplotlib/matplotlib@273784c · GitHub
[go: up one dir, main page]

Skip to content
Commit 273784c
Browse files
committed
Fixed zero args to make_compound_path.
1 parent 3486a67 commit 273784c

File tree

2 files changed

+12
-1
lines changed

2 files changed

+12
-1
lines changed

lib/matplotlib/path.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -326,6 +326,10 @@ def make_compound_path_from_polys(cls, XY):
326326
@classmethod
327327
def make_compound_path(cls, *args):
328328
"""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+
329333
lengths = [len(x) for x in args]
330334
total_length = sum(lengths)
331335

lib/matplotlib/tests/test_path.py

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77

88
from matplotlib.path import Path
99
from matplotlib.patches import Polygon
10-
from nose.tools import assert_raises
10+
from nose.tools import assert_raises, assert_equal
1111
from matplotlib.testing.decorators import image_comparison
1212
import matplotlib.pyplot as plt
1313

@@ -70,6 +70,13 @@ def test_point_in_path_nan():
7070
assert not contains[0]
7171

7272

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+
7380
if __name__ == '__main__':
7481
import nose
7582
nose.runmodule(argv=['-s', '--with-doctest'], exit=False)

0 commit comments

Comments
 (0)
0