Skip to content

Commit 1689853

Browse files
tacaswellmeeseeksmachine
authored andcommitted
Backport PR #26807: Catch ValueError to support pytorch (and others) plotting
1 parent 33c6403 commit 1689853

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)