Skip to content

Commit 72e95f0

Browse files
committed
draw_box > draw_bounding_box
1 parent a45ef42 commit 72e95f0

File tree

2 files changed

+22
-19
lines changed

2 files changed

+22
-19
lines changed

lib/matplotlib/tests/test_widgets.py

Lines changed: 19 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1164,10 +1164,10 @@ def polygon_remove_vertex(xdata, ydata):
11641164
('release', dict(xdata=xdata, ydata=ydata, button=3))]
11651165

11661166

1167-
@pytest.mark.parametrize('draw_box', [False, True])
1168-
def test_polygon_selector(draw_box):
1167+
@pytest.mark.parametrize('draw_bounding_box', [False, True])
1168+
def test_polygon_selector(draw_bounding_box):
11691169
check_selector = functools.partial(
1170-
check_polygon_selector, draw_box=draw_box)
1170+
check_polygon_selector, draw_bounding_box=draw_bounding_box)
11711171

11721172
# Simple polygon
11731173
expected_result = [(50, 50), (150, 50), (50, 150)]
@@ -1264,8 +1264,8 @@ def test_polygon_selector(draw_box):
12641264
check_selector(event_sequence, expected_result, 1)
12651265

12661266

1267-
@pytest.mark.parametrize('draw_box', [False, True])
1268-
def test_polygon_selector_set_props_handle_props(draw_box):
1267+
@pytest.mark.parametrize('draw_bounding_box', [False, True])
1268+
def test_polygon_selector_set_props_handle_props(draw_bounding_box):
12691269
ax = get_ax()
12701270

12711271
ax._selections_count = 0
@@ -1277,7 +1277,7 @@ def onselect(vertices):
12771277
tool = widgets.PolygonSelector(ax, onselect,
12781278
props=dict(color='b', alpha=0.2),
12791279
handle_props=dict(alpha=0.5),
1280-
draw_box=draw_box)
1280+
draw_bounding_box=draw_bounding_box)
12811281

12821282
event_sequence = (polygon_place_vertex(50, 50)
12831283
+ polygon_place_vertex(150, 50)
@@ -1319,8 +1319,8 @@ def onselect(verts):
13191319

13201320
# Change the order that the extra point is inserted in
13211321
@pytest.mark.parametrize('idx', [1, 2, 3])
1322-
@pytest.mark.parametrize('draw_box', [False, True])
1323-
def test_polygon_selector_remove(idx, draw_box):
1322+
@pytest.mark.parametrize('draw_bounding_box', [False, True])
1323+
def test_polygon_selector_remove(idx, draw_bounding_box):
13241324
verts = [(50, 50), (150, 50), (50, 150)]
13251325
event_sequence = [polygon_place_vertex(*verts[0]),
13261326
polygon_place_vertex(*verts[1]),
@@ -1333,22 +1333,24 @@ def test_polygon_selector_remove(idx, draw_box):
13331333
event_sequence.append(polygon_remove_vertex(200, 200))
13341334
# Flatten list of lists
13351335
event_sequence = sum(event_sequence, [])
1336-
check_polygon_selector(event_sequence, verts, 2, draw_box=draw_box)
1336+
check_polygon_selector(event_sequence, verts, 2,
1337+
draw_bounding_box=draw_bounding_box)
13371338

13381339

1339-
@pytest.mark.parametrize('draw_box', [False, True])
1340-
def test_polygon_selector_remove_first_point(draw_box):
1340+
@pytest.mark.parametrize('draw_bounding_box', [False, True])
1341+
def test_polygon_selector_remove_first_point(draw_bounding_box):
13411342
verts = [(50, 50), (150, 50), (50, 150)]
13421343
event_sequence = (polygon_place_vertex(*verts[0]) +
13431344
polygon_place_vertex(*verts[1]) +
13441345
polygon_place_vertex(*verts[2]) +
13451346
polygon_place_vertex(*verts[0]) +
13461347
polygon_remove_vertex(*verts[0]))
1347-
check_polygon_selector(event_sequence, verts[1:], 2, draw_box=draw_box)
1348+
check_polygon_selector(event_sequence, verts[1:], 2,
1349+
draw_bounding_box=draw_bounding_box)
13481350

13491351

1350-
@pytest.mark.parametrize('draw_box', [False, True])
1351-
def test_polygon_selector_redraw(draw_box):
1352+
@pytest.mark.parametrize('draw_bounding_box', [False, True])
1353+
def test_polygon_selector_redraw(draw_bounding_box):
13521354
verts = [(50, 50), (150, 50), (50, 150)]
13531355
event_sequence = (polygon_place_vertex(*verts[0]) +
13541356
polygon_place_vertex(*verts[1]) +
@@ -1366,7 +1368,8 @@ def test_polygon_selector_redraw(draw_box):
13661368
def onselect(vertices):
13671369
pass
13681370

1369-
tool = widgets.PolygonSelector(ax, onselect, draw_box=draw_box)
1371+
tool = widgets.PolygonSelector(ax, onselect,
1372+
draw_bounding_box=draw_bounding_box)
13701373
for (etype, event_args) in event_sequence:
13711374
do_event(tool, etype, **event_args)
13721375
# After removing two verts, only one remains, and the
@@ -1411,7 +1414,7 @@ def onselect(vertices):
14111414
pass
14121415

14131416
# Create selector
1414-
tool = widgets.PolygonSelector(ax, onselect, draw_box=True)
1417+
tool = widgets.PolygonSelector(ax, onselect, draw_bounding_box=True)
14151418
for (etype, event_args) in event_sequence:
14161419
do_event(tool, etype, **event_args)
14171420

lib/matplotlib/widgets.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3576,7 +3576,7 @@ class PolygonSelector(_SelectorWidget):
35763576
A vertex is selected (to complete the polygon or to move a vertex) if
35773577
the mouse click is within *grab_range* pixels of the vertex.
35783578
3579-
draw_box : bool, optional
3579+
draw_bounding_box : bool, optional
35803580
If `True`, a bounding box will be drawn around the polygon selector
35813581
once it is complete. This box can be used to move and resize the
35823582
selector.
@@ -3605,7 +3605,7 @@ class PolygonSelector(_SelectorWidget):
36053605
@_api.rename_parameter("3.5", "vertex_select_radius", "grab_range")
36063606
def __init__(self, ax, onselect, useblit=False,
36073607
props=None, handle_props=None, grab_range=10, *,
3608-
draw_box=False, box_handle_props=None,
3608+
draw_bounding_box=False, box_handle_props=None,
36093609
box_props=None):
36103610
# The state modifiers 'move', 'square', and 'center' are expected by
36113611
# _SelectorWidget but are not supported by PolygonSelector
@@ -3642,7 +3642,7 @@ def __init__(self, ax, onselect, useblit=False,
36423642
self.grab_range = grab_range
36433643

36443644
self.set_visible(True)
3645-
self._draw_box = draw_box
3645+
self._draw_box = draw_bounding_box
36463646
self._box = None
36473647

36483648
if box_handle_props is None:

0 commit comments

Comments
 (0)