Skip to content

Commit aa426be

Browse files
authored
Expire deprecations in widgets and keyword only arguments for Selectors (#24254)
* Expire deprecations in widgets and keyword only arguments for Selectors
1 parent 6e9a8c4 commit aa426be

File tree

4 files changed

+119
-168
lines changed

4 files changed

+119
-168
lines changed
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
Most arguments to widgets have been made keyword-only
2+
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
3+
4+
Passing all but the very few first arguments positionally in the constructors
5+
of Widgets is deprecated. Most arguments will become keyword-only in a future
6+
version.
Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
Removal of deprecations in the Selector widget API
2+
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
3+
4+
RectangleSelector and EllipseSelector
5+
.....................................
6+
7+
The *drawtype* keyword argument to `~matplotlib.widgets.RectangleSelector` is
8+
removed. From now on, the only behaviour will be ``drawtype='box'``.
9+
10+
Support for ``drawtype=line`` is removed altogether. As a
11+
result, the *lineprops* keyword argument to
12+
`~matplotlib.widgets.RectangleSelector` is also removed.
13+
14+
To retain the behaviour of ``drawtype='none'``, use ``rectprops={'visible':
15+
False}`` to make the drawn `~matplotlib.patches.Rectangle` invisible.
16+
17+
Cleaned up attributes and arguments are:
18+
19+
- The ``active_handle`` attribute has been privatized and removed.
20+
- The ``drawtype`` attribute has been privatized and removed.
21+
- The ``eventpress`` attribute has been privatized and removed.
22+
- The ``eventrelease`` attribute has been privatized and removed.
23+
- The ``interactive`` attribute has been privatized and removed.
24+
- The *marker_props* argument is removed, use *handle_props* instead.
25+
- The *maxdist* argument is removed, use *grab_range* instead.
26+
- The *rectprops* argument is removed, use *props* instead.
27+
- The ``rectprops`` attribute has been privatized and removed.
28+
- The ``state`` attribute has been privatized and removed.
29+
- The ``to_draw`` attribute has been privatized and removed.
30+
31+
PolygonSelector
32+
...............
33+
34+
- The *line* attribute is removed. If you want to change the selector artist
35+
properties, use the ``set_props`` or ``set_handle_props`` methods.
36+
- The *lineprops* argument is removed, use *props* instead.
37+
- The *markerprops* argument is removed, use *handle_props* instead.
38+
- The *maxdist* argument and attribute is removed, use *grab_range* instead.
39+
- The *vertex_select_radius* argument and attribute is removed, use
40+
*grab_range* instead.
41+
42+
SpanSelector
43+
............
44+
45+
- The ``active_handle`` attribute has been privatized and removed.
46+
- The ``eventpress`` attribute has been privatized and removed.
47+
- The ``eventrelease`` attribute has been privatized and removed.
48+
- The ``pressv`` attribute has been privatized and removed.
49+
- The ``prev`` attribute has been privatized and removed.
50+
- The ``rect`` attribute has been privatized and removed.
51+
- The *rectprops* parameter has been renamed to *props*.
52+
- The ``rectprops`` attribute has been privatized and removed.
53+
- The *span_stays* parameter has been renamed to *interactive*.
54+
- The ``span_stays`` attribute has been privatized and removed.
55+
- The ``state`` attribute has been privatized and removed.
56+
57+
LassoSelector
58+
.............
59+
60+
- The *lineprops* argument is removed, use *props* instead.
61+
- The ``onpress`` and ``onrelease`` methods are removed. They are straight
62+
aliases for ``press`` and ``release``.
63+
- The ``matplotlib.widgets.TextBox.DIST_FROM_LEFT`` attribute has been
64+
removed. It was marked as private in 3.5.

lib/matplotlib/tests/test_widgets.py

Lines changed: 7 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
from contextlib import nullcontext
21
import functools
32
from unittest import mock
43

@@ -24,22 +23,16 @@ def ax():
2423
return get_ax()
2524

2625

27-
@pytest.mark.parametrize('kwargs, warning_msg', [
28-
(dict(), None),
29-
(dict(drawtype='line', useblit=False),
30-
"Support for drawtype='line' is deprecated"),
31-
(dict(useblit=True, button=1), None),
32-
(dict(drawtype='none', minspanx=10, minspany=10),
33-
"Support for drawtype='none' is deprecated"),
34-
(dict(minspanx=10, minspany=10, spancoords='pixels'), None),
35-
(dict(props=dict(fill=True)), None),
26+
@pytest.mark.parametrize('kwargs', [
27+
dict(),
28+
dict(useblit=True, button=1),
29+
dict(minspanx=10, minspany=10, spancoords='pixels'),
30+
dict(props=dict(fill=True)),
3631
])
37-
def test_rectangle_selector(ax, kwargs, warning_msg):
32+
def test_rectangle_selector(ax, kwargs):
3833
onselect = mock.Mock(spec=noop, return_value=None)
3934

40-
with (pytest.warns(MatplotlibDeprecationWarning, match=warning_msg)
41-
if warning_msg else nullcontext()):
42-
tool = widgets.RectangleSelector(ax, onselect, **kwargs)
35+
tool = widgets.RectangleSelector(ax, onselect, **kwargs)
4336
do_event(tool, 'press', xdata=100, ydata=100, button=1)
4437
do_event(tool, 'onmove', xdata=199, ydata=199, button=1)
4538

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy