(ax, orientation, onmove_callback, kwargs)
| 633 | ('horizontal', False, dict(interactive=True)), |
| 634 | ]) |
| 635 | def test_span_selector(ax, orientation, onmove_callback, kwargs): |
| 636 | # Also test that span selectors work in the presence of twin axes or for |
| 637 | # outside-inset axes on top of the axes that contain the selector. Note |
| 638 | # that we need to unforce the axes aspect here, otherwise the twin axes |
| 639 | # forces the original axes' limits (to respect aspect=1) which makes some |
| 640 | # of the values below go out of bounds. |
| 641 | ax.set_aspect("auto") |
| 642 | ax.twinx() |
| 643 | child = ax.inset_axes([0, 1, 1, 1], xlim=(0, 200), ylim=(0, 200)) |
| 644 | |
| 645 | for target in [ax, child]: |
| 646 | selected = [] |
| 647 | def onselect(*args): selected.append(args) |
| 648 | moved = [] |
| 649 | def onmove(*args): moved.append(args) |
| 650 | if onmove_callback: |
| 651 | kwargs['onmove_callback'] = onmove |
| 652 | |
| 653 | tool = widgets.SpanSelector(target, onselect, orientation, **kwargs) |
| 654 | MouseEvent._from_ax_coords( |
| 655 | "button_press_event", target, (100, 100), 1)._process() |
| 656 | # move outside of axis |
| 657 | MouseEvent._from_ax_coords( |
| 658 | "motion_notify_event", target, (199, 199), 1)._process() |
| 659 | MouseEvent._from_ax_coords( |
| 660 | "button_release_event", target, (250, 250), 1)._process() |
| 661 | |
| 662 | # tol is set by pixel size (~100 pixels & span of 200 data units) |
| 663 | assert_allclose(selected, [(100, 199)], atol=.5) |
| 664 | if onmove_callback: |
| 665 | assert_allclose(moved, [(100, 199)], atol=.5) |
| 666 | |
| 667 | |
| 668 | @pytest.mark.parametrize('interactive', [True, False]) |
nothing calls this directly
no test coverage detected
searching dependent graphs…