Skip to content

Commit 30f9def

Browse files
committed
Merge #4107 'pelson/compound_path'
Merged into master instead of v1.4.x Conflict was two new test in the same place, kept both.
2 parents cc3a4c1 + 273784c commit 30f9def

File tree

2 files changed

+12
-1
lines changed

2 files changed

+12
-1
lines changed

lib/matplotlib/path.py

+4
Original file line numberDiff line numberDiff 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

lib/matplotlib/tests/test_path.py

+8-1
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

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

0 commit comments

Comments
 (0)