(xy, data)
| 425 | ] |
| 426 | ) |
| 427 | def test_cursor_data_nonuniform(xy, data): |
| 428 | from matplotlib.backend_bases import MouseEvent |
| 429 | |
| 430 | # Non-linear set of x-values |
| 431 | x = np.array([0, 1, 4, 9, 16]) |
| 432 | y = np.array([0, 1, 2, 3, 4]) |
| 433 | z = x[np.newaxis, :]**2 + y[:, np.newaxis]**2 |
| 434 | |
| 435 | fig, ax = plt.subplots() |
| 436 | im = NonUniformImage(ax, extent=(x.min(), x.max(), y.min(), y.max())) |
| 437 | im.set_data(x, y, z) |
| 438 | ax.add_image(im) |
| 439 | # Set lower min lim so we can test cursor outside image |
| 440 | ax.set_xlim(x.min() - 2, x.max()) |
| 441 | ax.set_ylim(y.min() - 2, y.max()) |
| 442 | |
| 443 | xdisp, ydisp = ax.transData.transform(xy) |
| 444 | event = MouseEvent('motion_notify_event', fig.canvas, xdisp, ydisp) |
| 445 | assert im.get_cursor_data(event) == data, (im.get_cursor_data(event), data) |
| 446 | |
| 447 | |
| 448 | @pytest.mark.parametrize( |
nothing calls this directly
no test coverage detected
searching dependent graphs…