8000 Expire more mpl3.6 deprecations. · matplotlib/matplotlib@dd15f3e · GitHub
[go: up one dir, main page]

Skip to content

Commit dd15f3e

Browse files
committed
Expire more mpl3.6 deprecations.
1 parent 43c35e7 commit dd15f3e

35 files changed

+111
-637
lines changed
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
Changes of API after deprecation
2+
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
3+
4+
- `.dviread.find_tex_file` now raises `FileNotFoundError` when the requested filename is
5+
not found.
6+
- `.Figure.colorbar` now raises if *cax* is not given and it is unable to determine from
7+
which Axes to steal space, i.e. if *ax* is also not given and *mappable* has not been
8+
added to an Axes.
9+
- `.pyplot.subplot` and `.pyplot.subplot2grid` no longer auto-remove preexisting
10+
overlapping Axes; explicitly call `.Axes.remove` as needed.
Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
Removal of deprecated APIs
2+
~~~~~~~~~~~~~~~~~~~~~~~~~~
3+
4+
The following deprecated APIs have been removed. Unless a replacement is stated, please
5+
vendor the previous implementation if needed.
6+
7+
- The following methods of `.FigureCanvasBase`: ``pick`` (use ``Figure.pick`` instead),
8+
``resize``, ``draw_event``, ``resize_event``, ``close_event``, ``key_press_event``,
9+
``key_release_event``, ``pick_event``, ``scroll_event``, ``button_press_event``,
10+
``button_release_event``, ``motion_notify_event``, ``leave_notify_event``,
11+
``enter_notify_event`` (for all the ``foo_event`` methods, construct the relevant
12+
`.Event` object and call ``canvas.callbacks.process(event.name, event)`` instead).
13+
- ``ToolBase.destroy`` (connect to ``tool_removed_event`` instead).
14+
- The *cleared* parameter to `.FigureCanvasAgg.get_renderer` (call ``renderer.clear()``
15+
instead).
16+
- The following methods of `.RendererCairo`: ``set_ctx_from_surface`` and
17+
``set_width_height`` (use ``set_context`` instead, which automatically infers the
18+
canvas size).
19+
- The ``window`` or ``win`` parameters and/or attributes of ``NavigationToolbar2Tk``,
20+
``NavigationToolbar2GTK3``, and ``NavigationToolbar2GTK4``, and the ``lastrect``
21+
attribute of ``NavigationToolbar2Tk``
22+
- The ``error_msg_gtk`` function and the ``icon_filename`` and ``window_icon`` globals
23+
in `.backend_gtk3`; the ``error_msg_wx`` function in `.backend_wx`.
24+
- ``FigureManagerGTK3Agg`` and ``FigureManagerGTK4Agg`` (use ``FigureManagerGTK3``
25+
instead); ``RendererGTK3Cairo`` and ``RendererGTK4Cairo``.
26+
- ``NavigationToolbar2Mac.prepare_configure_subplots`` (use
27+
`~.NavigationToolbar2.configure_subplots` instead).
28+
- ``FigureManagerMac.close``.
29+
- The ``qApp`` global in `.backend_qt` (use ``QtWidgets.QApplication.instance()``
30+
instead).
31+
- The ``offset_text_height`` method of ``RendererWx``; the ``sizer``, ``figmgr``,
32+
``num``, ``toolbar``, ``toolmanager``, ``get_canvas``, and ``get_figure`` attributes
33+
or methods of ``FigureFrameWx`` (use ``frame.GetSizer()``, ``frame.canvas.manager``,
34+
``frame.canvas.manager.num``, ``frame.GetToolBar()``,
35+
``frame.canvas.manager.toolmanager``, the *canvas_class* constructor parameter, and
36+
``frame.canvas.manager``, respectively, instead).
37+
- ``FigureFrameWxAgg`` and ``FigureFrameWxCairo`` (use
38+
``FigureFrameWx(..., canvas_class=FigureCanvasWxAgg)`` and
39+
``FigureFrameWx(..., canvas_class=FigureCanvasWxCairo)``, respectively, instead).
40+
- The ``filled`` attribute and the ``draw_all`` method of `.Colorbar` (instead of
41+
``draw_all``, use ``figure.draw_without_rendering``).
42+
- Calling `.MarkerStyle` without setting the *marker* parameter or setting it to None
43+
(use ``MarkerStyle("")`` instead).
44+
- Support for third-party canvas classes without a ``required_interactive_framework``
45+
attribute (this can only occur if the canvas class does not inherit from
46+
`.FigureCanvasBase`).
47+
- The ``canvas`` and ``background`` attributes of `.MultiCursor`; the
48+
``state_modifier_keys`` attribute of selector widgets.
49+
- Passing *useblit*, *horizOn*, or *vertOn* positionally to `.MultiCursor`.
50+
- Support for the ``seaborn-<foo>`` styles; use ``seaborn-v0_8-<foo>`` instead, or
51+
directly use the seaborn API.

lib/matplotlib/backend_bases.py

Lines changed: 0 additions & 233 deletions
Original file line numberDiff line numberDiff line change
@@ -1708,7 +1708,6 @@ def __init__(self, figure=None):
17081708
self.widgetlock = widgets.LockDraw()
17091709
self._button = None # the button pressed
17101710
self._key = None # the key pressed
1711-
self._lastx, self._lasty = None, None
17121711
self.mouse_grabber = None # the Axes currently grabbing mouse
17131712
self.toolbar = None # NavigationToolbar2 will set me
17141713
self._is_idle_drawing = False
@@ -1779,241 +1778,9 @@ def is_saving(self):
17791778
"""
17801779
return self._is_saving
17811780

1782-
@_api.deprecated("3.6", alternative="canvas.figure.pick")
1783-
def pick(self, mouseevent):
1784-
if not self.widgetlock.locked():
1785-
self.figure.pick(mouseevent)
1786-
17871781
def blit(self, bbox=None):
17881782
"""Blit the canvas in bbox (default entire canvas)."""
17891783

1790-
def resize(self, w, h):
1791-
"""
1792-
UNUSED: Set the canvas size in pixels.
1793-
1794-
Certain backends may implement a similar method internally, but this is
1795-
not a requirement of, nor is it used by, Matplotlib itself.
1796-
"""
1797-
# The entire method is actually deprecated, but we allow pass-through
1798-
# to a parent class to support e.g. QWidget.resize.
1799-
if hasattr(super(), "resize"):
1800-
return super().resize(w, h)
1801-
else:
1802-
_api.warn_deprecated("3.6", name="resize", obj_type="method",
1803-
alternative="FigureManagerBase.resize")
1804-
1805-
@_api.deprecated("3.6", alternative=(
1806-
"callbacks.process('draw_event', DrawEvent(...))"))
1807-
def draw_event(self, renderer):
1808-
"""Pass a `DrawEvent` to all functions connected to ``draw_event``."""
1809-
s = 'draw_event'
1810-
event = DrawEvent(s, self, renderer)
1811-
self.callbacks.process(s, event)
1812-
1813-
@_api.deprecated("3.6", alternative=(
1814-
"callbacks.process('resize_event', ResizeEvent(...))"))
1815-
def resize_event(self):
1816-
"""
1817-
Pass a `ResizeEvent` to all functions connected to ``resize_event``.
1818-
"""
1819-
s = 'resize_event'
1820-
event = ResizeEvent(s, self)
1821-
self.callbacks.process(s, event)
1822-
self.draw_idle()
1823-
1824-
@_api.deprecated("3.6", alternative=(
1825-
"callbacks.process('close_event', CloseEvent(...))"))
1826-
def close_event(self, guiEvent=None):
1827-
"""
1828-
Pass a `CloseEvent` to all functions connected to ``close_event``.
1829-
"""
1830-
s = 'close_event'
1831-
try:
1832-
event = CloseEvent(s, self, guiEvent=guiEvent)
1833-
self.callbacks.process(s, event)
1834-
except (TypeError, AttributeError):
1835-
pass
1836-
# Suppress the TypeError when the python session is being killed.
1837-
# It may be that a better solution would be a mechanism to
1838-
# disconnect all callbacks upon shutdown.
1839-
# AttributeError occurs on OSX with qt4agg upon exiting
1840-
# with an open window; 'callbacks' attribute no longer exists.
1841-
1842-
@_api.deprecated("3.6", alternative=(
1843-
"callbacks.process('key_press_event', KeyEvent(...))"))
1844-
def key_press_event(self, key, guiEvent=None):
1845-
"""
1846-
Pass a `KeyEvent` to all functions connected to ``key_press_event``.
1847-
"""
1848-
self._key = key
1849-
s = 'key_press_event'
1850-
event = KeyEvent(
1851-
s, self, key, self._lastx, self._lasty, guiEvent=guiEvent)
1852-
self.callbacks.process(s, event)
1853-
1854-
@_api.deprecated("3.6", alternative=(
1855-
"callbacks.process('key_release_event', KeyEvent(...))"))
1856-
def key_release_event(self, key, guiEvent=None):
1857-
"""
1858-
Pass a `KeyEvent` to all functions connected to ``key_release_event``.
1859-
"""
1860-
s = 'key_release_event'
1861-
event = KeyEvent(
1862-
s, self, key, self._lastx, self._lasty, guiEvent=guiEvent)
1863-
self.callbacks.process(s, event)
1864-
self._key = None
1865-
1866-
@_api.deprecated("3.6", alternative=(
1867-
"callbacks.process('pick_event', PickEvent(...))"))
1868-
def pick_event(self, mouseevent, artist, **kwargs):
1869-
"""
1870-
Callback processing for pick events.
1871-
1872-
This method will be called by artists who are picked and will
1873-
fire off `PickEvent` callbacks registered listeners.
1874-
1875-
Note that artists are not pickable by default (see
1876-
`.Artist.set_picker`).
1877-
"""
1878-
s = 'pick_event'
1879-
event = PickEvent(s, self, mouseevent, artist,
1880-
guiEvent=mouseevent.guiEvent,
1881-
**kwargs)
1882-
self.callbacks.process(s, event)
1883-
1884-
@_api.deprecated("3.6", alternative=(
1885-
"callbacks.process('scroll_event', MouseEvent(...))"))
1886-
def scroll_event(self, x, y, step, guiEvent=None):
1887-
"""
1888-
Callback processing for scroll events.
1889-
1890-
Backend derived classes should call this function on any
1891-
scroll wheel event. (*x*, *y*) are the canvas coords ((0, 0) is lower
1892-
left). button and key are as defined in `MouseEvent`.
1893-
1894-
This method will call all functions connected to the 'scroll_event'
1895-
with a `MouseEvent` instance.
1896-
"""
1897-
if step >= 0:
1898-
self._button = 'up'
1899-
else:
1900-
self._button = 'down'
1901-
s = 'scroll_event'
1902-
mouseevent = MouseEvent(s, self, x, y, self._button, self._key,
1903-
step=step, guiEvent=guiEvent)
1904-
self.callbacks.process(s, mouseevent)
1905-
1906-
@_api.deprecated("3.6", alternative=(
1907-
"callbacks.process('button_press_event', MouseEvent(...))"))
1908-
def button_press_event(self, x, y, button, dblclick=False, guiEvent=None):
1909-
"""
1910-
Callback processing for mouse button press events.
1911-
1912-
Backend derived classes should call this function on any mouse
1913-
button press. (*x*, *y*) are the canvas coords ((0, 0) is lower left).
1914-
button and key are as defined in `MouseEvent`.
1915-
1916-
This method will call all functions connected to the
1917-
'button_press_event' with a `MouseEvent` instance.
1918-
"""
1919-
self._button = button
1920-
s = 'button_press_event'
1921-
mouseevent = MouseEvent(s, self, x, y, button, self._key,
1922-
dblclick=dblclick, guiEvent=guiEvent)
1923-
self.callbacks.process(s, mouseevent)
1924-
1925-
@_api.deprecated("3.6", alternative=(
1926-
"callbacks.process('button_release_event', MouseEvent(...))"))
1927-
def button_release_event(self, x, y, button, guiEvent=None):
1928-
"""
1929-
Callback processing for mouse button release events.
1930-
1931-
Backend derived classes should call this function on any mouse
1932-
button release.
1933-
1934-
This method will call all functions connected to the
1935-
'button_release_event' with a `MouseEvent` instance.
1936-
1937-
Parameters
1938-
----------
1939-
x : float
1940-
The canvas coordinates where 0=left.
1941-
y : float
1942-
The canvas coordinates where 0=bottom.
1943-
guiEvent
1944-
The native UI event that generated the Matplotlib event.
1945-
"""
1946-
s = 'button_release_event'
1947-
event = MouseEvent(s, self, x, y, button, self._key, guiEvent=guiEvent)
1948-
self.callbacks.process(s, event)
1949-
self._button = None
1950-
1951-
# Also remove _lastx, _lasty when this goes away.
1952-
@_api.deprecated("3.6", alternative=(
1953-
"callbacks.process('motion_notify_event', MouseEvent(...))"))
1954-
def motion_notify_event(self, x, y, guiEvent=None):
1955-
"""
1956-
Callback processing for mouse movement events.
1957-
1958-
Backend derived classes should call this function on any
1959-
motion-notify-event.
1960-
1961-
This method will call all functions connected to the
1962-
'motion_notify_event' with a `MouseEvent` instance.
1963-
1964-
Parameters
1965-
----------
1966-
x : float
1967-
The canvas coordinates where 0=left.
1968-
y : float
1969-
The canvas coordinates where 0=bottom.
1970-
guiEvent
1971-
The native UI event that generated the Matplotlib event.
1972-
"""
1973-
self._lastx, self._lasty = x, y
1974-
s = 'motion_notify_event'
1975-
event = MouseEvent(s, self, x, y, self._button, self._key,
1976-
guiEvent=guiEvent)
1977-
self.callbacks.process(s, event)
1978-
1979-
@_api.deprecated("3.6", alternative=(
1980-
"callbacks.process('leave_notify_event', LocationEvent(...))"))
1981-
def leave_notify_event(self, guiEvent=None):
1982-
"""
1983-
Callback processing for the mouse cursor leaving the canvas.
1984-
1985-
Backend derived classes should call this function when leaving
1986-
canvas.
1987-
1988-
Parameters
1989-
----------
1990-
guiEvent
1991-
The native UI event that generated the Matplotlib event.
1992-
"""
1993-
self.callbacks.process('figure_leave_event', LocationEvent._lastevent)
1994-
LocationEvent._lastevent = None
1995-
self._lastx, self._lasty = None, None
1996-
1997-
@_api.deprecated("3.6", alternative=(
1998-
"callbacks.process('enter_notify_event', LocationEvent(...))"))
1999-
def enter_notify_event(self, guiEvent=None, *, xy):
2000-
"""
2001-
Callback processing for the mouse cursor entering the canvas.
2002-
2003-
Backend derived classes should call this function when entering
2004-
canvas.
2005-
2006-
Parameters
2007-
----------
2008-
gu 10000 iEvent
2009-
The native UI event that generated the Matplotlib event.
2010-
xy : (float, float)
2011-
The coordinate location of the pointer when the canvas is entered.
2012-
"""
2013-
self._lastx, self._lasty = x, y = xy
2014-
event = LocationEvent('figure_enter_event', self, x, y, guiEvent)
2015-
self.callbacks.process('figure_enter_event', event)
2016-
20171784
def inaxes(self, xy):
20181785
"""
20191786
Return the topmost visible `~.axes.Axes` containing the point *xy*.

lib/matplotlib/backend_managers.py

Lines changed: 1 addition & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -204,23 +204,12 @@ def remove_tool(self, name):
204204
name : str
205205
Name of the tool.
206206
"""
207-
208207
tool = self.get_tool(name)
209-
destroy = _api.deprecate_method_override(
210-
backend_tools.ToolBase.destroy, tool, since="3.6",
211-
alternative="tool_removed_event")
212-
if destroy is not None:
213-
destroy()
214-
215-
# If it's a toggle tool and toggled, untoggle
216-
if getattr(tool, 'toggled', False):
208+
if getattr(tool, 'toggled', False): # If it's a toggled toggle tool, untoggle
217209
self.trigger_tool(tool, 'toolmanager')
218-
219210
self._remove_keys(name)
220-
221211
event = ToolEvent('tool_removed_event', self, tool)
222212
self._callbacks.process(event.name, event)
223-
224213
del self._tools[name]
225214

226215
def add_tool(self, name, tool, *args, **kwargs):

lib/matplotlib/backend_tools.py

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -155,15 +155,6 @@ def trigger(self, sender, event, data=None):
155155
"""
156156
pass
157157

158-
@_api.deprecated("3.6", alternative="tool_removed_event")
159-
def destroy(self):
160-
"""
161-
Destroy the tool.
162-
163-
This method is called by `.ToolManager.remove_tool`.
164-
"""
165-
pass
166-
167158

168159
class ToolToggleBase(ToolBase):
169160
"""

lib/matplotlib/backends/_backend_tk.py

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -600,9 +600,6 @@ def full_screen_toggle(self):
600600

601601

602602
class NavigationToolbar2Tk(NavigationToolbar2, tk.Frame):
603-
window = _api.deprecated("3.6", alternative="self.master")(
604-
property(lambda self: self.master))
605-
606603
def __init__(self, canvas, window=None, *, pack_toolbar=True):
607604
"""
608605
Parameters
@@ -729,9 +726,6 @@ def remove_rubberband(self):
729726
self.canvas._tkcanvas.delete(self.canvas._rubberband_rect_black)
730727
self.canvas._rubberband_rect_black = None
731728

732-
lastrect = _api.deprecated("3.6")(
733-
property(lambda self: self.canvas._rubberband_rect_black))
734-
735729
def _set_image_for_button(self, button):
736730
"""
737731
Set the image for a button based on its pixel size.
@@ -957,9 +951,6 @@ def remove_rubberband(self):
957951
NavigationToolbar2Tk.remove_rubberband(
958952
self._make_classic_style_pseudo_toolbar())
959953

960-
lastrect = _api.deprecated("3.6")(
961-
property(lambda self: self.figure.canvas._rubberband_rect_black))
962-
963954

964955
class ToolbarTk(ToolContainerBase, tk.Frame):
965956
def __init__(self, toolmanager, window=None):

0 commit comments

Comments
 (0)
0