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 @@ -2228,6 +2228,9 @@ def _g_sig_digits(value, delta):
2228
2228
Return the number of significant digits to %g-format *value*, assuming that
2229
2229
it is known with an error of *delta*.
2230
2230
"""
2231
+ # For inf or nan, the precision doesn't matter.
2232
+ if not math .isfinite (value ):
2233
+ return 0
2231
2234
if delta == 0 :
2232
2235
if value == 0 :
2233
2236
# if both value and delta are 0, np.spacing below returns 5e-324
@@ -2241,11 +2244,10 @@ def _g_sig_digits(value, delta):
2241
2244
# digits before the decimal point (floor(log10(45.67)) + 1 = 2): the total
2242
2245
# is 4 significant digits. A value of 0 contributes 1 "digit" before the
2243
2246
# decimal point.
2244
- # For inf or nan, the precision doesn't matter.
2245
2247
return max (
2246
2248
0 ,
2247
2249
(math .floor (math .log10 (abs (value ))) + 1 if value else 1 )
2248
- - math .floor (math .log10 (delta ))) if math . isfinite ( value ) else 0
2250
+ - math .floor (math .log10 (delta )))
2249
2251
2250
2252
2251
2253
def _unikey_or_keysym_to_mplkey (unikey , keysym ):
You can’t perform that action at this time.
0 commit comments