Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit ce5d274

Browse files
committed
MNT: shorten logic + docstring
1 parent cfb27b3 commit ce5d274

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

lib/matplotlib/cbook/__init__.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1708,7 +1708,8 @@ def safe_first_element(obj):
17081708

17091709
def _safe_first_finite(obj, *, skip_nonfinite=True):
17101710
"""
1711-
Return the first non-None element in *obj*.
1711+
Return the first non-None (and optionally finite) element in *obj*.
1712+
17121713
This is a method for internal use.
17131714
17141715
This is an type-independent way of obtaining the first non-None element,
@@ -1717,7 +1718,7 @@ def _safe_first_finite(obj, *, skip_nonfinite=True):
17171718
"""
17181719
def safe_isfinite(val):
17191720
try:
1720-
return np.isfinite(val) if np.isscalar(val) else True
1721+
return np.isscalar(val) and np.isfinite(val)
17211722
except TypeError:
17221723
# This is something that numpy can not make heads or tails
17231724
# of, assume "finite"

0 commit comments

Comments
 (0)