Skip to content

Commit

Permalink
Merge pull request #18266 from QuLogic/fix-empty-path-extent
Browse files Browse the repository at this point in the history
Fix Path.get_extents for empty paths.
  • Loading branch information
dopplershift committed Aug 15, 2020
2 parents 792756c + 8ce2457 commit 591b857
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
5 changes: 4 additions & 1 deletion lib/matplotlib/path.py
Original file line number Diff line number Diff line change
Expand Up @@ -600,7 +600,10 @@ def get_extents(self, transform=None, **kwargs):
# as can the ends of the curve
xys.append(curve([0, *dzeros, 1]))
xys = np.concatenate(xys)
return Bbox([xys.min(axis=0), xys.max(axis=0)])
if len(xys):
return Bbox([xys.min(axis=0), xys.max(axis=0)])
else:
return Bbox.null()

def intersects_path(self, other, filled=True):
"""
Expand Down
2 changes: 2 additions & 0 deletions lib/matplotlib/tests/test_path.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@ def test_empty_closed_path():
path = Path(np.zeros((0, 2)), closed=True)
assert path.vertices.shape == (0, 2)
assert path.codes is None
assert_array_equal(path.get_extents().extents,
transforms.Bbox.null().extents)


def test_readonly_path():
Expand Down

0 comments on commit 591b857

Please sign in to comment.