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

Function test_span_selector_bound

lib/matplotlib/tests/test_widgets.py:869–893  ·  view source on GitHub ↗
(direction)

Source from the content-addressed store, hash-verified

867
868@pytest.mark.parametrize('direction', ("horizontal", "vertical"))
869def test_span_selector_bound(direction):
870 fig, ax = plt.subplots(1, 1)
871 ax.plot([10, 20], [10, 30])
872 fig.canvas.draw()
873 x_bound = ax.get_xbound()
874 y_bound = ax.get_ybound()
875
876 tool = widgets.SpanSelector(ax, print, direction, interactive=True)
877 assert ax.get_xbound() == x_bound
878 assert ax.get_ybound() == y_bound
879
880 bound = x_bound if direction == 'horizontal' else y_bound
881 assert tool._edge_handles.positions == list(bound)
882
883 press_data = (10.5, 11.5)
884 move_data = (11, 13) # Updating selector is done in onmove
885 release_data = move_data
886 click_and_drag(tool, start=press_data, end=move_data)
887
888 assert ax.get_xbound() == x_bound
889 assert ax.get_ybound() == y_bound
890
891 index = 0 if direction == 'horizontal' else 1
892 handle_positions = [press_data[index], release_data[index]]
893 assert tool._edge_handles.positions == handle_positions
894
895
896@pytest.mark.backend('QtAgg', skip_on_importerror=True)

Callers

nothing calls this directly

Calls 6

click_and_dragFunction · 0.90
get_xboundMethod · 0.80
get_yboundMethod · 0.80
subplotsMethod · 0.45
plotMethod · 0.45
drawMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…