8000 Remove remaining 3.8 deprecations · matplotlib/matplotlib@3d24148 · GitHub
[go: up one dir, main page]

Skip to content

Commit 3d24148

Browse files
committed
Remove remaining 3.8 deprecations
1 parent 1127c99 commit 3d24148

File tree

14 files changed

+92
-99
lines changed

14 files changed

+92
-99
lines changed

doc/api/next_api_changes/removals/28874-ES.rst

Lines changed: 71 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,48 @@
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+
146
Auto-closing of figures when switching backend
247
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
348

@@ -61,6 +106,13 @@ which should cover most use cases.
61106
... with no replacement.
62107

63108

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+
64116
``cbook`` API changes
65117
~~~~~~~~~~~~~~~~~~~~~
66118

@@ -74,6 +126,25 @@ now auto-loads numpy arrays. Use ``get_sample_data(..., asfileobj=False)`` inste
74126
the filename of the data file, which can then be passed to `open`, if desired.
75127

76128

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+
77148
``axes_grid1`` API changes
78149
~~~~~~~~~~~~~~~~~~~~~~~~~~
79150

lib/matplotlib/figure.py

Lines changed: 6 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -613,22 +613,22 @@ def add_axes(self, *args, **kwargs):
613613
"""
614614

615615
if not len(args) and 'rect' not in kwargs:
616-
raise TypeError(
617-
"add_axes() missing 1 required positional argument: 'rect'")
616+
raise TypeError("add_axes() missing 1 required positional argument: 'rect'")
618617
elif 'rect' in kwargs:
619618
if len(args):
620-
raise TypeError(
621-
"add_axes() got multiple values for argument 'rect'")
619+
raise TypeError("add_axes() got multiple values for argument 'rect'")
622620
args = (kwargs.pop('rect'), )
621+
if len(args) != 1:
622+
raise _api.nargs_error("add_axes", 1, len(args))
623623

624624
if isinstance(args[0], Axes):
625-
a, *extra_args = args
625+
a, = args
626626
key = a._projection_init
627627
if a.get_figure(root=False) is not self:
628628
raise ValueError(
629629
"The Axes must have been created in the present figure")
630630
else:
631-
rect, *extra_args = args
631+
rect, = args
632632
if not np.isfinite(rect).all():
633633
raise ValueError(f'all entries in rect must be finite not {rect}')
634634
projection_class, pkw = self._process_projection_requirements(**kwargs)
@@ -637,11 +637,6 @@ def add_axes(self, *args, **kwargs):
637637
a = projection_class(self, rect, **pkw)
638638
key = (projection_class, pkw)
639639

640-
if extra_args:
641-
_api.warn_deprecated(
642-
"3.8",
643-
name="Passing more than one positional argument to Figure.add_axes",
644-
addendum="Any additional positional arguments are currently ignored.")
645640
return self._add_axes_internal(a, key)
646641

647642
@_docstring.interpd

lib/matplotlib/legend.py

Lines changed: 2 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -454,24 +454,10 @@ def __init__(
454454
self.borderaxespad = mpl._val_or_rc(borderaxespad, 'legend.borderaxespad')
455455
self.columnspacing = mpl._val_or_rc(columnspacing, 'legend.columnspacing')
456456
self.shadow = mpl._val_or_rc(shadow, 'legend.shadow')
457-
# trim handles and labels if illegal label...
458-
_lab, _hand = [], []
459-
for label, handle in zip(labels, handles):
460-
if isinstance(label, str) and label.startswith('_'):
461-
_api.warn_deprecated("3.8", message=(
462-
"An artist whose label starts with an underscore was passed to "
463-
"legend(); such artists will no longer be ignored in the future. "
464-
"To suppress this warning, explicitly filter out such artists, "
465-
"e.g. with `[art for art in artists if not "
466-
"art.get_label().startswith('_')]`."))
467-
else:
468-
_lab.append(label)
469-
_hand.append(handle)
470-
labels, handles = _lab, _hand
471457

472458
if reverse:
473-
labels.reverse()
474-
handles.reverse()
459+
labels = [*reversed(labels)]
460+
handles = [*reversed(handles)]
475461

476462
if len(handles) < 2:
477463
ncols = 1

lib/matplotlib/path.py

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1086,10 +1086,7 @@ def get_path_collection_extents(
10861086
if len(paths) == 0:
10871087
raise ValueError("No paths provided")
10881088
if len(offsets) == 0:
1089-
_api.warn_deprecated(
1090-
"3.8", message="Calling get_path_collection_extents() with an"
1091-
" empty offsets list is deprecated since %(since)s. Support will"
1092-
" be removed %(removal)s.")
1089+
raise ValueError("No offsets provided")
10931090
extents, minpos = _path.get_path_collection_extents(
10941091
master_transform, paths, np.atleast_3d(transforms),
10951092
offsets, offset_transform)

lib/matplotlib/table.py

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -496,11 +496,7 @@ def auto_set_column_width(self, col):
496496
"""
497497
col1d = np.atleast_1d(col)
498498
if not np.issubdtype(col1d.dtype, np.integer):
499-
_api.warn_deprecated("3.8", name="col",
500-
message="%(name)r must be an int or sequence of ints. "
501-
"Passing other types is deprecated since %(since)s "
502-
"and will be removed %(removal)s.")
503-
return
499+
raise TypeError("col must be an int or sequence of ints.")
504500
for cell in col1d:
505501
self._autoColumns.append(cell)
506502

lib/matplotlib/tests/test_figure.py

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -518,12 +518,10 @@ def test_invalid_figure_add_axes():
518518
fig.add_axes(ax)
519519

520520
fig2.delaxes(ax)
521-
with pytest.warns(mpl.MatplotlibDeprecationWarning,
522-
match="Passing more than one positional argument"):
521+
with pytest.raises(TypeError, match=r"add_axes\(\) takes 1 positional arguments"):
523522
fig2.add_axes(ax, "extra positional argument")
524523

525-
with pytest.warns(mpl.MatplotlibDeprecationWarning,
526-
match="Passing more than one positional argument"):
524+
with pytest.raises(TypeError, match=r"add_axes\(\) takes 1 positional arguments"):
527525
fig.add_axes([0, 0, 1, 1], "extra positional argument")
528526

529527

lib/matplotlib/tests/test_legend.py

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -138,19 +138,6 @@ def test_various_labels():
138138
ax.legend(numpoints=1, loc='best')
139139

140140

141-
def test_legend_label_with_leading_underscore():
142-
"""
143-
Test that artists with labels starting with an underscore are not added to
144-
the legend, and that a warning is issued if one tries to add them
145-
explicitly.
146-
"""
147-
fig, ax = plt.subplots()
148-
line, = ax.plot([0, 1], label='_foo')
149-
with pytest.warns(_api.MatplotlibDeprecationWarning, match="with an underscore"):
150-
legend = ax.legend(handles=[line])
151-
assert len(legend.legend_handles) == 0
152-
153-
154141
@image_comparison(['legend_labels_first.png'], remove_text=True,
155142
tol=0.013 if platform.machine() == 'arm64' else 0)
156143
def test_labels_first():

lib/matplotlib/tests/test_table.py

Lines changed: 3 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -128,10 +128,9 @@ def test_customcell():
128128

129129
@image_comparison(['table_auto_column.png'])
130130
def test_auto_column():
131-
fig = plt.figure()
131+
fig, (ax1, ax2, ax3, ax4) = plt.subplots(4, 1)
132132

133133
# iterable list input
134-
ax1 = fig.add_subplot(4, 1, 1)
135134
ax1.axis('off')
136135
tb1 = ax1.table(
137136
cellText=[['Fit Text', 2],
@@ -144,7 +143,6 @@ def test_auto_column():
144143
tb1.auto_set_column_width([-1, 0, 1])
145144

146145
# iterable tuple input
147-
ax2 = fig.add_subplot(4, 1, 2)
148146
ax2.axis('off')
149147
tb2 = ax2.table(
150148
cellText=[['Fit Text', 2],
@@ -157,7 +155,6 @@ def test_auto_column():
157155
tb2.auto_set_column_width((-1, 0, 1))
158156

159157
# 3 single inputs
160-
ax3 = fig.add_subplot(4, 1, 3)
161158
ax3.axis('off')
162159
tb3 = ax3.table(
163160
cellText=[['Fit Text', 2],
@@ -171,8 +168,8 @@ def test_auto_column():
171168
tb3.auto_set_column_width(0)
172169
tb3.auto_set_column_width(1)
173170

174-
# 4 non integer iterable input
175-
ax4 = fig.add_subplot(4, 1, 4)
171+
# 4 this used to test non-integer iterable input, which did nothing, but only
172+
# remains to avoid re-generating the test image.
176173
ax4.axis('off')
177174
tb4 = ax4.table(
178175
cellText=[['Fit Text', 2],
@@ -182,12 +179,6 @@ def test_auto_column():
182179
loc="center")
183180
tb4.auto_set_font_size(False)
184181
tb4.set_fontsize(12)
185-
with pytest.warns(mpl.MatplotlibDeprecationWarning,
186-
match="'col' must be an int or sequence of ints"):
187-
tb4.auto_set_column_width("-101") # type: ignore [arg-type]
188-
with pytest.warns(mpl.MatplotlibDeprecationWarning,
189-
match="'col' must be an int or sequence of ints"):
190-
tb4.auto_set_column_width(["-101"]) # type: ignore [list-item]
191182

192183

193184
def test_table_cells():

lib/matplotlib/tests/test_widgets.py

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -131,16 +131,6 @@ def test_rectangle_minspan(ax, spancoords, minspanx, x1, minspany, y1):
131131
assert kwargs == {}
132132

133133

134-
def test_deprecation_selector_visible_attribute(ax):
135-
tool = widgets.RectangleSelector(ax)
136-
137-
assert tool.get_visible()
138-
139-
with pytest.warns(mpl.MatplotlibDeprecationWarning,
140-
match="was deprecated in Matplotlib 3.8"):
141-
tool.visible
142-
143-
144134
@pytest.mark.parametrize('drag_from_anywhere, new_center',
145135
[[True, (60, 75)],
146136
[False, (30, 20)]])

lib/matplotlib/texmanager.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@
3131
import numpy as np
3232

3333
import matplotlib as mpl
34-
from matplotlib import _api, cbook, dviread
34+
from matplotlib import cbook, dviread
3535

3636
_log = logging.getLogger(__name__)
3737

@@ -63,7 +63,6 @@ class TexManager:
6363
Repeated calls to this constructor always return the same instance.
6464
"""
6565

66-
texcache = _api.deprecate_privatize_attribute("3.8")
6766
_texcache = os.path.join(mpl.get_cachedir(), 'tex.cache')
6867
_grey_arrayd = {}
6968

0 commit comments

Comments
 (0)
0