Commit b8d9247
committed
Fix format_cursor_data for values close to float resolution.
Previously, moving the cursor over
`plt.imshow(1 + np.random.randn(10, 10) * 1e-15)` would result in
`ValueError: math domain error` (when trying to compute
`math.log10(delta)` with `delta = 0`). This is because the full range
of normalization implied by the image above (~1e-15) is representable
with float precision, but the spacing between individual colors (256x
less) is too small to be represented, and thus rounded to zero.
In general, I consider that such floating point errors should be fixed
on the user side, but this specific error seems worth fixing as the 1)
the image is still rendered correctly, 2) errors in the mouse event
handler (rendering the cursor text) are somewhat obscure for end users,
and 3) it used to work before Matplotlib 3.5.1 parent 0bb36e8 commit b8d9247
2 files changed
+5
-0
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
2212 | 2212 | | |
2213 | 2213 | | |
2214 | 2214 | | |
| 2215 | + | |
| 2216 | + | |
| 2217 | + | |
| 2218 | + | |
2215 | 2219 | | |
2216 | 2220 | | |
2217 | 2221 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
341 | 341 | | |
342 | 342 | | |
343 | 343 | | |
| 344 | + | |
344 | 345 | | |
345 | 346 | | |
346 | 347 | | |
| |||
0 commit comments