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

Function test_rectangle_rotate

lib/matplotlib/tests/test_widgets.py:440–470  ·  view source on GitHub ↗
(ax, selector_class)

Source from the content-addressed store, hash-verified

438@pytest.mark.parametrize('selector_class',
439 [widgets.RectangleSelector, widgets.EllipseSelector])
440def test_rectangle_rotate(ax, selector_class):
441 tool = selector_class(ax, interactive=True)
442 # Draw rectangle
443 click_and_drag(tool, start=(100, 100), end=(130, 140))
444 assert tool.extents == (100, 130, 100, 140)
445 assert len(tool._state) == 0
446
447 # Rotate anticlockwise using top-right corner
448 KeyEvent("key_press_event", ax.figure.canvas, "r")._process()
449 assert tool._state == {'rotate'}
450 assert len(tool._state) == 1
451 click_and_drag(tool, start=(130, 140), end=(120, 145))
452 KeyEvent("key_press_event", ax.figure.canvas, "r")._process()
453 assert len(tool._state) == 0
454 # Extents shouldn't change (as shape of rectangle hasn't changed)
455 assert tool.extents == (100, 130, 100, 140)
456 assert_allclose(tool.rotation, 25.56, atol=0.01)
457 tool.rotation = 45
458 assert tool.rotation == 45
459 # Corners should move
460 assert_allclose(tool.corners,
461 np.array([[118.53, 139.75, 111.46, 90.25],
462 [95.25, 116.46, 144.75, 123.54]]), atol=0.01)
463
464 # Scale using top-right corner
465 click_and_drag(tool, start=(110, 145), end=(110, 160))
466 assert_allclose(tool.extents, (100, 139.75, 100, 151.82), atol=0.01)
467
468 if selector_class == widgets.RectangleSelector:
469 with pytest.raises(ValueError):
470 tool._selection_artist.rotation_point = 'unvalid_value'
471
472
473def test_rectangle_add_remove_set(ax):

Callers

nothing calls this directly

Calls 3

click_and_dragFunction · 0.90
KeyEventClass · 0.90
_processMethod · 0.80

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…