Skip to content

Commit 3d5585a

Browse files
authored
Merge pull request #26807 from oscargus/torchfix
Catch ValueError to support pytorch (and others) plotting
2 parents 8f3e9e6 + a75771b commit 3d5585a

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

lib/matplotlib/cbook.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1685,7 +1685,7 @@ def safe_first_element(obj):
16851685
def _safe_first_finite(obj, *, skip_nonfinite=True):
16861686
"""
16871687
Return the first finite element in *obj* if one is available and skip_nonfinite is
1688-
True. Otherwise return the first element.
1688+
True. Otherwise, return the first element.
16891689
16901690
This is a method for internal use.
16911691
@@ -1697,7 +1697,7 @@ def safe_isfinite(val):
16971697
return False
16981698
try:
16991699
return math.isfinite(val)
1700-
except TypeError:
1700+
except (TypeError, ValueError):
17011701
pass
17021702
try:
17031703
return np.isfinite(val) if np.isscalar(val) else True

0 commit comments

Comments
 (0)
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