Skip to content

Expire remaining 3.6 deprecations #25584

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 7 commits into from
Apr 19, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 1 addition & 5 deletions ci/mypy-stubtest-allowlist.txt
Original file line number Diff line number Diff line change
Expand Up @@ -84,13 +84,10 @@ matplotlib.transforms.TransformWrapper.input_dims
matplotlib.transforms.TransformWrapper.is_separable
matplotlib.transforms.TransformWrapper.output_dims

# 3.6 deprecations
matplotlib.colorbar.Colorbar.__init__
matplotlib.figure.Figure.callbacks
# 3.6 Pending deprecations
matplotlib.figure.Figure.set_constrained_layout
matplotlib.figure.Figure.set_constrained_layout_pads
matplotlib.figure.Figure.set_tight_layout
matplotlib.figure.SubFigure.callbacks

# 3.7 deprecations
matplotlib.cm.register_cmap
Expand All @@ -103,7 +100,6 @@ matplotlib.widgets.Slider.__init__
matplotlib.widgets.RangeSlider.__init__
matplotlib.widgets.TextBox.__init__
matplotlib.widgets.Cursor.__init__
matplotlib.widgets.MultiCursor.__init__
matplotlib.widgets.SpanSelector.__init__
matplotlib.widgets.ToolLineHandles.__init__
matplotlib.widgets.ToolHandles.__init__
Expand Down
5 changes: 5 additions & 0 deletions doc/api/next_api_changes/deprecations/25584-KS.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
Widgets
~~~~~~~

The *visible* attribute getter of Selector widgets has been deprecated;
use ``get_visible``
24 changes: 24 additions & 0 deletions doc/api/next_api_changes/removals/25584-KS.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
``Figure.callbacks`` is removed
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

The Figure ``callbacks`` property has been removed. The only signal was
"dpi_changed", which can be replaced by connecting to the "resize_event" on the
canvas ``figure.canvas.mpl_connect("resize_event", func)`` instead.



Passing too many positional arguments to ``tripcolor``
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
... raises ``TypeError`` (extra arguments were previously ignored).


The *filled* argument to ``Colorbar`` is removed
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
This behavior was already governed by the underlying ``ScalarMappable``.


Widgets
~~~~~~~

The *visible* attribute setter of Selector widgets has been removed; use ``set_visible``
The associated getter is also deprecated, but not yet expired.
5 changes: 1 addition & 4 deletions lib/matplotlib/colorbar.py
Original file line number Diff line number Diff line change
Expand Up @@ -260,8 +260,6 @@ class Colorbar:
drawedges : bool
Whether to draw lines at color boundaries.

filled : bool

%(_colormap_kw_doc)s

location : None or {'left', 'right', 'top', 'bottom'}
Expand All @@ -278,7 +276,6 @@ class Colorbar:

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

@_api.delete_parameter("3.6", "filled")
def __init__(self, ax, mappable=None, *, cmap=None,
norm=None,
alpha=None,
Expand All @@ -291,7 +288,6 @@ def __init__(self, ax, mappable=None, *, cmap=None,
ticks=None,
format=None,
drawedges=False,
filled=True,
extendfrac=None,
extendrect=False,
label='',
Expand All @@ -305,6 +301,7 @@ def __init__(self, ax, mappable=None, *, cmap=None,
cmap = mappable.cmap
norm = mappable.norm

filled = True
if isinstance(mappable, contour.ContourSet):
cs = mappable
alpha = cs.get_alpha()
Expand Down
1 change: 0 additions & 1 deletion lib/matplotlib/colorbar.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,6 @@ class Colorbar:
ticks: Sequence[float] | Locator | None = ...,
format: str | Formatter | None = ...,
drawedges: bool = ...,
filled: bool = ...,
extendfrac: Literal["auto"] | float | Sequence[float] | None = ...,
extendrect: bool = ...,
label: str = ...,
Expand Down
13 changes: 0 additions & 13 deletions lib/matplotlib/figure.py
Original file line number Diff line number Diff line change
Expand Up @@ -2142,10 +2142,6 @@ class SubFigure(FigureBase):

See :doc:`/gallery/subplots_axes_and_figures/subfigures`
"""
callbacks = _api.deprecated(
"3.6", alternative=("the 'resize_event' signal in "
"Figure.canvas.callbacks")
)(property(lambda self: self._fig_callbacks))

def __init__(self, parent, subplotspec, *,
facecolor=None,
Expand Down Expand Up @@ -2194,7 +2190,6 @@ def __init__(self, parent, subplotspec, *,
self._subplotspec = subplotspec
self._parent = parent
self.figure = parent.figure
self._fig_callbacks = parent._fig_callbacks

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

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

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

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

Expand Down
5 changes: 2 additions & 3 deletions lib/matplotlib/tests/test_triangulation.py
Original file line number Diff line number Diff line change
Expand Up @@ -280,6 +280,8 @@ def test_tripcolor_color():
with pytest.raises(TypeError,
match="positional.*'c'.*keyword-only.*'facecolors'"):
ax.tripcolor(x, y, C=[1, 2, 3, 4])
with pytest.raises(TypeError, match="Unexpected positional parameter"):
ax.tripcolor(x, y, [1, 2], 'unused_positional')

# smoke test for valid color specifications (via C or facecolors)
ax.tripcolor(x, y, [1, 2, 3, 4]) # edges
Expand All @@ -303,9 +305,6 @@ def test_tripcolor_warnings():
y = [0, -1, 0, 1]
c = [0.4, 0.5]
fig, ax = plt.subplots()
# additional parameters
with pytest.warns(DeprecationWarning, match="Additional positional param"):
ax.tripcolor(x, y, c, 'unused_positional')
# facecolors takes precedence over c
with pytest.warns(UserWarning, match="Positional parameter c .*no effect"):
ax.tripcolor(x, y, c, facecolors=c)
Expand Down
5 changes: 2 additions & 3 deletions lib/matplotlib/tests/test_widgets.py
Original file line number Diff line number Diff line change
Expand Up @@ -138,9 +138,8 @@ def test_deprecation_selector_visible_attribute(ax):
assert tool.get_visible()

with pytest.warns(mpl.MatplotlibDeprecationWarning,
match="was deprecated in Matplotlib 3.6"):
tool.visible = False
assert not tool.get_visible()
match="was deprecated in Matplotlib 3.8"):
tool.visible


@pytest.mark.parametrize('drag_from_anywhere, new_center',
Expand Down
5 changes: 1 addition & 4 deletions lib/matplotlib/tri/_tripcolor.py
Original file line number Diff line number Diff line change
Expand Up @@ -80,10 +80,7 @@ def tripcolor(ax, *args, alpha=1.0, norm=None, cmap=None, vmin=None,
"tripcolor() missing 1 required positional argument: 'c'; or "
"1 required keyword-only argument: 'facecolors'")
elif len(args) > 1:
_api.warn_deprecated(
"3.6", message=f"Additional positional parameters "
f"{args[1:]!r} are ignored; support for them is deprecated "
f"since %(since)s and will be removed %(removal)s")
raise TypeError(f"Unexpected positional parameters: {args[1:]!r}")
c = np.asarray(args[0])
if len(c) == len(tri.x):
# having this before the len(tri.triangles) comparison gives
Expand Down
6 changes: 1 addition & 5 deletions lib/matplotlib/widgets.py
Original file line number Diff line number Diff line change
Expand Up @@ -2429,13 +2429,9 @@ def get_visible(self):

@property
def visible(self):
_api.warn_deprecated("3.8", alternative="get_visible")
return self.get_visible()

@visible.setter
def visible(self, visible):
_api.warn_deprecated("3.6", alternative="set_visible")
self.set_visible(visible)

def clear(self):
"""Clear the selection and set the selector ready to make a new one."""
self._clear_without_update()
Expand Down
3 changes: 1 addition & 2 deletions lib/matplotlib/widgets.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -259,6 +259,7 @@ class MultiCursor(Widget):
self,
canvas: Any,
axes: Sequence[Axes],
*,
useblit: bool = ...,
horizOn: bool = ...,
vertOn: bool = ...,
Expand Down Expand Up @@ -297,8 +298,6 @@ class _SelectorWidget(AxesWidget):
def get_visible(self) -> bool: ...
@property
def visible(self) -> bool: ...
@visible.setter
def visible(self, visible: bool) -> None: ...
def clear(self) -> None: ...
@property
def artists(self) -> tuple[Artist]: ...
Expand Down