MCPcopy Index your code
hub / github.com/matplotlib/matplotlib / test_cursor_data_nonuniform

Function test_cursor_data_nonuniform

lib/matplotlib/tests/test_image.py:427–445  ·  view source on GitHub ↗
(xy, data)

Source from the content-addressed store, hash-verified

425 ]
426)
427def 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(

Callers

nothing calls this directly

Calls 11

set_dataMethod · 0.95
get_cursor_dataMethod · 0.95
NonUniformImageClass · 0.90
MouseEventClass · 0.90
minMethod · 0.80
maxMethod · 0.80
add_imageMethod · 0.80
subplotsMethod · 0.45
set_xlimMethod · 0.45
set_ylimMethod · 0.45
transformMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…