Skip to content

Fixed zero args to make_compound_path. #4107

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions lib/matplotlib/path.py
Original file line number Diff line number Diff line change
Expand Up @@ -326,6 +326,10 @@ def make_compound_path_from_polys(cls, XY):
@classmethod
def make_compound_path(cls, *args):
"""Make a compound path from a list of Path objects."""
# Handle an empty list in args (i.e. no args).
if not args:
return Path(np.empty([0, 2], dtype=np.float32))

lengths = [len(x) for x in args]
total_length = sum(lengths)

Expand Down
9 changes: 8 additions & 1 deletion lib/matplotlib/tests/test_path.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

from matplotlib.path import Path
from matplotlib.patches import Polygon
from nose.tools import assert_raises
from nose.tools import assert_raises, assert_equal
from matplotlib.testing.decorators import image_comparison
import matplotlib.pyplot as plt

Expand Down Expand Up @@ -70,6 +70,13 @@ def test_point_in_path_nan():
assert not contains[0]


def test_make_compound_path_empty():
# We should be able to make a compound path with no arguments.
# This makes it easier to write generic path based code.
r = Path.make_compound_path()
assert_equal(r.vertices.shape, (0, 2))


if __name__ == '__main__':
import nose
nose.runmodule(argv=['-s', '--with-doctest'], exit=False)