Skip to content

Commit 37f26da

Browse files
authored
Merge pull request #26853 from oscargus/widgetdeprecationremovals
Widgets: Remove deprecations and make arguments keyword only
2 parents ff552f4 + 705568a commit 37f26da

File tree

6 files changed

+54
-215
lines changed

6 files changed

+54
-215
lines changed

ci/mypy-stubtest-allowlist.txt

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,6 @@ matplotlib.cm.register_cmap
5454
matplotlib.cm.unregister_cmap
5555
matplotlib.collections.PolyCollection.span_where
5656
matplotlib.gridspec.GridSpecBase.get_grid_positions
57-
matplotlib.widgets.MultiCursor.needclear
5857

5958
# 3.8 deprecations
6059
matplotlib.cbook.get_sample_data
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
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 now keyword-only. In general, all optional arguments are keyword-only.
6+
7+
``RadioButtons.circles``
8+
~~~~~~~~~~~~~~~~~~~~~~~~
9+
10+
... is removed. (``RadioButtons`` now draws itself using `~.Axes.scatter`.)
11+
12+
``CheckButtons.rectangles`` and ``CheckButtons.lines``
13+
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
14+
15+
``CheckButtons.rectangles`` and ``CheckButtons.lines`` are removed.
16+
(``CheckButtons`` now draws itself using `~.Axes.scatter`.)
17+
18+
Remove unused parameter *x* to ``TextBox.begin_typing``
19+
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
20+
21+
This parameter was unused in the method, but was a required argument.
22+
23+
``MultiCursor.needclear``
24+
~~~~~~~~~~~~~~~~~~~~~~~~~
25+
26+
... is removed.

lib/matplotlib/tests/test_widgets.py

Lines changed: 0 additions & 59 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,6 @@
77
import matplotlib.colors as mcolors
88
import matplotlib.widgets as widgets
99
import matplotlib.pyplot as plt
10-
from matplotlib.patches import Rectangle
11-
from matplotlib.lines import Line2D
1210
from matplotlib.testing.decorators import check_figures_equal, image_comparison
1311
from matplotlib.testing.widgets import (click_and_drag, do_event, get_ax,
1412
mock_event, noop)
@@ -1055,16 +1053,10 @@ def test_check_radio_buttons_image():
10551053

10561054
rax1 = fig.add_axes((0.05, 0.7, 0.2, 0.15))
10571055
rb1 = widgets.RadioButtons(rax1, ('Radio 1', 'Radio 2', 'Radio 3'))
1058-
with pytest.warns(DeprecationWarning,
1059-
match='The circles attribute was deprecated'):
1060-
rb1.circles # Trigger the old-style elliptic radiobuttons.
10611056

10621057
rax2 = fig.add_axes((0.05, 0.5, 0.2, 0.15))
10631058
cb1 = widgets.CheckButtons(rax2, ('Check 1', 'Check 2', 'Check 3'),
10641059
(False, True, True))
1065-
with pytest.warns(DeprecationWarning,
1066-
match='The rectangles attribute was deprecated'):
1067-
cb1.rectangles # Trigger old-style Rectangle check boxes
10681060

10691061
rax3 = fig.add_axes((0.05, 0.3, 0.2, 0.15))
10701062
rb3 = widgets.RadioButtons(
@@ -1164,57 +1156,6 @@ def test_check_button_props(fig_test, fig_ref):
11641156
cb.set_check_props({**check_props, 's': (24 / 2)**2})
11651157

11661158

1167-
@check_figures_equal(extensions=["png"])
1168-
def test_check_buttons_rectangles(fig_test, fig_ref):
1169-
# Test should be removed once .rectangles is removed
1170-
cb = widgets.CheckButtons(fig_test.subplots(), ["", ""],
1171-
[False, False])
1172-
with pytest.warns(DeprecationWarning,
1173-
match='The rectangles attribute was deprecated'):
1174-
cb.rectangles
1175-
ax = fig_ref.add_subplot(xticks=[], yticks=[])
1176-
ys = [2/3, 1/3]
1177-
dy = 1/3
1178-
w, h = dy / 2, dy / 2
1179-
rectangles = [
1180-
Rectangle(xy=(0.05, ys[i] - h / 2), width=w, height=h,
1181-
edgecolor="black",
1182-
facecolor="none",
1183-
transform=ax.transAxes
1184-
)
1185-
for i, y in enumerate(ys)
1186-
]
1187-
for rectangle in rectangles:
1188-
ax.add_patch(rectangle)
1189-
1190-
1191-
@check_figures_equal(extensions=["png"])
1192-
def test_check_buttons_lines(fig_test, fig_ref):
1193-
# Test should be removed once .lines is removed
1194-
cb = widgets.CheckButtons(fig_test.subplots(), ["", ""], [True, True])
1195-
with pytest.warns(DeprecationWarning,
1196-
match='The lines attribute was deprecated'):
1197-
cb.lines
1198-
for rectangle in cb._rectangles:
1199-
rectangle.set_visible(False)
1200-
ax = fig_ref.add_subplot(xticks=[], yticks=[])
1201-
ys = [2/3, 1/3]
1202-
dy = 1/3
1203-
w, h = dy / 2, dy / 2
1204-
lineparams = {'color': 'k', 'linewidth': 1.25,
1205-
'transform': ax.transAxes,
1206-
'solid_capstyle': 'butt'}
1207-
for i, y in enumerate(ys):
1208-
x, y = 0.05, y - h / 2
1209-
l1 = Line2D([x, x + w], [y + h, y], **lineparams)
1210-
l2 = Line2D([x, x + w], [y, y + h], **lineparams)
1211-
1212-
l1.set_visible(True)
1213-
l2.set_visible(True)
1214-
ax.add_line(l1)
1215-
ax.add_line(l2)
1216-
1217-
12181159
def test_slider_slidermin_slidermax_invalid():
12191160
fig, ax = plt.subplots()
12201161
# test min/max with floats

0 commit comments

Comments
 (0)