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

Commit 716d046

Browse files
Merge pull request matplotlib#30162 from QuLogic/nan-spacing
TST: Fix runtime error checking NaN input to format_cursor_data
2 parents d810e68 + 3db5500 commit 716d046

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

‎lib/matplotlib/cbook.py‎

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2228,6 +2228,9 @@ def _g_sig_digits(value, delta):
22282228
Return the number of significant digits to %g-format *value*, assuming that
22292229
it is known with an error of *delta*.
22302230
"""
2231+
# For inf or nan, the precision doesn't matter.
2232+
if not math.isfinite(value):
2233+
return 0
22312234
if delta == 0:
22322235
if value == 0:
22332236
# if both value and delta are 0, np.spacing below returns 5e-324
@@ -2241,11 +2244,10 @@ def _g_sig_digits(value, delta):
22412244
# digits before the decimal point (floor(log10(45.67)) + 1 = 2): the total
22422245
# is 4 significant digits. A value of 0 contributes 1 "digit" before the
22432246
# decimal point.
2244-
# For inf or nan, the precision doesn't matter.
22452247
return max(
22462248
0,
22472249
(math.floor(math.log10(abs(value))) + 1 if value else 1)
2248-
- math.floor(math.log10(delta)))ifmath.isfinite(value) else0
2250+
- math.floor(math.log10(delta)))
22492251

22502252

22512253
def _unikey_or_keysym_to_mplkey(unikey, keysym):

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /