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

Function test_rectangle_minspan

lib/matplotlib/tests/test_widgets.py:97–129  ·  view source on GitHub ↗
(ax, spancoords, minspanx, x1, minspany, y1)

Source from the content-addressed store, hash-verified

95@pytest.mark.parametrize('minspanx, x1', [[0, 10], [1, 10.5], [1, 11]])
96@pytest.mark.parametrize('minspany, y1', [[0, 10], [1, 10.5], [1, 11]])
97def test_rectangle_minspan(ax, spancoords, minspanx, x1, minspany, y1):
98
99 onselect = mock.Mock(spec=noop, return_value=None)
100
101 x0, y0 = (10, 10)
102 if spancoords == 'pixels':
103 minspanx, minspany = (ax.transData.transform((x1, y1)) -
104 ax.transData.transform((x0, y0)))
105
106 tool = widgets.RectangleSelector(ax, onselect=onselect, interactive=True,
107 spancoords=spancoords,
108 minspanx=minspanx, minspany=minspany)
109 # Too small to create a selector
110 click_and_drag(tool, start=(x0, x1), end=(y0, y1))
111 assert not tool._selection_completed
112 onselect.assert_not_called()
113
114 click_and_drag(tool, start=(20, 20), end=(30, 30))
115 assert tool._selection_completed
116 onselect.assert_called_once()
117
118 # Too small to create a selector. Should clear existing selector, and
119 # trigger onselect because there was a preexisting selector
120 onselect.reset_mock()
121 click_and_drag(tool, start=(x0, y0), end=(x1, y1))
122 assert not tool._selection_completed
123 onselect.assert_called_once()
124 (epress, erelease), kwargs = onselect.call_args
125 assert epress.xdata == x0
126 assert epress.ydata == y0
127 assert erelease.xdata == x1
128 assert erelease.ydata == y1
129 assert kwargs == {}
130
131
132@pytest.mark.parametrize('drag_from_anywhere, new_center',

Callers

nothing calls this directly

Calls 2

click_and_dragFunction · 0.90
transformMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…