Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commitbbf0cd2

Browse files
committed
MNT: shorten logic + docstring
1 parentcfb27b3 commitbbf0cd2

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

‎lib/matplotlib/cbook/__init__.py‎

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1708,14 +1708,17 @@ 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,
17151716
supporting both index access and the iterator protocol.
17161717
The first non-None element will be obtained when skip_none is True.
17171718
"""
17181719
defsafe_isfinite(val):
1720+
ifvalisNone:
1721+
returnFalse
17191722
try:
17201723
returnnp.isfinite(val)ifnp.isscalar(val)elseTrue
17211724
exceptTypeError:
@@ -1743,10 +1746,7 @@ def safe_isfinite(val):
17431746
raiseRuntimeError("matplotlib does not "
17441747
"support generators as input")
17451748
else:
1746-
returnnext(
1747-
valforvalinobj
1748-
ifvalisnotNoneandsafe_isfinite(val)
1749-
)
1749+
returnnext(valforvalinobjifsafe_isfinite(val))
17501750

17511751

17521752
defsanitize_sequence(data):

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp