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

Function test_rectangle_selector

lib/matplotlib/tests/test_widgets.py:70–91  ·  view source on GitHub ↗
(ax, kwargs)

Source from the content-addressed store, hash-verified

68 dict(props=dict(fill=True)),
69])
70def test_rectangle_selector(ax, kwargs):
71 onselect = mock.Mock(spec=noop, return_value=None)
72
73 tool = widgets.RectangleSelector(ax, onselect=onselect, **kwargs)
74 MouseEvent._from_ax_coords("button_press_event", ax, (100, 100), 1)._process()
75 MouseEvent._from_ax_coords("motion_notify_event", ax, (199, 199), 1)._process()
76 # purposely drag outside of axis for release
77 MouseEvent._from_ax_coords("button_release_event", ax, (250, 250), 1)._process()
78
79 if kwargs.get('drawtype', None) not in ['line', 'none']:
80 assert_allclose(tool.geometry,
81 [[100., 100, 199, 199, 100],
82 [100, 199, 199, 100, 100]],
83 err_msg=tool.geometry)
84
85 onselect.assert_called_once()
86 (epress, erelease), kwargs = onselect.call_args
87 assert epress.xdata == 100
88 assert epress.ydata == 100
89 assert erelease.xdata == 199
90 assert erelease.ydata == 199
91 assert kwargs == {}
92
93
94@pytest.mark.parametrize('spancoords', ['data', 'pixels'])

Callers

nothing calls this directly

Calls 3

_processMethod · 0.80
_from_ax_coordsMethod · 0.45
getMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…