Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit cefb6fd

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

File tree

2 files changed

+19
-108
lines changed

2 files changed

+19
-108
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 & 104 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,9 +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")
18451842
state_modifier_keys = _api.deprecate_privatize_attribute("3.6")
18461843

18471844
def set_active(self, active):
@@ -2266,8 +2263,7 @@ def on_select(min: float, max: float) -> Any
22662263
See also: :doc:`/gallery/widgets/span_selector`
22672264
"""
22682265

2269-
@_api.rename_parameter("3.5", "rectprops", "props")
2270-
@_api.rename_parameter("3.5", "span_stays", "interactive")
2266+
@_api.make_keyword_only("3.7", name="minspan")
22712267
def __init__(self, ax, onselect, direction, minspan=0, useblit=False,
22722268
props=None, onmove_callback=None, interactive=False,
22732269
button=None, handle_props=None, grab_range=10,
@@ -2323,24 +2319,6 @@ def __init__(self, ax, onselect, direction, minspan=0, useblit=False,
23232319
# prev attribute is deprecated but we still need to maintain it
23242320
self._prev = (0, 0)
23252321

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-
23442322
def new_axes(self, ax):
23452323
"""Set SpanSelector to operate on a new Axes."""
23462324
self.ax = ax
@@ -2916,11 +2894,7 @@ class RectangleSelector(_SelectorWidget):
29162894
See also: :doc:`/gallery/widgets/rectangle_selector`
29172895
"""
29182896

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")
2897+
@_api.make_keyword_only("3.7", name="drawtype")
29242898
def __init__(self, ax, onselect, drawtype='box',
29252899
minspanx=0, minspany=0, useblit=False,
29262900
lineprops=None, props=None, spancoords='data',
@@ -2943,36 +2917,15 @@ def __init__(self, ax, onselect, drawtype='box',
29432917
# interactive bounding box to allow the polygon to be easily resized
29442918
self._allow_creation = True
29452919

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)
2920+
_api.check_in_list(['box'], drawtype=drawtype)
2921+
if props is None:
2922+
props = dict(facecolor='red', edgecolor='black',
2923+
alpha=0.2, fill=True)
2924+
props['animated'] = self.useblit
2925+
self._visible = props.pop('visible', self._visible)
2926+
self._props = props
2927+
to_draw = self._init_shape(**self._props)
2928+
self.ax.add_patch(to_draw)
29762929

29772930
self._selection_artist = to_draw
29782931
self._set_aspect_ratio_correction()
@@ -3013,20 +2966,6 @@ def __init__(self, ax, onselect, drawtype='box',
30132966

30142967
self._extents_on_press = None
30152968

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-
30302969
@property
30312970
def _handles_artists(self):
30322971
return (*self._center_handle.artists, *self._corner_handles.artists,
@@ -3368,8 +3307,6 @@ def rotation(self, value):
33683307
# call extents setter to draw shape and update handles positions
33693308
self.extents = self.extents
33703309

3371-
draw_shape = _api.deprecate_privatize_attribute('3.5')
3372-
33733310
def _draw_shape(self, extents):
33743311
x0, x1, y0, y1 = extents
33753312
xmin, xmax = sorted([x0, x1])
@@ -3458,9 +3395,6 @@ class EllipseSelector(RectangleSelector):
34583395
--------
34593396
:doc:`/gallery/widgets/rectangle_selector`
34603397
"""
3461-
3462-
draw_shape = _api.deprecate_privatize_attribute('3.5')
3463-
34643398
def _init_shape(self, **props):
34653399
return Ellipse((0, 0), 0, 1, visible=False, **props)
34663400

@@ -3538,7 +3472,7 @@ def onselect(verts):
35383472
which corresponds to all buttons.
35393473
"""
35403474

3541-
@_api.rename_parameter("3.5", "lineprops", "props")
3475+
@_api.make_keyword_only("3.7", name="useblit")
35423476
def __init__(self, ax, onselect=None, useblit=True, props=None,
35433477
button=None):
35443478
super().__init__(ax, onselect, useblit=useblit, button=button)
@@ -3551,18 +3485,10 @@ def __init__(self, ax, onselect=None, useblit=True, props=None,
35513485
self.ax.add_line(line)
35523486
self._selection_artist = line
35533487

3554-
@_api.deprecated("3.5", alternative="press")
3555-
def onpress(self, event):
3556-
self.press(event)
3557-
35583488
def _press(self, event):
35593489
self.verts = [self._get_data(event)]
35603490
self._selection_artist.set_visible(True)
35613491

3562-
@_api.deprecated("3.5", alternative="release")
3563-
def onrelease(self, event):
3564-
self.release(event)
3565-
35663492
def _release(self, event):
35673493
if self.verts is not None:
35683494
self.verts.append(self._get_data(event))
@@ -3657,9 +3583,7 @@ class PolygonSelector(_SelectorWidget):
36573583
point.
36583584
"""
36593585

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")
3586+
@_api.make_keyword_only("3.7", name="useblit")
36633587
def __init__(self, ax, onselect, useblit=False,
36643588
props=None, handle_props=None, grab_range=10, *,
36653589
draw_bounding_box=False, box_handle_props=None,
@@ -3767,16 +3691,6 @@ def _scale_polygon(self, event):
37673691
self._draw_polygon()
37683692
self._old_box_extents = self._box.extents
37693693

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-
37803694
@property
37813695
def _handles_artists(self):
37823696
return self._polygon_handles.artists
@@ -3968,15 +3882,16 @@ class Lasso(AxesWidget):
39683882
The parent Axes for the widget.
39693883
xy : (float, float)
39703884
Coordinates of the start of the lasso.
3885+
callback : callable
3886+
Whenever the lasso is released, the *callback* function is called and
3887+
passed the vertices of the selected path.
39713888
useblit : bool, default: True
39723889
Whether to use blitting for faster drawing (if supported by the
39733890
backend). See the tutorial :doc:`/tutorials/advanced/blitting`
39743891
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.
39783892
"""
39793893

3894+
@_api.make_keyword_only("3.7", name="useblit")
39803895
def __init__(self, ax, xy, callback=None, useblit=True):
39813896
super().__init__(ax)
39823897

0 commit comments

Comments
 (0)