Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit fe6a433

Browse files
authored
Merge pull request #18269 from meeseeksmachine/auto-backport-of-pr-18266-on-v3.3.x
Backport PR #18266 on branch v3.3.x (Fix Path.get_extents for empty paths.)
2 parents b1452eb + 91176f5 commit fe6a433

File tree

2 files changed

+6
-1
lines changed

2 files changed

+6
-1
lines changed

lib/matplotlib/path.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -600,7 +600,10 @@ def get_extents(self, transform=None, **kwargs):
600600
# as can the ends of the curve
601601
xys.append(curve([0, *dzeros, 1]))
602602
xys = np.concatenate(xys)
603-
return Bbox([xys.min(axis=0), xys.max(axis=0)])
603+
if len(xys):
604+
return Bbox([xys.min(axis=0), xys.max(axis=0)])
605+
else:
606+
return Bbox.null()
604607

605608
def intersects_path(self, other, filled=True):
606609
"""

lib/matplotlib/tests/test_path.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,8 @@ def test_empty_closed_path():
1919
path = Path(np.zeros((0, 2)), closed=True)
2020
assert path.vertices.shape == (0, 2)
2121
assert path.codes is None
22+
assert_array_equal(path.get_extents().extents,
23+
transforms.Bbox.null().extents)
2224

2325

2426
def test_readonly_path():

0 commit comments

Comments
 (0)