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

Commit3e2d546

Browse files
authored
Merge pull request#21275 from anntzer/fcdeps
Fix format_cursor_data for values close to float resolution.
2 parentsfcfea77 +5fbc3b3 commit3e2d546

File tree

2 files changed

+5
-0
lines changed

2 files changed

+5
-0
lines changed

‎lib/matplotlib/cbook/__init__.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2212,6 +2212,10 @@ def _g_sig_digits(value, delta):
22122212
Return the number of significant digits to %g-format *value*, assuming that
22132213
it is known with an error of *delta*.
22142214
"""
2215+
ifdelta==0:
2216+
# delta = 0 may occur when trying to format values over a tiny range;
2217+
# in that case, replace it by the distance to the closest float.
2218+
delta=np.spacing(value)
22152219
# If e.g. value = 45.67 and delta = 0.02, then we want to round to 2 digits
22162220
# after the decimal point (floor(log10(0.02)) = -2); 45.67 contributes 2
22172221
# digits before the decimal point (floor(log10(45.67)) + 1 = 2): the total

‎lib/matplotlib/tests/test_image.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -341,6 +341,7 @@ def test_cursor_data():
341341
([[10001,10000]],"[10001.000]"),
342342
([[.123,.987]],"[0.123]"),
343343
([[np.nan,1,2]],"[]"),
344+
([[1,1+1e-15]],"[1.0000000000000000]"),
344345
])
345346
deftest_format_cursor_data(data,text):
346347
frommatplotlib.backend_basesimportMouseEvent

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp