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

Skip to content

Commit 4f5b574

Browse files
authored
Merge pull request #25584 from ksunden/expire_deps_36
Expire remaining 3.6 deprecations
2 parents 5937318 + 0a48bb6 commit 4f5b574

File tree

11 files changed

+38
-40
lines changed

11 files changed

+38
-40
lines changed

ci/mypy-stubtest-allowlist.txt

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -84,13 +84,10 @@ matplotlib.transforms.TransformWrapper.input_dims
8484
matplotlib.transforms.TransformWrapper.is_separable
8585
matplotlib.transforms.TransformWrapper.output_dims
8686

87-
# 3.6 deprecations
88-
matplotlib.colorbar.Colorbar.__init__
89-
matplotlib.figure.Figure.callbacks
87+
# 3.6 Pending deprecations
9088
matplotlib.figure.Figure.set_constrained_layout
9189
matplotlib.figure.Figure.set_constrained_layout_pads
9290
matplotlib.figure.Figure.set_tight_layout
93-
matplotlib.figure.SubFigure.callbacks
9491

9592
# 3.7 deprecations
9693
matplotlib.cm.register_cmap
@@ -103,7 +100,6 @@ matplotlib.widgets.Slider.__init__
103100
matplotlib.widgets.RangeSlider.__init__
104101
matplotlib.widgets.TextBox.__init__
105102
matplotlib.widgets.Cursor.__init__
106-
matplotlib.widgets.MultiCursor.__init__
107103
matplotlib.widgets.SpanSelector.__init__
108104
matplotlib.widgets.ToolLineHandles.__init__
109105
matplotlib.widgets.ToolHandles.__init__
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
Widgets
2+
~~~~~~~
3+
4+
The *visible* attribute getter of Selector widgets has been deprecated;
5+
use ``get_visible``
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
``Figure.callbacks`` is removed
2+
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
3+
4+
The Figure ``callbacks`` property has been removed. The only signal was
5+
"dpi_changed", which can be replaced by connecting to the "resize_event" on the
6+
canvas ``figure.canvas.mpl_connect("resize_event", func)`` instead.
7+
8+
9+
10+
Passing too many positional arguments to ``tripcolor``
11+
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
12+
... raises ``TypeError`` (extra arguments were previously ignored).
13+
14+
15+
The *filled* argument to ``Colorbar`` is removed
16+
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
17+
This behavior was already governed by the underlying ``ScalarMappable``.
18+
19+
20+
Widgets
21+
~~~~~~~
22+
23+
The *visible* attribute setter of Selector widgets has been removed; use ``set_visible``
24+
The associated getter is also deprecated, but not yet expired.

lib/matplotlib/colorbar.py

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -260,8 +260,6 @@ class Colorbar:
260260
drawedges : bool
261261
Whether to draw lines at color boundaries.
262262
263-
filled : bool
264-
265263
%(_colormap_kw_doc)s
266264
267265
location : None or {'left', 'right', 'top', 'bottom'}
@@ -278,7 +276,6 @@ class Colorbar:
278276

279277
n_rasterize = 50 # rasterize solids if number of colors >= n_rasterize
280278

281-
@_api.delete_parameter("3.6", "filled")
282279
def __init__(self, ax, mappable=None, *, cmap=None,
283280
norm=None,
284281
alpha=None,
@@ -291,7 +288,6 @@ def __init__(self, ax, mappable=None, *, cmap=None,
291288
ticks=None,
292289
format=None,
293290
drawedges=False,
294-
filled=True,
295291
extendfrac=None,
296292
extendrect=False,
297293
label='',
@@ -305,6 +301,7 @@ def __init__(self, ax, mappable=None, *, cmap=None,
305301
cmap = mappable.cmap
306302
norm = mappable.norm
307303

304+
filled = True
308305
if isinstance(mappable, contour.ContourSet):
309306
cs = mappable
310307
alpha = cs.get_alpha()

lib/matplotlib/colorbar.pyi

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,6 @@ class Colorbar:
5757
ticks: Sequence[float] | Locator | None = ...,
5858
format: str | Formatter | None = ...,
5959
drawedges: bool = ...,
60-
filled: bool = ...,
6160
extendfrac: Literal["auto"] | float | Sequence[float] | None = ...,
6261
extendrect: bool = ...,
6362
label: str = ...,

lib/matplotlib/figure.py

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -2142,10 +2142,6 @@ class SubFigure(FigureBase):
21422142
21432143
See :doc:`/gallery/subplots_axes_and_figures/subfigures`
21442144
"""
2145-
callbacks = _api.deprecated(
2146-
"3.6", alternative=("the 'resize_event' signal in "
2147-
"Figure.canvas.callbacks")
2148-
)(property(lambda self: self._fig_callbacks))
21492145

21502146
def __init__(self, parent, subplotspec, *,
21512147
facecolor=None,
@@ -2194,7 +2190,6 @@ def __init__(self, parent, subplotspec, *,
21942190
self._subplotspec = subplotspec
21952191
self._parent = parent
21962192
self.figure = parent.figure
2197-
self._fig_callbacks = parent._fig_callbacks
21982193

21992194
# subfigures use the parent axstack
22002195
self._axstack = parent._axstack
@@ -2355,12 +2350,6 @@ class Figure(FigureBase):
23552350
depending on the renderer option_image_nocomposite function. If
23562351
*suppressComposite* is a boolean, this will override the renderer.
23572352
"""
2358-
# Remove the self._fig_callbacks properties on figure and subfigure
2359-
# after the deprecation expires.
2360-
callbacks = _api.deprecated(
2361-
"3.6", alternative=("the 'resize_event' signal in "
2362-
"Figure.canvas.callbacks")
2363-
)(property(lambda self: self._fig_callbacks))
23642353

23652354
def __str__(self):
23662355
return "Figure(%gx%g)" % tuple(self.bbox.size)
@@ -2501,7 +2490,6 @@ def __init__(self,
25012490
# everything is None, so use default:
25022491
self.set_layout_engine(layout=layout)
25032492

2504-
self._fig_callbacks = cbook.CallbackRegistry(signals=["dpi_changed"])
25052493
# Callbacks traditionally associated with the canvas (and exposed with
25062494
# a proxy property), but that actually need to be on the figure for
25072495
# pickling.
@@ -2750,7 +2738,6 @@ def _set_dpi(self, dpi, forward=True):
27502738
self.dpi_scale_trans.clear().scale(dpi)
27512739
w, h = self.get_size_inches()
27522740
self.set_size_inches(w, h, forward=forward)
2753-
self._fig_callbacks.process('dpi_changed', self)
27542741

27552742
dpi = property(_get_dpi, _set_dpi, doc="The resolution in dots per inch.")
27562743

lib/matplotlib/tests/test_triangulation.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -280,6 +280,8 @@ def test_tripcolor_color():
280280
with pytest.raises(TypeError,
281281
match="positional.*'c'.*keyword-only.*'facecolors'"):
282282
ax.tripcolor(x, y, C=[1, 2, 3, 4])
283+
with pytest.raises(TypeError, match="Unexpected positional parameter"):
284+
ax.tripcolor(x, y, [1, 2], 'unused_positional')
283285

284286
# smoke test for valid color specifications (via C or facecolors)
285287
ax.tripcolor(x, y, [1, 2, 3, 4]) # edges
@@ -303,9 +305,6 @@ def test_tripcolor_warnings():
303305
y = [0, -1, 0, 1]
304306
c = [0.4, 0.5]
305307
fig, ax = plt.subplots()
306-
# additional parameters
307-
with pytest.warns(DeprecationWarning, match="Additional positional param"):
308-
ax.tripcolor(x, y, c, 'unused_positional')
309308
# facecolors takes precedence over c
310309
with pytest.warns(UserWarning, match="Positional parameter c .*no effect"):
311310
ax.tripcolor(x, y, c, facecolors=c)

lib/matplotlib/tests/test_widgets.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -138,9 +138,8 @@ def test_deprecation_selector_visible_attribute(ax):
138138
assert tool.get_visible()
139139

140140
with pytest.warns(mpl.MatplotlibDeprecationWarning,
141-
match="was deprecated in Matplotlib 3.6"):
142-
tool.visible = False
143-
assert not tool.get_visible()
141+
match="was deprecated in Matplotlib 3.8"):
142+
tool.visible
144143

145144

146145
@pytest.mark.parametrize('drag_from_anywhere, new_center',

lib/matplotlib/tri/_tripcolor.py

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -80,10 +80,7 @@ def tripcolor(ax, *args, alpha=1.0, norm=None, cmap=None, vmin=None,
8080
"tripcolor() missing 1 required positional argument: 'c'; or "
8181
"1 required keyword-only argument: 'facecolors'")
8282
elif len(args) > 1:
83-
_api.warn_deprecated(
84-
"3.6", message=f"Additional positional parameters "
85-
f"{args[1:]!r} are ignored; support for them is deprecated "
86-
f"since %(since)s and will be removed %(removal)s")
83+
raise TypeError(f"Unexpected positional parameters: {args[1:]!r}")
8784
c = np.asarray(args[0])
8885
if len(c) == len(tri.x):
8986
# having this before the len(tri.triangles) comparison gives

lib/matplotlib/widgets.py

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2429,13 +2429,9 @@ def get_visible(self):
24292429

24302430
@property
24312431
def visible(self):
2432+
_api.warn_deprecated("3.8", alternative="get_visible")
24322433
return self.get_visible()
24332434

2434-
@visible.setter
2435-
def visible(self, visible):
2436-
_api.warn_deprecated("3.6", alternative="set_visible")
2437-
self.set_visible(visible)
2438-
24392435
def clear(self):
24402436
"""Clear the selection and set the selector ready to make a new one."""
24412437
self._clear_without_update()

lib/matplotlib/widgets.pyi

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -259,6 +259,7 @@ class MultiCursor(Widget):
259259
self,
260260
canvas: Any,
261261
axes: Sequence[Axes],
262+
*,
262263
useblit: bool = ...,
263264
horizOn: bool = ...,
264265
vertOn: bool = ...,
@@ -297,8 +298,6 @@ class _SelectorWidget(AxesWidget):
297298
def get_visible(self) -> bool: ...
298299
@property
299300
def visible(self) -> bool: ...
300-
@visible.setter
301-
def visible(self, visible: bool) -> None: ...
302301
def clear(self) -> None: ...
303302
@property
304303
def artists(self) -> tuple[Artist]: ...

0 commit comments

Comments
 (0)