File tree Expand file tree Collapse file tree 1 file changed +4
-2
lines changed Expand file tree Collapse file tree 1 file changed +4
-2
lines changed Original file line number Diff line number Diff line change @@ -2208,6 +2208,9 @@ def _g_sig_digits(value, delta):
2208
2208
Return the number of significant digits to %g-format *value*, assuming that
2209
2209
it is known with an error of *delta*.
2210
2210
"""
2211
+ # For inf or nan, the precision doesn't matter.
2212
+ if not math .isfinite (value ):
2213
+ return 0
2211
2214
if delta == 0 :
2212
2215
if value == 0 :
2213
2216
# if both value and delta are 0, np.spacing below returns 5e-324
@@ -2221,11 +2224,10 @@ def _g_sig_digits(value, delta):
2221
2224
# digits before the decimal point (floor(log10(45.67)) + 1 = 2): the total
2222
2225
# is 4 significant digits. A value of 0 contributes 1 "digit" before the
2223
2226
# decimal point.
2224
- # For inf or nan, the precision doesn't matter.
2225
2227
return max (
2226
2228
0 ,
2227
2229
(math .floor (math .log10 (abs (value ))) + 1 if value else 1 )
2228
- - math .floor (math .log10 (delta ))) if math . isfinite ( value ) else 0
2230
+ - math .floor (math .log10 (delta )))
2229
2231
2230
2232
2231
2233
def _unikey_or_keysym_to_mplkey (unikey , keysym ):
You can’t perform that action at this time.
0 commit comments