From 91176f54e9f48e42b5e9ee4d2fd9fe64a8f2334c Mon Sep 17 00:00:00 2001 From: Ryan May Date: Sat, 15 Aug 2020 14:24:51 -0600 Subject: [PATCH] Backport PR #18266: 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(): pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy