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

Function test_polygon_selector

lib/matplotlib/tests/test_widgets.py:1445–1555  ·  view source on GitHub ↗
(ax, draw_bounding_box)

Source from the content-addressed store, hash-verified

1443
1444@pytest.mark.parametrize('draw_bounding_box', [False, True])
1445def test_polygon_selector(ax, draw_bounding_box):
1446 check_selector = functools.partial(
1447 check_polygon_selector, draw_bounding_box=draw_bounding_box)
1448
1449 # Simple polygon
1450 expected_result = [(50, 50), (150, 50), (50, 150)]
1451 event_sequence = [
1452 *polygon_place_vertex(ax, (50, 50)),
1453 *polygon_place_vertex(ax, (150, 50)),
1454 *polygon_place_vertex(ax, (50, 150)),
1455 *polygon_place_vertex(ax, (50, 50)),
1456 ]
1457 check_selector(event_sequence, expected_result, 1)
1458
1459 # Move first vertex before completing the polygon.
1460 expected_result = [(75, 50), (150, 50), (50, 150)]
1461 event_sequence = [
1462 *polygon_place_vertex(ax, (50, 50)),
1463 *polygon_place_vertex(ax, (150, 50)),
1464 KeyEvent("key_press_event", ax.figure.canvas, "control"),
1465 MouseEvent._from_ax_coords("motion_notify_event", ax, (50, 50)),
1466 MouseEvent._from_ax_coords("button_press_event", ax, (50, 50), 1),
1467 MouseEvent._from_ax_coords("motion_notify_event", ax, (75, 50)),
1468 MouseEvent._from_ax_coords("button_release_event", ax, (75, 50), 1),
1469 KeyEvent("key_release_event", ax.figure.canvas, "control"),
1470 *polygon_place_vertex(ax, (50, 150)),
1471 *polygon_place_vertex(ax, (75, 50)),
1472 ]
1473 check_selector(event_sequence, expected_result, 1)
1474
1475 # Move first two vertices at once before completing the polygon.
1476 expected_result = [(50, 75), (150, 75), (50, 150)]
1477 event_sequence = [
1478 *polygon_place_vertex(ax, (50, 50)),
1479 *polygon_place_vertex(ax, (150, 50)),
1480 KeyEvent("key_press_event", ax.figure.canvas, "shift"),
1481 MouseEvent._from_ax_coords("motion_notify_event", ax, (100, 100)),
1482 MouseEvent._from_ax_coords("button_press_event", ax, (100, 100), 1),
1483 MouseEvent._from_ax_coords("motion_notify_event", ax, (100, 125)),
1484 MouseEvent._from_ax_coords("button_release_event", ax, (100, 125), 1),
1485 KeyEvent("key_release_event", ax.figure.canvas, "shift"),
1486 *polygon_place_vertex(ax, (50, 150)),
1487 *polygon_place_vertex(ax, (50, 75)),
1488 ]
1489 check_selector(event_sequence, expected_result, 1)
1490
1491 # Move first vertex after completing the polygon.
1492 expected_result = [(85, 50), (150, 50), (50, 150)]
1493 event_sequence = [
1494 *polygon_place_vertex(ax, (60, 50)),
1495 *polygon_place_vertex(ax, (150, 50)),
1496 *polygon_place_vertex(ax, (50, 150)),
1497 *polygon_place_vertex(ax, (60, 50)),
1498 MouseEvent._from_ax_coords("motion_notify_event", ax, (60, 50)),
1499 MouseEvent._from_ax_coords("button_press_event", ax, (60, 50), 1),
1500 MouseEvent._from_ax_coords("motion_notify_event", ax, (85, 50)),
1501 MouseEvent._from_ax_coords("button_release_event", ax, (85, 50), 1),
1502 ]

Callers

nothing calls this directly

Calls 3

KeyEventClass · 0.90
polygon_place_vertexFunction · 0.85
_from_ax_coordsMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…