From 16898539e5937640e6849b181b4d882d21ed0fb0 Mon Sep 17 00:00:00 2001 From: Thomas A Caswell Date: Mon, 18 Sep 2023 12:00:57 -0400 Subject: [PATCH] Backport PR #26807: Catch ValueError to support pytorch (and others) plotting --- lib/matplotlib/cbook.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/matplotlib/cbook.py b/lib/matplotlib/cbook.py index 80ec1612688b..f02486a0e280 100644 --- a/lib/matplotlib/cbook.py +++ b/lib/matplotlib/cbook.py @@ -1685,7 +1685,7 @@ def safe_first_element(obj): def _safe_first_finite(obj, *, skip_nonfinite=True): """ Return the first finite element in *obj* if one is available and skip_nonfinite is - True. Otherwise return the first element. + True. Otherwise, return the first element. This is a method for internal use. @@ -1697,7 +1697,7 @@ def safe_isfinite(val): return False try: return math.isfinite(val) - except TypeError: + except (TypeError, ValueError): pass try: return np.isfinite(val) if np.isscalar(val) else True 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