From 8ce2457cbd859c6af9b9f686f3d57277c50bad60 Mon Sep 17 00:00:00 2001 From: Elliott Sales de Andrade Date: Fri, 14 Aug 2020 20:02:22 -0400 Subject: [PATCH] Fix Path.get_extents for empty paths. --- lib/matplotlib/path.py | 5 ++++- lib/matplotlib/tests/test_path.py | 2 ++ 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/lib/matplotlib/path.py b/lib/matplotlib/path.py index 5088596a893f..e1daf35eed45 100644 --- a/lib/matplotlib/path.py +++ b/lib/matplotlib/path.py @@ -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): """ diff --git a/lib/matplotlib/tests/test_path.py b/lib/matplotlib/tests/test_path.py index ebe2e1a46de7..2c4844b47f37 100644 --- a/lib/matplotlib/tests/test_path.py +++ b/lib/matplotlib/tests/test_path.py @@ -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():