8000 Expire more mpl3.6 deprecations. by anntzer · Pull Request #25456 · matplotlib/matplotlib · GitHub
[go: up one dir, main page]

Skip to content

Expire more mpl3.6 deprecations. #25456

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 1 commit into from
Mar 22, 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
10 changes: 10 additions & 0 deletions doc/api/next_api_changes/behavior/25456-AL.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
Changes of API after deprecation
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

- `.dviread.find_tex_file` now raises `FileNotFoundError` when the requested filename is
not found.
- `.Figure.colorbar` now raises if *cax* is not given and it is unable to determine from
which Axes to steal space, i.e. if *ax* is also not given and *mappable* has not been
added to an Axes.
- `.pyplot.subplot` and `.pyplot.subplot2grid` no longer auto-remove preexisting
overlapping Axes; explicitly call ``Axes.remove`` as needed.
51 changes: 51 additions & 0 deletions doc/api/next_api_changes/removals/25456-AL.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
Removal of deprecated APIs
~~~~~~~~~~~~~~~~~~~~~~~~~~

The following deprecated APIs have been removed. Unless a replacement is stated, please
vendor the previous implementation if needed.

- The following methods of `.FigureCanvasBase`: ``pick`` (use ``Figure.pick`` instead),
``resize``, ``draw_event``, ``resize_event``, ``close_event``, ``key_press_event``,
``key_release_event``, ``pick_event``, ``scroll_event``, ``button_press_event``,
``button_release_event``, ``motion_notify_event``, ``leave_notify_event``,
``enter_notify_event`` (for all the ``foo_event`` methods, construct the relevant
`.Event` object and call ``canvas.callbacks.process(event.name, event)`` instead).
- ``ToolBase.destroy`` (connect to ``tool_removed_event`` instead).
- The *cleared* parameter to `.FigureCanvasAgg.get_renderer` (call ``renderer.clear()``
instead).
- The following methods of `.RendererCairo`: ``set_ctx_from_surface`` and
``set_width_height`` (use ``set_context`` instead, which automatically infers the
canvas size).
- The ``window`` or ``win`` parameters and/or attributes of ``NavigationToolbar2Tk``,
``NavigationToolbar2GTK3``, and ``NavigationToolbar2GTK4``, and the ``lastrect``
attribute of ``NavigationToolbar2Tk``
- The ``error_msg_gtk`` function and the ``icon_filename`` and ``window_icon`` globals
in ``backend_gtk3``; the ``error_msg_wx`` function in ``backend_wx``.
- ``FigureManagerGTK3Agg`` and ``FigureManagerGTK4Agg`` (use ``FigureManagerGTK3``
instead); ``RendererGTK3Cairo`` and ``RendererGTK4Cairo``.
- ``NavigationToolbar2Mac.prepare_configure_subplots`` (use
`~.NavigationToolbar2.configure_subplots` instead).
- ``FigureManagerMac.close``.
- The ``qApp`` global in `.backend_qt` (use ``QtWidgets.QApplication.instance()``
instead).
- The ``offset_text_height`` method of ``RendererWx``; the ``sizer``, ``figmgr``,
``num``, ``toolbar``, ``toolmanager``, ``get_canvas``, and ``get_figure_manager``
attributes or methods of ``FigureFrameWx`` (use ``frame.GetSizer()``,
``frame.canvas.manager``, ``frame.canvas.manager.num``, ``frame.GetToolBar()``,
``frame.canvas.manager.toolmanager``, the *canvas_class* constructor parameter, and
``frame.canvas.manager``, respectively, instead).
- ``FigureFrameWxAgg`` and ``FigureFrameWxCairo`` (use
``FigureFrameWx(..., canvas_class=FigureCanvasWxAgg)`` and
``FigureFrameWx(..., canvas_class=FigureCanvasWxCairo)``, respectively, instead).
- The ``filled`` attribute and the ``draw_all`` method of `.Colorbar` (instead of
``draw_all``, use ``figure.draw_without_rendering``).
- Calling `.MarkerStyle` without setting the *marker* parameter or setting it to None
(use ``MarkerStyle("")`` instead).
- Support for third-party canvas classes without a ``required_interactive_framework``
attribute (this can only occur if the canvas class does not inherit from
`.FigureCanvasBase`).
- The ``canvas`` and ``background`` attributes of `.MultiCursor`; the
``state_modifier_keys`` attribute of selector widgets.
- Passing *useblit*, *horizOn*, or *vertOn* positionally to `.MultiCursor`.
- Support for the ``seaborn-<foo>`` styles; use ``seaborn-v0_8-<foo>`` instead, or
directly use the seaborn API.
233 changes: 0 additions & 233 deletions lib/matplotlib/backend_bases.py
Original file line number Diff line number Diff line change
Expand Up @@ -1708,7 +1708,6 @@ def __init__(self, figure=None):
self.widgetlock = widgets.LockDraw()
self._button = None # the button pressed
self._key = None # the key pressed
self._lastx, self._lasty = None, None
self.mouse_grabber = None # the Axes currently grabbing mouse
self.toolbar = None # NavigationToolbar2 will set me
self._is_idle_drawing = False
Expand Down Expand Up @@ -1779,241 +1778,9 @@ def is_saving(self):
"""
return self._is_saving

@_api.deprecated("3.6", alternative="canvas.figure.pick")
def pick(self, mouseevent):
if not self.widgetlock.locked():
self.figure.pick(mouseevent)

def blit(self, bbox=None):
"""Blit the canvas in bbox (default entire canvas)."""

def resize(self, w, h):
"""
UNUSED: Set the canvas size in pixels.

Certain backends may implement a similar method internally, but this is
not a requirement of, nor is it used by, Matplotlib itself.
"""
# The entire method is actually deprecated, but we allow pass-through
# to a parent class to support e.g. QWidget.resize.
if hasattr(super(), "resize"):
return super().resize(w, h)
else:
_api.warn_deprecated("3.6", name="resize", obj_type="method",
alternative="FigureManagerBase.resize")

@_api.deprecated("3.6", alternative=(
"callbacks.process('draw_event', DrawEvent(...))"))
def draw_event(self, renderer):
"""Pass a `DrawEvent` to all functions connected to ``draw_event``."""
s = 'draw_event'
event = DrawEvent(s, self, renderer)
self.callbacks.process(s, event)

@_api.deprecated("3.6", alternative=(
"callbacks.process('resize_event', ResizeEvent(...))"))
def resize_event(self):
"""
Pass a `ResizeEvent` to all functions connected to ``resize_event``.
"""
s = 'resize_event'
event = ResizeEvent(s, self)
self.callbacks.process(s, event)
self.draw_idle()

@_api.deprecated("3.6", alternative=(
"callbacks.process('close_event', CloseEvent(...))"))
def close_event(self, guiEvent=None):
"""
Pass a `CloseEvent` to all functions connected to ``close_event``.
"""
s = 'close_event'
try:
event = CloseEvent(s, self, guiEvent=guiEvent)
self.callbacks.process(s, event)
except (TypeError, AttributeError):
pass
# Suppress the TypeError when the python session is being killed.
# It may be that a better solution would be a mechanism to
# disconnect all callbacks upon shutdown.
# AttributeError occurs on OSX with qt4agg upon exiting
# with an open window; 'callbacks' attribute no longer exists.

@_api.deprecated("3.6", alternative=(
"callbacks.process('key_press_event', KeyEvent(...))"))
def key_press_event(self, key, guiEvent=None):
"""
Pass a `KeyEvent` to all functions connected to ``key_press_event``.
"""
self._key = key
s = 'key_press_event'
event = KeyEvent(
s, self, key, self._lastx, self._lasty, guiEvent=guiEvent)
self.callbacks.process(s, event)

@_api.deprecated("3.6", alternative=(
"callbacks.process('key_release_event', KeyEvent(...))"))
def key_release_event(self, key, guiEvent=None):
"""
Pass a `KeyEvent` to all functions connected to ``key_release_event``.
"""
s = 'key_release_event'
event = KeyEvent(
s, self, key, self._lastx, self._lasty, guiEvent=guiEvent)
self.callbacks.process(s, event)
self._key = None

@_api.deprecated("3.6", alternative=(
"callbacks.process('pick_event', PickEvent(...))"))
def pick_event(self, mouseevent, artist, **kwargs):
"""
Callback processing for pick events.

This method will be called by artists who are picked and will
fire off `PickEvent` callbacks registered listeners.

Note that artists are not pickable by default (see
`.Artist.set_picker`).
"""
s = 'pick_event'
event = PickEvent(s, self, mouseevent, artist,
guiEvent=mouseevent.guiEvent,
**kwargs)
self.callbacks.process(s, event)

@_api.deprecated("3.6", alternative=(
"callbacks.process('scroll_event', MouseEvent(...))"))
def scroll_event(self, x, y, step, guiEvent=None):
"""
Callback processing for scroll events.

Backend derived classes should call this function on any
scroll wheel event. (*x*, *y*) are the canvas coords ((0, 0) is lower
left). button and key are as defined in `MouseEvent`.

This method will call all functions connected to the 'scroll_event'
with a `MouseEvent` instance.
"""
if step >= 0:
self._button = 'up'
else:
self._button = 'down'
s = 'scroll_event'
mouseevent = MouseEvent(s, self, x, y, self._button, self._key,
step=step, guiEvent=guiEvent)
self.callbacks.process(s, mouseevent)

@_api.deprecated("3.6", alternative=(
"callbacks.process('button_press_event', MouseEvent(...))"))
def button_press_event(self, x, y, button, dblclick=False, guiEvent=None):
"""
Callback processing for mouse button press events.

Backend derived classes should call this function on any mouse
button press. (*x*, *y*) are the canvas coords ((0, 0) is lower left).
button and key are as defined in `MouseEvent`.

This method will call all functions connected to the
'button_press_event' with a `MouseEvent` instance.
"""
self._button = button
s = 'button_press_event'
mouseevent = MouseEvent(s, self, x, y, button, self._key,
dblclick=dblclick, guiEvent=guiEvent)
self.callbacks.process(s, mouseevent)

@_api.deprecated("3.6", alternative=(
"callbacks.process('button_release_event', MouseEvent(...))"))
def button_release_event(self, x, y, button, guiEvent=None):
"""
Callback processing for mouse button release events.

Backend derived classes should call this function on any mouse
button release.

This method will call all functions connected to the
'button_release_event' with a `MouseEvent` instance.

Parameters
----------
x : float
The canvas coordinates where 0=left.
y : float
The canvas coordinates where 0=bottom.
guiEvent
The native UI event that generated the Matplotlib event.
"""
s = 'button_release_event'
event = MouseEvent(s, self, x, y, button, self._key, guiEvent=guiEvent)
self.callbacks.process(s, event)
self._button = None

# Also remove _lastx, _lasty when this goes away.
@_api.deprecated("3.6", alternative=(
"callbacks.process('motion_notify_event', MouseEvent(...))"))
def motion_notify_event(self, x, y, guiEvent=None):
"""
Callback processing for mouse movement events.

Backend derived classes should call this function on any
motion-notify-event.

This method will call all functions connected to the
'motion_notify_event' with a `MouseEvent` instance.

Parameters
----------
x : float
The canvas coordinates where 0=left.
y : float
The canvas coordinates where 0=bottom.
guiEvent
The native UI event that generated the Matplotlib event.
"""
self._lastx, self._lasty = x, y
s = 'motion_notify_event'
event = MouseEvent(s, self, x, y, self._button, self._key,
guiEvent=guiEvent)
self.callbacks.process(s, event)

@_api.deprecated("3.6", alternative=(
"callbacks.process('leave_notify_event', LocationEvent(...))"))
def leave_notify_event(self, guiEvent=None):
"""
Callback processing for the mouse cursor leaving the canvas.

Backend derived classes should call this function when leaving
canvas.

Parameters
----------
guiEvent
The native UI event that generated the Matplotlib event.
"""
self.callbacks.process('figure_leave_event', LocationEvent._lastevent)
LocationEvent._lastevent = None
self._lastx, self._lasty = None, None

@_api.deprecated("3.6", alternative=(
"callbacks.process('enter_notify_event', LocationEvent(...))"))
def enter_notify_event(self, guiEvent=None, *, xy):
"""
Callback processing for the mouse cursor entering the canvas.

Backend derived classes should call this function when entering
canvas.

Parameters
----------
guiEvent
The native UI event that generated the Matplotlib event.
xy : (float, float)
The coordinate location of the pointer when the canvas is entered.
"""
self._lastx, self._lasty = x, y = xy
event = LocationEvent('figure_enter_event', self, x, y, guiEvent)
self.callbacks.process('figure_enter_event', event)

def inaxes(self, xy):
"""
Return the topmost visible `~.axes.Axes` containing the point *xy*.
Expand Down
13 changes: 1 addition & 12 deletions lib/matplotlib/backend_managers.py
Original file line number Diff line number Diff line change
Expand Up @@ -204,23 +204,12 @@ def remove_tool(self, name):
name : str
Name of the tool.
"""

tool = self.get_tool(name)
destroy = _api.deprecate_method_override(
backend_tools.ToolBase.destroy, tool, since="3.6",
alternative="tool_removed_event")
if destroy is not None:
destroy()

# If it's a toggle tool and toggled, untoggle
if getattr(tool, 'toggled', False):
if getattr(tool, 'toggled', False): # If it's a toggled toggle tool, untoggle
self.trigger_tool(tool, 'toolmanager')

self._remove_keys(name)

event = ToolEvent('tool_removed_event', self, tool)
self._callbacks.process(event.name, event)

del self._tools[name]

def add_tool(self, name, tool, *args, **kwargs):
Expand Down
9 changes: 0 additions & 9 deletions lib/matplotlib/backend_tools.py
Original file line number Diff line number Diff line change
Expand Up @@ -155,15 +155,6 @@ def trigger(self, sender, event, data=None):
"""
pass

@_api.deprecated("3.6", alternative="tool_removed_event")
def destroy(self):
"""
Destroy the tool.

This method is called by `.ToolManager.remove_tool`.
"""
pass


class ToolToggleBase(ToolBase):
"""
Expand Down
9 changes: 0 additions & 9 deletions lib/matplotlib/backends/_backend_tk.py
Original file line number Diff line number Diff line change
Expand Up @@ -598,9 +598,6 @@ def full_screen_toggle(self):


class NavigationToolbar2Tk(NavigationToolbar2, tk.Frame):
window = _api.deprecated("3.6", alternative="self.master")(
property(lambda self: self.master))

def __init__(self, canvas, window=None, *, pack_toolbar=True):
"""
Parameters
Expand Down Expand Up @@ -727,9 +724,6 @@ def remove_rubberband(self):
self.canvas._tkcanvas.delete(self.canvas._rubberband_rect_black)
self.canvas._rubberband_rect_black = None

lastrect = _api.deprecated("3.6")(
property(lambda self: self.canvas._rubberband_rect_black))

def _set_image_for_button(self, button):
"""
Set the image for a button based on its pixel size.
Expand Down Expand Up @@ -966,9 +960,6 @@ def remove_rubberband(self):
NavigationToolbar2Tk.remove_rubberband(
self._make_classic_style_pseudo_toolbar())

lastrect = _api.deprecated("3.6")(
property(lambda self: self.figure.canvas._rubberband_rect_black))


class ToolbarTk(ToolContainerBase, tk.Frame):
def __init__(self, toolmanager, window=None):
Expand Down
Loading
0