Skip to content

Commit 1f1340e

Browse files
committed
Expire deprecations in widgets and keyword only arguments for Selectors
1 parent f6e7512 commit 1f1340e

File tree

2 files changed

+19
-110
lines changed

2 files changed

+19
-110
lines changed

lib/matplotlib/tests/test_widgets.py

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -24,11 +24,7 @@ def ax():
2424

2525
@pytest.mark.parametrize('kwargs, warning_msg', [
2626
(dict(), None),
27-
(dict(drawtype='line', useblit=False),
28-
"Support for drawtype='line' is deprecated"),
2927
(dict(useblit=True, button=1), None),
30-
(dict(drawtype='none', minspanx=10, minspany=10),
31-
"Support for drawtype='none' is deprecated"),
3228
(dict(minspanx=10, minspany=10, spancoords='pixels'), None),
3329
(dict(props=dict(fill=True)), None),
3430
])

lib/matplotlib/widgets.py

Lines changed: 19 additions & 106 deletions
Original file line numberDiff line numberDiff line change
@@ -588,6 +588,7 @@ class RangeSlider(SliderBase):
588588
Slider value.
589589
"""
590590

591+
@_api.make_keyword_only("3.7", name="valinit")
591592
def __init__(
592593
self,
593594
ax,
@@ -1124,8 +1125,7 @@ class TextBox(AxesWidget):
11241125
The color of the text box when hovering.
11251126
"""
11261127

1127-
DIST_FROM_LEFT = _api.deprecate_privatize_attribute("3.5")
1128-
1128+
@_api.make_keyword_only("3.7", name="color")
11291129
def __init__(self, ax, label, initial='',
11301130
color='.95', hovercolor='1', label_pad=.01,
11311131
textalignment="left"):
@@ -1839,11 +1839,6 @@ def __init__(self, ax, onselect, useblit=False, button=None,
18391839
self._prev_event = None
18401840
self._state = set()
18411841

1842-
eventpress = _api.deprecate_privatize_attribute("3.5")
1843-
eventrelease = _api.deprecate_privatize_attribute("3.5")
1844-
state = _api.deprecate_privatize_attribute("3.5")
1845-
state_modifier_keys = _api.deprecate_privatize_attribute("3.6")
1846-
18471842
def set_active(self, active):
18481843
super().set_active(active)
18491844
if active:
@@ -2266,8 +2261,7 @@ def on_select(min: float, max: float) -> Any
22662261
See also: :doc:`/gallery/widgets/span_selector`
22672262
"""
22682263

2269-
@_api.rename_parameter("3.5", "rectprops", "props")
2270-
@_api.rename_parameter("3.5", "span_stays", "interactive")
2264+
@_api.make_keyword_only("3.7", name="minspan")
22712265
def __init__(self, ax, onselect, direction, minspan=0, useblit=False,
22722266
props=None, onmove_callback=None, interactive=False,
22732267
button=None, handle_props=None, grab_range=10,
@@ -2323,24 +2317,6 @@ def __init__(self, ax, onselect, direction, minspan=0, useblit=False,
23232317
# prev attribute is deprecated but we still need to maintain it
23242318
self._prev = (0, 0)
23252319

2326-
rect = _api.deprecated("3.5")(
2327-
property(lambda self: self._selection_artist)
2328-
)
2329-
2330-
rectprops = _api.deprecated("3.5")(
2331-
property(lambda self: self._props)
2332-
)
2333-
2334-
active_handle = _api.deprecate_privatize_attribute("3.5")
2335-
2336-
pressv = _api.deprecate_privatize_attribute("3.5")
2337-
2338-
span_stays = _api.deprecated("3.5")(
2339-
property(lambda self: self._interactive)
2340-
)
2341-
2342-
prev = _api.deprecate_privatize_attribute("3.5")
2343-
23442320
def new_axes(self, ax):
23452321
"""Set SpanSelector to operate on a new Axes."""
23462322
self.ax = ax
@@ -2916,11 +2892,7 @@ class RectangleSelector(_SelectorWidget):
29162892
See also: :doc:`/gallery/widgets/rectangle_selector`
29172893
"""
29182894

2919-
@_api.rename_parameter("3.5", "maxdist", "grab_range")
2920-
@_api.rename_parameter("3.5", "marker_props", "handle_props")
2921-
@_api.rename_parameter("3.5", "rectprops", "props")
2922-
@_api.delete_parameter("3.5", "drawtype")
2923-
@_api.delete_parameter("3.5", "lineprops")
2895+
@_api.make_keyword_only("3.7", name="drawtype")
29242896
def __init__(self, ax, onselect, drawtype='box',
29252897
minspanx=0, minspany=0, useblit=False,
29262898
lineprops=None, props=None, spancoords='data',
@@ -2943,36 +2915,15 @@ def __init__(self, ax, onselect, drawtype='box',
29432915
# interactive bounding box to allow the polygon to be easily resized
29442916
self._allow_creation = True
29452917

2946-
if drawtype == 'none': # draw a line but make it invisible
2947-
_api.warn_deprecated(
2948-
"3.5", message="Support for drawtype='none' is deprecated "
2949-
"since %(since)s and will be removed "
2950-
"%(removal)s."
2951-
"Use props=dict(visible=False) instead.")
2952-
drawtype = 'line'
2953-
self._visible = False
2954-
2955-
if drawtype == 'box':
2956-
if props is None:
2957-
props = dict(facecolor='red', edgecolor='black',
2958-
alpha=0.2, fill=True)
2959-
props['animated'] = self.useblit
2960-
self._visible = props.pop('visible', self._visible)
2961-
self._props = props
2962-
to_draw = self._init_shape(**self._props)
2963-
self.ax.add_patch(to_draw)
2964-
if drawtype == 'line':
2965-
_api.warn_deprecated(
2966-
"3.5", message="Support for drawtype='line' is deprecated "
2967-
"since %(since)s and will be removed "
2968-
"%(removal)s.")
2969-
if lineprops is None:
2970-
lineprops = dict(color='black', linestyle='-',
2971-
linewidth=2, alpha=0.5)
2972-
lineprops['animated'] = self.useblit
2973-
self._props = lineprops
2974-
to_draw = Line2D([0, 0], [0, 0], visible=False, **self._props)
2975-
self.ax.add_line(to_draw)
2918+
_api.check_in_list(['box'], drawtype=drawtype)
2919+
if props is None:
2920+
props = dict(facecolor='red', edgecolor='black',
2921+
alpha=0.2, fill=True)
2922+
props['animated'] = self.useblit
2923+
self._visible = props.pop('visible', self._visible)
2924+
self._props = props
2925+
to_draw = self._init_shape(**self._props)
2926+
self.ax.add_patch(to_draw)
29762927

29772928
self._selection_artist = to_draw
29782929
self._set_aspect_ratio_correction()
@@ -3013,20 +2964,6 @@ def __init__(self, ax, onselect, drawtype='box',
30132964

30142965
self._extents_on_press = None
30152966

3016-
to_draw = _api.deprecated("3.5")(
3017-
property(lambda self: self._selection_artist)
3018-
)
3019-
3020-
drawtype = _api.deprecate_privatize_attribute("3.5")
3021-
3022-
active_handle = _api.deprecate_privatize_attribute("3.5")
3023-
3024-
interactive = _api.deprecate_privatize_attribute("3.5")
3025-
3026-
maxdist = _api.deprecated("3.5", name="maxdist", alternative="grab_range")(
3027-
property(lambda self: self.grab_range,
3028-
lambda self, value: setattr(self, "grab_range", value)))
3029-
30302967
@property
30312968
def _handles_artists(self):
30322969
return (*self._center_handle.artists, *self._corner_handles.artists,
@@ -3368,8 +3305,6 @@ def rotation(self, value):
33683305
# call extents setter to draw shape and update handles positions
33693306
self.extents = self.extents
33703307

3371-
draw_shape = _api.deprecate_privatize_attribute('3.5')
3372-
33733308
def _draw_shape(self, extents):
33743309
x0, x1, y0, y1 = extents
33753310
xmin, xmax = sorted([x0, x1])
@@ -3458,9 +3393,6 @@ class EllipseSelector(RectangleSelector):
34583393
--------
34593394
:doc:`/gallery/widgets/rectangle_selector`
34603395
"""
3461-
3462-
draw_shape = _api.deprecate_privatize_attribute('3.5')
3463-
34643396
def _init_shape(self, **props):
34653397
return Ellipse((0, 0), 0, 1, visible=False, **props)
34663398

@@ -3538,7 +3470,7 @@ def onselect(verts):
35383470
which corresponds to all buttons.
35393471
"""
35403472

3541-
@_api.rename_parameter("3.5", "lineprops", "props")
3473+
@_api.make_keyword_only("3.7", name="useblit")
35423474
def __init__(self, ax, onselect=None, useblit=True, props=None,
35433475
button=None):
35443476
super().__init__(ax, onselect, useblit=useblit, button=button)
@@ -3551,18 +3483,10 @@ def __init__(self, ax, onselect=None, useblit=True, props=None,
35513483
self.ax.add_line(line)
35523484
self._selection_artist = line
35533485

3554-
@_api.deprecated("3.5", alternative="press")
3555-
def onpress(self, event):
3556-
self.press(event)
3557-
35583486
def _press(self, event):
35593487
self.verts = [self._get_data(event)]
35603488
self._selection_artist.set_visible(True)
35613489

3562-
@_api.deprecated("3.5", alternative="release")
3563-
def onrelease(self, event):
3564-
self.release(event)
3565-
35663490
def _release(self, event):
35673491
if self.verts is not None:
35683492
self.verts.append(self._get_data(event))
@@ -3657,9 +3581,7 @@ class PolygonSelector(_SelectorWidget):
36573581
point.
36583582
"""
36593583

3660-
@_api.rename_parameter("3.5", "lineprops", "props")
3661-
@_api.rename_parameter("3.5", "markerprops", "handle_props")
3662-
@_api.rename_parameter("3.5", "vertex_select_radius", "grab_range")
3584+
@_api.make_keyword_only("3.7", name="useblit")
36633585
def __init__(self, ax, onselect, useblit=False,
36643586
props=None, handle_props=None, grab_range=10, *,
36653587
draw_bounding_box=False, box_handle_props=None,
@@ -3767,16 +3689,6 @@ def _scale_polygon(self, event):
37673689
self._draw_polygon()
37683690
self._old_box_extents = self._box.extents
37693691

3770-
line = _api.deprecated("3.5")(
3771-
property(lambda self: self._selection_artist)
3772-
)
3773-
3774-
vertex_select_radius = _api.deprecated("3.5", name="vertex_select_radius",
3775-
alternative="grab_range")(
3776-
property(lambda self: self.grab_range,
3777-
lambda self, value: setattr(self, "grab_range", value))
3778-
)
3779-
37803692
@property
37813693
def _handles_artists(self):
37823694
return self._polygon_handles.artists
@@ -3968,15 +3880,16 @@ class Lasso(AxesWidget):
39683880
The parent Axes for the widget.
39693881
xy : (float, float)
39703882
Coordinates of the start of the lasso.
3883+
callback : callable
3884+
Whenever the lasso is released, the *callback* function is called and
3885+
passed the vertices of the selected path.
39713886
useblit : bool, default: True
39723887
Whether to use blitting for faster drawing (if supported by the
39733888
backend). See the tutorial :doc:`/tutorials/advanced/blitting`
39743889
for details.
3975-
callback : callable
3976-
Whenever the lasso is released, the *callback* function is called and
3977-
passed the vertices of the selected path.
39783890
"""
39793891

3892+
@_api.make_keyword_only("3.7", name="useblit")
39803893
def __init__(self, ax, xy, callback=None, useblit=True):
39813894
super().__init__(ax)
39823895

0 commit comments

Comments
 (0)