File tree 1 file changed +5
-5
lines changed 1 file changed +5
-5
lines changed Original file line number Diff line number Diff line change @@ -1708,14 +1708,17 @@ def safe_first_element(obj):
1708
1708
1709
1709
def _safe_first_finite (obj , * , skip_nonfinite = True ):
1710
1710
"""
1711
- Return the first non-None element in *obj*.
1711
+ Return the first non-None (and optionally finite) element in *obj*.
1712
+
1712
1713
This is a method for internal use.
1713
1714
1714
1715
This is an type-independent way of obtaining the first non-None element,
1715
1716
supporting both index access and the iterator protocol.
1716
1717
The first non-None element will be obtained when skip_none is True.
1717
1718
"""
1718
1719
def safe_isfinite (val ):
1720
+ if val is None :
1721
+ return False
1719
1722
try :
1720
1723
return np .isfinite (val ) if np .isscalar (val ) else True
1721
1724
except TypeError :
@@ -1743,10 +1746,7 @@ def safe_isfinite(val):
1743
1746
raise RuntimeError ("matplotlib does not "
1744
1747
"support generators as input" )
1745
1748
else :
1746
- return next (
1747
- val for val in obj
1748
- if val is not None and safe_isfinite (val )
1749
- )
1749
+ return next (val for val in obj if safe_isfinite (val ))
1750
1750
1751
1751
1752
1752
def sanitize_sequence (data ):
You can’t perform that action at this time.
0 commit comments