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

Skip to content

Commit 7593423

Browse files
authored
Merge pull request #28874 from QuLogic/remove-deprecations
Remove remaining 3.8 deprecations
2 parents df1e039 + d9fdae8 commit 7593423

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

48 files changed

+255
-730
lines changed
Lines changed: 180 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,180 @@
1+
Passing extra positional arguments to ``Figure.add_axes``
2+
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
3+
4+
Positional arguments passed to `.Figure.add_axes` other than a rect or an existing
5+
``Axes`` were previously ignored, and is now an error.
6+
7+
8+
Artists explicitly passed in will no longer be filtered by legend() based on their label
9+
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
10+
11+
Previously, artists explicitly passed to ``legend(handles=[...])`` are filtered out if
12+
their label starts with an underscore. This filter is no longer applied; explicitly
13+
filter out such artists (``[art for art in artists if not
14+
art.get_label().startswith('_')]``) if necessary.
15+
16+
Note that if no handles are specified at all, then the default still filters out labels
17+
starting with an underscore.
18+
19+
20+
The parameter of ``Annotation.contains`` and ``Legend.contains`` is renamed to *mouseevent*
21+
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
22+
23+
... consistently with `.Artist.contains`.
24+
25+
26+
Support for passing the "frac" key in ``annotate(..., arrowprops={"frac": ...})``
27+
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
28+
29+
... has been removed. This key has had no effect since Matplotlib 1.5.
30+
31+
32+
Passing non-int or sequence of non-int to ``Table.auto_set_column_width``
33+
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
34+
35+
Column numbers are ints, and formerly passing any other type was effectively ignored.
36+
This has now become an error.
37+
38+
39+
Widgets
40+
~~~~~~~
41+
42+
The *visible* attribute getter of ``*Selector`` widgets has been removed; use
43+
``get_visible`` instead.
44+
45+
46+
Auto-closing of figures when switching backend
47+
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
48+
49+
Allowable backend switches (i.e. those that do not swap a GUI event loop with another
50+
one) will not close existing figures. If necessary, call ``plt.close("all")`` before
51+
switching.
52+
53+
54+
``FigureCanvasBase.switch_backends``
55+
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
56+
57+
... has been removed with no replacement.
58+
59+
60+
Accessing ``event.guiEvent`` after event handlers return
61+
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
62+
63+
... is no longer supported, and ``event.guiEvent`` will be set to None once the event
64+
handlers return. For some GUI toolkits, it is unsafe to use the event, though you may
65+
separately stash the object at your own risk.
66+
67+
68+
``PdfPages(keep_empty=True)``
69+
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
70+
71+
A zero-page PDF is not valid, thus passing ``keep_empty=True`` to `.backend_pdf.PdfPages`
72+
and `.backend_pgf.PdfPages`, and the ``keep_empty`` attribute of these classes, is no
73+
longer allowed, and empty PDF files will not be created.
74+
75+
Furthermore, `.backend_pdf.PdfPages` no longer immediately creates the target file upon
76+
instantiation, but only when the first figure is saved. To fully control file creation,
77+
directly pass an opened file object as argument (``with open(path, "wb") as file,
78+
PdfPages(file) as pdf: ...``).
79+
80+
81+
``backend_ps.psDefs``
82+
~~~~~~~~~~~~~~~~~~~~~
83+
84+
The ``psDefs`` module-level variable in ``backend_ps`` has been removed with no
85+
replacement.
86+
87+
88+
Automatic papersize selection in PostScript
89+
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
90+
91+
Setting :rc:`ps.papersize` to ``'auto'`` or passing ``papersize='auto'`` to
92+
`.Figure.savefig` is no longer supported. Either pass an explicit paper type name, or
93+
omit this parameter to use the default from the rcParam.
94+
95+
96+
``RendererAgg.tostring_rgb`` and ``FigureCanvasAgg.tostring_rgb``
97+
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
98+
99+
... have been remove with no direct replacement. Consider using ``buffer_rgba`` instead,
100+
which should cover most use cases.
101+
102+
103+
``NavigationToolbar2QT.message`` has been removed
104+
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
105+
106+
... with no replacement.
107+
108+
109+
``TexManager.texcache``
110+
~~~~~~~~~~~~~~~~~~~~~~~
111+
112+
... is considered private and has been removed. The location of the cache directory is
113+
clarified in the doc-string.
114+
115+
116+
``cbook`` API changes
117+
~~~~~~~~~~~~~~~~~~~~~
118+
119+
``cbook.Stack`` has been removed with no replacement.
120+
121+
``Grouper.clean()`` has been removed with no replacement. The Grouper class now cleans
122+
itself up automatically.
123+
124+
The *np_load* parameter of ``cbook.get_sample_data`` has been removed; `.get_sample_data`
125+
now auto-loads numpy arrays. Use ``get_sample_data(..., asfileobj=False)`` instead to get
126+
the filename of the data file, which can then be passed to `open`, if desired.
127+
128+
129+
Calling ``paths.get_path_collection_extents`` with empty *offsets*
130+
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
131+
132+
Calling `~.get_path_collection_extents` with an empty *offsets* parameter has an
133+
ambiguous interpretation and is no longer allowed.
134+
135+
136+
``bbox.anchored()`` with no explicit container
137+
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
138+
139+
Not passing a *container* argument to `.BboxBase.anchored` is no longer supported.
140+
141+
142+
``INVALID_NON_AFFINE``, ``INVALID_AFFINE``, ``INVALID`` attributes of ``TransformNode``
143+
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
144+
145+
These attributes have been removed.
146+
147+
148+
``axes_grid1`` API changes
149+
~~~~~~~~~~~~~~~~~~~~~~~~~~
150+
151+
``anchored_artists.AnchoredEllipse`` has been removed. Instead, directly construct an
152+
`.AnchoredOffsetbox`, an `.AuxTransformBox`, and an `~.patches.Ellipse`, as demonstrated
153+
in :doc:`/gallery/misc/anchored_artists`.
154+
155+
The ``axes_divider.AxesLocator`` class has been removed. The ``new_locator`` method of
156+
divider instances now instead returns an opaque callable (which can still be passed to
157+
``ax.set_axes_locator``).
158+
159+
``axes_divider.Divider.locate`` has been removed; use ``Divider.new_locator(...)(ax,
160+
renderer)`` instead.
161+
162+
``axes_grid.CbarAxesBase.toggle_label`` has been removed. Instead, use standard methods
163+
for manipulating colorbar labels (`.Colorbar.set_label`) and tick labels
164+
(`.Axes.tick_params`).
165+
166+
``inset_location.InsetPosition`` has been removed; use `~.Axes.inset_axes` instead.
167+
168+
169+
``axisartist`` API changes
170+
~~~~~~~~~~~~~~~~~~~~~~~~~~
171+
172+
The ``axisartist.axes_grid`` and ``axisartist.axes_rgb`` modules, which provide wrappers
173+
combining the functionality of `.axes_grid1` and `.axisartist`, have been removed;
174+
directly use e.g. ``AxesGrid(..., axes_class=axislines.Axes)`` instead.
175+
176+
Calling an axisartist Axes to mean `~matplotlib.pyplot.axis` has been removed; explicitly
177+
call the method instead.
178+
179+
``floating_axes.GridHelperCurveLinear.get_data_boundary`` has been removed. Use
180+
``grid_finder.extreme_finder(*[None] * 5)`` to get the extremes of the grid.

doc/api/prev_api_changes/api_changes_3.6.0/behaviour.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -241,7 +241,7 @@ Specified exception types in ``Grid``
241241

242242
In a few cases an `Exception` was thrown when an incorrect argument value was
243243
set in the `mpl_toolkits.axes_grid1.axes_grid.Grid` (=
244-
`mpl_toolkits.axisartist.axes_grid.Grid`) constructor. These are replaced as
244+
``mpl_toolkits.axisartist.axes_grid.Grid``) constructor. These are replaced as
245245
follows:
246246

247247
* Providing an incorrect value for *ngrids* now raises a `ValueError`

doc/api/prev_api_changes/api_changes_3.7.0/deprecations.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ Passing undefined *label_mode* to ``Grid``
9090
... is deprecated. This includes `mpl_toolkits.axes_grid1.axes_grid.Grid`,
9191
`mpl_toolkits.axes_grid1.axes_grid.AxesGrid`, and
9292
`mpl_toolkits.axes_grid1.axes_grid.ImageGrid` as well as the corresponding
93-
classes imported from `mpl_toolkits.axisartist.axes_grid`.
93+
classes imported from ``mpl_toolkits.axisartist.axes_grid``.
9494

9595
Pass ``label_mode='keep'`` instead to get the previous behavior of not modifying labels.
9696

doc/api/prev_api_changes/api_changes_3.9.0/removals.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,7 @@ Passing undefined *label_mode* to ``Grid``
111111
... is no longer allowed. This includes `mpl_toolkits.axes_grid1.axes_grid.Grid`,
112112
`mpl_toolkits.axes_grid1.axes_grid.AxesGrid`, and
113113
`mpl_toolkits.axes_grid1.axes_grid.ImageGrid` as well as the corresponding classes
114-
imported from `mpl_toolkits.axisartist.axes_grid`.
114+
imported from ``mpl_toolkits.axisartist.axes_grid``.
115115

116116
Pass ``label_mode='keep'`` instead to get the previous behavior of not modifying labels.
117117

doc/api/toolkits/axisartist.rst

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,8 +34,6 @@ You can find a tutorial describing usage of axisartist at the
3434

3535
axisartist.angle_helper
3636
axisartist.axes_divider
37-
axisartist.axes_grid
38-
axisartist.axes_rgb
3937
axisartist.axis_artist
4038
axisartist.axisline_style
4139
axisartist.axislines

lib/matplotlib/backend_bases.py

Lines changed: 2 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -1178,26 +1178,12 @@ class Event:
11781178
def __init__(self, name, canvas, guiEvent=None):
11791179
self.name = name
11801180
self.canvas = canvas
1181-
self._guiEvent = guiEvent
1182-
self._guiEvent_deleted = False
1181+
self.guiEvent = guiEvent
11831182

11841183
def _process(self):
11851184
"""Process this event on ``self.canvas``, then unset ``guiEvent``."""
11861185
self.canvas.callbacks.process(self.name, self)
1187-
self._guiEvent_deleted = True
1188-
1189-
@property
1190-
def guiEvent(self):
1191-
# After deprecation elapses: remove _guiEvent_deleted; make guiEvent a plain
1192-
# attribute set to None by _process.
1193-
if self._guiEvent_deleted:
1194-
_api.warn_deprecated(
1195-
"3.8", message="Accessing guiEvent outside of the original GUI event "
1196-
"handler is unsafe and deprecated since %(since)s; in the future, the "
1197-
"attribute will be set to None after quitting the event handler. You "
1198-
"may separately record the value of the guiEvent attribute at your own "
1199-
"risk.")
1200-
return self._guiEvent
1186+
self.guiEvent = None
12011187

12021188

12031189
class DrawEvent(Event):
@@ -2097,12 +2083,6 @@ def print_figure(
20972083
if dpi == 'figure':
20982084
dpi = getattr(self.figure, '_original_dpi', self.figure.dpi)
20992085

2100-
if kwargs.get("papertype") == 'auto':
2101-
# When deprecation elapses, remove backend_ps._get_papertype & its callers.
2102-
_api.warn_deprecated(
2103-
"3.8", name="papertype='auto'", addendum="Pass an explicit paper type, "
2104-
"'figure', or omit the *papertype* argument entirely.")
2105-
21062086
# Remove the figure manager, if any, to avoid resizing the GUI widget.
21072087
with (cbook._setattr_cm(self, manager=None),
21082088
self._switch_canvas_and_return_print_method(format, backend)
@@ -2207,20 +2187,6 @@ def get_default_filename(self):
22072187
default_filetype = self.get_default_filetype()
22082188
return f'{default_basename}.{default_filetype}'
22092189

2210-
@_api.deprecated("3.8")
2211-
def switch_backends(self, FigureCanvasClass):
2212-
"""
2213-
Instantiate an instance of FigureCanvasClass
2214-
2215-
This is used for backend switching, e.g., to instantiate a
2216-
FigureCanvasPS from a FigureCanvasGTK. Note, deep copying is
2217-
not done, so any changes to one of the instances (e.g., setting
2218-
figure size or line props), will be reflected in the other
2219-
"""
2220-
newCanvas = FigureCanvasClass(self.figure)
2221-
newCanvas._is_saving = self._is_saving
2222-
return newCanvas
2223-
22242190
def mpl_connect(self, s, func):
22252191
"""
22262192
Bind function *func* to event *s*.

lib/matplotlib/backend_bases.pyi

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -199,13 +199,11 @@ class TimerBase:
199199
class Event:
200200
name: str
201201
canvas: FigureCanvasBase
202+
guiEvent: Any
202203
def __init__(
203204
self, name: str, canvas: FigureCanvasBase, guiEvent: Any | None = ...
204205
) -> None: ...
205206

206-
@property
207-
def guiEvent(self) -> Any: ...
208-
209207
class DrawEvent(Event):
210208
renderer: RendererBase
211209
def __init__(
@@ -348,7 +346,6 @@ class FigureCanvasBase:
348346
def get_default_filetype(cls) -> str: ...
349347
def get_default_filename(self) -> str: ...
350348
_T = TypeVar("_T", bound=FigureCanvasBase)
351-
def switch_backends(self, FigureCanvasClass: type[_T]) -> _T: ...
352349
def mpl_connect(self, s: str, func: Callable[[Event], Any]) -> int: ...
353350
def mpl_disconnect(self, cid: int) -> None: ...
354351
def new_timer(

lib/matplotlib/backend_tools.pyi

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -75,8 +75,8 @@ class ToolXScale(AxisScaleBase):
7575
def set_scale(self, ax, scale: str | ScaleBase) -> None: ...
7676

7777
class ToolViewsPositions(ToolBase):
78-
views: dict[Figure | Axes, cbook.Stack]
79-
positions: dict[Figure | Axes, cbook.Stack]
78+
views: dict[Figure | Axes, cbook._Stack]
79+
positions: dict[Figure | Axes, cbook._Stack]
8080
home_views: dict[Figure, dict[Axes, tuple[float, float, float, float]]]
8181
def add_figure(self, figure: Figure) -> None: ...
8282
def clear(self, figure: Figure) -> None: ...

lib/matplotlib/backends/backend_agg.py

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -266,10 +266,6 @@ def buffer_rgba(self):
266266
def tostring_argb(self):
267267
return np.asarray(self._renderer).take([3, 0, 1, 2], axis=2).tobytes()
268268

269-
@_api.deprecated("3.8", alternative="buffer_rgba")
270-
def tostring_rgb(self):
271-
return np.asarray(self._renderer).take([0, 1, 2], axis=2).tobytes()
272-
273269
def clear(self):
274270
self._renderer.clear()
275271

@@ -398,16 +394,6 @@ def get_renderer(self):
398394
self._lastKey = key
399395
return self.renderer
400396

401-
@_api.deprecated("3.8", alternative="buffer_rgba")
402-
def tostring_rgb(self):
403-
"""
404-
Get the image as RGB `bytes`.
405-
406-
`draw` must be called at least once before this function will work and
407-
to update the renderer for any subsequent changes to the Figure.
408-
"""
409-
return self.renderer.tostring_rgb()
410-
411397
def tostring_argb(self):
412398
"""
413399
Get the image as ARGB `bytes`.

lib/matplotlib/backends/backend_pdf.py

Lines changed: 3 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -2663,9 +2663,9 @@ class PdfPages:
26632663
confusion when using `~.pyplot.savefig` and forgetting the format argument.
26642664
"""
26652665

2666-
_UNSET = object()
2667-
2668-
def __init__(self, filename, keep_empty=_UNSET, metadata=None):
2666+
@_api.delete_parameter("3.10", "keep_empty",
2667+
addendum="This parameter does nothing.")
2668+
def __init__(self, filename, keep_empty=None, metadata=None):
26692669
"""
26702670
Create a new PdfPages object.
26712671
@@ -2676,10 +2676,6 @@ def __init__(self, filename, keep_empty=_UNSET, metadata=None):
26762676
The file is opened when a figure is saved for the first time (overwriting
26772677
any older file with the same name).
26782678
2679-
keep_empty : bool, optional
2680-
If set to False, then empty pdf files will be deleted automatically
2681-
when closed.
2682-
26832679
metadata : dict, optional
26842680
Information dictionary object (see PDF reference section 10.2.1
26852681
'Document Information Dictionary'), e.g.:
@@ -2693,13 +2689,6 @@ def __init__(self, filename, keep_empty=_UNSET, metadata=None):
26932689
self._filename = filename
26942690
self._metadata = metadata
26952691
self._file = None
2696-
if keep_empty and keep_empty is not self._UNSET:
2697-
_api.warn_deprecated("3.8", message=(
2698-
"Keeping empty pdf files is deprecated since %(since)s and support "
2699-
"will be removed %(removal)s."))
2700-
self._keep_empty = keep_empty
2701-
2702-
keep_empty = _api.deprecate_privatize_attribute("3.8")
27032692

27042693
def __enter__(self):
27052694
return self
@@ -2721,11 +2710,6 @@ def close(self):
27212710
self._file.finalize()
27222711
self._file.close()
27232712
self._file = None
2724-
elif self._keep_empty: # True *or* UNSET.
2725-
_api.warn_deprecated("3.8", message=(
2726-
"Keeping empty pdf files is deprecated since %(since)s and support "
2727-
"will be removed %(removal)s."))
2728-
PdfFile(self._filename, metadata=self._metadata).close() # touch the file.
27292713

27302714
def infodict(self):
27312715
"""

0 commit comments

Comments
 (0)