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

Commit7eb3ae5

Browse files
timhoffmmeeseeksmachine
authored andcommitted
Backport PRmatplotlib#30162: TST: Fix runtime error checking NaN input to format_cursor_data
1 parentf492078 commit7eb3ae5

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
@@ -2208,6 +2208,9 @@ def _g_sig_digits(value, delta):
22082208
Return the number of significant digits to %g-format *value*, assuming that
22092209
it is known with an error of *delta*.
22102210
"""
2211+
# For inf or nan, the precision doesn't matter.
2212+
ifnotmath.isfinite(value):
2213+
return0
22112214
ifdelta==0:
22122215
ifvalue==0:
22132216
# if both value and delta are 0, np.spacing below returns 5e-324
@@ -2221,11 +2224,10 @@ def _g_sig_digits(value, delta):
22212224
# digits before the decimal point (floor(log10(45.67)) + 1 = 2): the total
22222225
# is 4 significant digits. A value of 0 contributes 1 "digit" before the
22232226
# decimal point.
2224-
# For inf or nan, the precision doesn't matter.
22252227
returnmax(
22262228
0,
22272229
(math.floor(math.log10(abs(value)))+1ifvalueelse1)
2228-
-math.floor(math.log10(delta)))ifmath.isfinite(value)else0
2230+
-math.floor(math.log10(delta)))
22292231

22302232

22312233
def_unikey_or_keysym_to_mplkey(unikey,keysym):

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp