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

Skip to content

Commit 002b27e

Browse files
authored
Merge pull request #17239 from QuLogic/remove-deprecations
API: Remove deprecations that expire in 3.3
2 parents a4378ef + a30e8e7 commit 002b27e

21 files changed

+131
-286
lines changed

doc/api/api_changes_3.3/behaviour.rst

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -192,3 +192,25 @@ be kept by passing it as a keyword argument to `.Axes.hist`.
192192
`.Legend` and `.OffsetBox` subclasses (`.PaddedBox`, `.AnchoredOffsetbox`, and
193193
`.AnnotationBbox`) no longer directly keep track of the visibility of their
194194
underlying `.Patch` artist, but instead pass that flag down to the `.Patch`.
195+
196+
`.Legend` and `.Table` no longer allow invalid locations
197+
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
198+
This affects legends produced on an Axes (`.Axes.legend` and `.pyplot.legend`)
199+
and on a Figure (`.Figure.legend` and `.pyplot.figlegend`). Figure legends also
200+
no longer accept the unsupported ``'best'`` location. Previously, invalid Axes
201+
locations would use ``'best'`` and invalid Figure locations would used ``'upper
202+
right'``.
203+
204+
205+
Passing Line2D's *drawstyle* together with *linestyle* is removed
206+
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
207+
208+
Instead of ``plt.plot(..., linestyle="steps--")``, use ``plt.plot(...,
209+
linestyle="--", drawstyle="steps")``. ``ds`` is also an alias for
210+
``drawstyle``.
211+
212+
Upper case color strings
213+
~~~~~~~~~~~~~~~~~~~~~~~~
214+
215+
Support for passing single-letter colors (one of "rgbcmykw") as UPPERCASE
216+
characters is removed; these colors are now case-sensitive (lowercase).

doc/api/api_changes_3.3/removals.rst

Lines changed: 68 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,12 @@ Modules
99

1010
Classes, methods and attributes
1111
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
12+
- ``artist.Artist.aname`` property (no replacement)
13+
14+
- ``axis.Axis.iter_ticks`` (no replacement)
15+
16+
- Support for custom backends that do not provide a
17+
``backend_bases.GraphicsContextBase.set_hatch_color`` method
1218
- ``backend_bases.RendererBase.strip_math()``
1319
(use ``cbook.strip_math()`` instead)
1420

@@ -39,38 +45,68 @@ Classes, methods and attributes
3945
- ``backend_qt5.NavigationToolbar2QT.buttons`` property (no replacement)
4046
- ``backend_qt5.NavigationToolbar2QT.adj_window`` property (no replacement)
4147

48+
- ``bezier.find_r_to_boundary_of_closedpath()`` (no replacement)
49+
4250
- ``cbook.dedent()`` (use `inspect.cleandoc` instead)
4351
- ``cbook.get_label()`` (no replacement)
4452
- ``cbook.is_hashable()`` (use ``isinstance(..., collections.abc.Hashable)``
4553
instead)
4654
- ``cbook.iterable()`` (use ``numpy.iterable()`` instead)
4755
- ``cbook.safezip()`` (no replacement)
4856

57+
- ``colorbar.ColorbarBase.get_cmap`` (use ``ScalarMappable.get_cmap`` instead)
58+
- ``colorbar.ColorbarBase.set_cmap`` (use ``ScalarMappable.set_cmap`` instead)
59+
- ``colorbar.ColorbarBase.get_clim`` (use ``ScalarMappable.get_clim`` instead)
60+
- ``colorbar.ColorbarBase.set_clim`` (use ``ScalarMappable.set_clim`` instead)
61+
- ``colorbar.ColorbarBase.set_norm`` (use ``ScalarMappable.set_norm`` instead)
62+
63+
- ``dates.seconds()`` (no replacement)
64+
- ``dates.minutes()`` (no replacement)
65+
- ``dates.hours()`` (no replacement)
66+
- ``dates.weeks()`` (no replacement)
67+
- ``dates.strpdate2num`` and ``dates.bytespdate2num`` (use `time.strptime` or
68+
`dateutil.parser.parse` or `.dates.datestr2num` instead)
69+
4970
- ``docstring.Appender`` (no replacement)
5071
- ``docstring.dedent()`` (use `inspect.getdoc` instead)
5172
- ``docstring.copy_dedent()``
5273
(use ``docstring.copy()`` and `inspect.getdoc` instead)
5374

75+
- ``font_manager.OSXInstalledFonts()`` (no replacement)
76+
77+
- ``image.BboxImage.interp_at_native`` property (no replacement)
78+
79+
- ``lines.Line2D.verticalOffset`` property (no replacement)
80+
5481
- ``matplotlib.checkdep_dvipng`` (no replacement)
5582
- ``matplotlib.checkdep_ghostscript`` (no replacement)
5683
- ``matplotlib.checkdep_pdftops`` (no replacement)
5784
- ``matplotlib.checkdep_inkscape`` (no replacement)
5885
- ``matplotlib.get_py2exe_datafiles`` (no replacement)
5986
- ``matplotlib.tk_window_focus`` (use ``rcParams['tk.window_focus']`` instead)
6087

88+
- ``mlab.demean()`` (use ``mlab.detrend_mean()`` instead)
89+
90+
- ``path.get_paths_extents()``
91+
(use ``path.get_path_collection_extents()`` instead)
92+
- ``path.Path.has_nonfinite()`` (use ``not np.isfinite(self.vertices).all()``
93+
instead)
94+
95+
- ``projections.process_projection_requirements()`` (no replacement)
96+
6197
- ``pyplot.plotfile()`` (Instead, load the data using
6298
`pandas.read_csv` or `numpy.loadtxt` or similar and use regular pyplot
6399
functions to plot the loaded data.)
100+
101+
- ``quiver.Quiver.color()`` (use ``Quiver.get_facecolor()`` instead)
102+
- ``quiver.Quiver.keyvec`` property (no replacement)
103+
- ``quiver.Quiver.keytext`` property (no replacement)
104+
64105
- ``rcsetup.validate_qt4()`` (no replacement)
65106
- ``rcsetup.validate_qt5()`` (no replacement)
66107
- ``rcsetup.validate_verbose()`` (no replacement)
67108
- ``rcsetup.ValidateInterval`` (no replacement)
68109

69-
- ``sphinxext.plot_directive.plot_directive()``
70-
(use the class ``PlotDirective`` instead)
71-
- ``sphinxext.mathmpl.math_directive()``
72-
(use the class ``MathDirective`` instead)
73-
74110
- ``scale.LogTransformBase`` (use ``scale.LogTransform`` instead)
75111
- ``scale.InvertedLogTransformBase`` (use ``scale.InvertedLogTransform`` instead)
76112
- ``scale.Log10Transform`` (use ``scale.LogTransform`` instead)
@@ -79,15 +115,27 @@ Classes, methods and attributes
79115
- ``scale.InvertedLog2Transform`` (use ``scale.InvertedLogTransform`` instead)
80116
- ``scale.NaturalLogTransform`` (use ``scale.LogTransform`` instead)
81117
- ``scale.InvertedNaturalLogTransform`` (use ``scale.InvertedLogTransform`` instead)
118+
- ``scale.get_scale_docs()`` (no replacement)
119+
120+
- ``sphinxext.plot_directive.plot_directive()``
121+
(use the class ``PlotDirective`` instead)
122+
- ``sphinxext.mathmpl.math_directive()``
123+
(use the class ``MathDirective`` instead)
82124

83125
- ``spines.Spine.is_frame_like()`` (no replacement)
84126

127+
- ``testing.decorators.switch_backend()`` (use ``@pytest.mark.backend``
128+
decorator instead)
129+
85130
- ``text.Text.is_math_text()`` (use ``cbook.is_math_text()`` instead)
86131
- ``text.TextWithDash()`` (use ``text.Annotation`` instead)
87132
- ``textpath.TextPath.is_math_text()`` (use ``cbook.is_math_text()`` instead)
88133
- ``textpath.TextPath.text_get_vertices_codes()``
89134
(use ``textpath.text_to_path.get_text_path()`` instead)
90135

136+
- ``textpath.TextToPath.glyph_to_path()`` (use ``font.get_path()`` and manual
137+
translation of the vertices instead)
138+
91139
- ``ticker.OldScalarFormatter.pprint_val()`` (no replacement)
92140
- ``ticker.ScalarFormatter.pprint_val()`` (no replacement)
93141
- ``ticker.LogFormatter.pprint_val()`` (no replacement)
@@ -98,38 +146,7 @@ Classes, methods and attributes
98146
``Tick.tick1line``, ``Tick.tick2line``, ``Tick.label1``, ``Tick.label2``
99147
instead)
100148

101-
- ``Artist.aname`` property (no replacement)
102-
- ``Axis.iter_ticks`` (no replacement)
103-
104-
- ``image.BboxImage.interp_at_native`` property (no replacement)
105-
- ``lines.Line2D.verticalOffset`` property (no replacement)
106-
- ``bezier.find_r_to_boundary_of_closedpath()`` (no replacement)
107-
108-
- ``quiver.Quiver.color()`` (use ``Quiver.get_facecolor()`` instead)
109-
- ``quiver.Quiver.keyvec`` property (no replacement)
110-
- ``quiver.Quiver.keytext`` property (no replacement)
111-
112-
- ``colorbar.ColorbarBase.get_cmap`` (use ``ScalarMappable.get_cmap`` instead)
113-
- ``colorbar.ColorbarBase.set_cmap`` (use ``ScalarMappable.set_cmap`` instead)
114-
- ``colorbar.ColorbarBase.get_clim`` (use ``ScalarMappable.get_clim`` instead)
115-
- ``colorbar.ColorbarBase.set_clim`` (use ``ScalarMappable.set_clim`` instead)
116-
- ``colorbar.ColorbarBase.set_norm`` (use ``ScalarMappable.set_norm`` instead)
117-
118-
- ``dates.seconds()`` (no replacement)
119-
- ``dates.minutes()`` (no replacement)
120-
- ``dates.hours()`` (no replacement)
121-
- ``dates.weeks()`` (no replacement)
122-
- ``dates.strpdate2num`` and ``dates.bytespdate2num`` (use `time.strptime` or
123-
`dateutil.parser.parse` or `.dates.datestr2num` instead)
124-
125-
- ``font_manager.OSXInstalledFonts()`` (no replacement)
126-
127-
- ``mlab.demean()`` (use ``mlab.detrend_mean()`` instead)
128-
129-
- ``projections.process_projection_requirements()`` (no replacement)
130-
131-
- ``path.get_paths_extents()``
132-
(use ``path.get_path_collection_extents()`` instead)
149+
- ``widgets.SpanSelector.buttonDown`` property (no replacement)
133150

134151
- ``mplot3d.proj3d.line2d()`` (no replacement)
135152
- ``mplot3d.proj3d.line2d_dist()`` (no replacement)
@@ -159,8 +176,6 @@ Classes, methods and attributes
159176
- ``axisartist.axislines.Axes.AxisDict``
160177
(use ``axis_grid1.mpl_axes.Axes.AxisDict`` instead)
161178

162-
- ``widgets.SpanSelector.buttonDown`` property (no replacement)
163-
164179
Arguments
165180
~~~~~~~~~
166181
- ``Axes.text()`` / ``pyplot.text()`` do not support the parameter ``withdash``
@@ -176,7 +191,8 @@ Arguments
176191
- The unused parameter ``interp_at_native`` of `.BboxImage` has been removed.
177192
- The parameter ``usetex`` of `.TextToPath.get_text_path` has been removed.
178193
Use ``ismath='TeX'`` instead.
179-
- The parameter ``block`` of ``show()`` is now keyword-only.
194+
- The parameter ``block`` of ``show()`` is now keyword-only, and arbitrary
195+
arguments or keyword arguments are no longer accepted.
180196
- The parameter ``frameon`` of `.Figure.savefig` has been removed. Use
181197
``facecolor="none"`` to get a transparent background.
182198
- Passing a ``wx.EvtHandler`` as the first argument to ``backend_wx.TimerWx``
@@ -195,6 +211,18 @@ Arguments
195211
other than ``ticklabels``.
196212
- ``mpl_toolkits.mplot3d.art3d.Poly3DCollection.set_zsort`` does not accept
197213
the value ``True`` anymore. Pass the equivalent value 'average' instead.
214+
- `.AnchoredText` no longer accepts ``horizontalalignment`` or
215+
``verticalalignment`` keyword arguments.
216+
- `.ConnectionPatch` no longer accepts the ``arrow_transmuter`` and
217+
``connector`` keyword arguments, which did nothing since 3.0.
218+
- `.FancyArrowPatch` no longer accepts the ``arrow_transmuter`` and
219+
``connector`` keyword arguments, which did nothing since 3.0.
220+
- `.TextPath` no longer accepts arbitrary positional or keyword arguments.
221+
- `.MaxNLocator.set_params()` no longer accepts arbitrary keyword arguments.
222+
- `~.Axes.pie` no longer accepts and squeezes non-1D inputs; pass 1D input to
223+
the ``x`` argument.
224+
- Passing (n, 1)-shaped error arrays to `.Axes.errorbar()` is no longer
225+
supported; pass a 1D array instead.
198226

199227
rcParams
200228
~~~~~~~~

doc/api/prev_api_changes/api_changes_3.1.0.rst

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -849,8 +849,8 @@ Use the standard library's docstring manipulation tools instead, such as
849849

850850

851851

852-
- `matplotlib.scale.get_scale_docs()`
853-
- `matplotlib.pyplot.get_scale_docs()`
852+
- ``matplotlib.scale.get_scale_docs()``
853+
- ``matplotlib.pyplot.get_scale_docs()``
854854

855855
These are considered internal and will be removed from the public API in a
856856
future version.
@@ -905,7 +905,8 @@ Font Handling
905905
- ``backend_pdf.RendererPdf.afm_font_cache``
906906
- ``backend_ps.RendererPS.afmfontd``
907907
- ``font_manager.OSXInstalledFonts``
908-
- `.TextToPath.glyph_to_path` (Instead call ``font.get_path()`` and manually transform the path.)
908+
- ``.TextToPath.glyph_to_path`` (Instead call ``font.get_path()`` and manually
909+
transform the path.)
909910

910911

911912
Date related functions
@@ -1011,7 +1012,7 @@ Path tools
10111012

10121013
Use `~.path.get_path_collection_extents` instead.
10131014

1014-
- `.Path.has_nonfinite` attribute
1015+
- ``.Path.has_nonfinite`` attribute
10151016

10161017
Use ``not np.isfinite(path.vertices).all()`` instead.
10171018

doc/missing-references.json

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1369,9 +1369,6 @@
13691369
"matplotlib.patches.Patch.__init__": [
13701370
"doc/devel/documenting_mpl.rst:696"
13711371
],
1372-
"matplotlib.pyplot.get_scale_docs()": [
1373-
"doc/api/prev_api_changes/api_changes_3.1.0.rst:853"
1374-
],
13751372
"matplotlib.sphinxext.mathmpl": [
13761373
"doc/users/prev_whats_new/whats_new_3.0.rst:225"
13771374
],
@@ -1543,4 +1540,4 @@
15431540
"lib/mpl_toolkits/mplot3d/axes3d.py:docstring of mpl_toolkits.mplot3d.axes3d.Axes3D.get_ylim3d:24"
15441541
]
15451542
}
1546-
}
1543+
}

lib/matplotlib/axes/_axes.py

Lines changed: 8 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -2915,7 +2915,7 @@ def pie(self, x, explode=None, labels=None, colors=None,
29152915
29162916
Parameters
29172917
----------
2918-
x : array-like
2918+
x : 1D array-like
29192919
The wedge sizes.
29202920
29212921
explode : array-like, default: None
@@ -2999,12 +2999,8 @@ def pie(self, x, explode=None, labels=None, colors=None,
29992999
# The use of float32 is "historical", but can't be changed without
30003000
# regenerating the test baselines.
30013001
x = np.asarray(x, np.float32)
3002-
if x.ndim != 1 and x.squeeze().ndim <= 1:
3003-
cbook.warn_deprecated(
3004-
"3.1", message="Non-1D inputs to pie() are currently "
3005-
"squeeze()d, but this behavior is deprecated since %(since)s "
3006-
"and will be removed %(removal)s; pass a 1D array instead.")
3007-
x = np.atleast_1d(x.squeeze())
3002+
if x.ndim > 1:
3003+
raise ValueError("x must be 1D")
30083004

30093005
if np.any(x < 0):
30103006
raise ValueError("Wedge sizes 'x' must be non negative values")
@@ -3372,7 +3368,7 @@ def xywhere(xs, ys, mask):
33723368
ys = [thisy for thisy, b in zip(ys, mask) if b]
33733369
return xs, ys
33743370

3375-
def extract_err(err, data):
3371+
def extract_err(name, err, data):
33763372
"""
33773373
Private function to parse *err* and subtract/add it to *data*.
33783374
@@ -3384,20 +3380,9 @@ def extract_err(err, data):
33843380
iter(b)
33853381
except (TypeError, ValueError):
33863382
a = b = err # Symmetric error: 1D iterable.
3387-
# This could just be `np.ndim(a) > 1 and np.ndim(b) > 1`, except
3388-
# for the (undocumented, but tested) support for (n, 1) arrays.
3389-
a_sh = np.shape(a)
3390-
b_sh = np.shape(b)
3391-
if (len(a_sh) > 2 or (len(a_sh) == 2 and a_sh[1] != 1)
3392-
or len(b_sh) > 2 or (len(b_sh) == 2 and b_sh[1] != 1)):
3383+
if np.ndim(a) > 1 or np.ndim(b) > 1:
33933384
raise ValueError(
3394-
"err must be a scalar or a 1D or (2, n) array-like")
3395-
if len(a_sh) == 2 or len(b_sh) == 2:
3396-
cbook.warn_deprecated(
3397-
"3.1", message="Support for passing a (n, 1)-shaped error "
3398-
"array to errorbar() is deprecated since Matplotlib "
3399-
"%(since)s and will be removed %(removal)s; pass a 1D "
3400-
"array instead.")
3385+
f"{name}err must be a scalar or a 1D or (2, n) array-like")
34013386
# Using list comprehensions rather than arrays to preserve units.
34023387
for e in [a, b]:
34033388
if len(data) != len(e):
@@ -3409,7 +3394,7 @@ def extract_err(err, data):
34093394
return low, high
34103395

34113396
if xerr is not None:
3412-
left, right = extract_err(xerr, x)
3397+
left, right = extract_err('x', xerr, x)
34133398
# select points without upper/lower limits in x and
34143399
# draw normal errorbars for these points
34153400
noxlims = ~(xlolims | xuplims)
@@ -3458,7 +3443,7 @@ def extract_err(err, data):
34583443
**eb_cap_style))
34593444

34603445
if yerr is not None:
3461-
lower, upper = extract_err(yerr, y)
3446+
lower, upper = extract_err('y', yerr, y)
34623447
# select points without upper/lower limits in y and
34633448
# draw normal errorbars for these points
34643449
noylims = ~(lolims | uplims)

lib/matplotlib/backends/backend_nbagg.py

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -239,13 +239,7 @@ def trigger_manager_draw(manager):
239239
manager.show()
240240

241241
@staticmethod
242-
def show(*args, block=None, **kwargs):
243-
if args or kwargs:
244-
cbook.warn_deprecated(
245-
"3.1", message="Passing arguments to show(), other than "
246-
"passing 'block' by keyword, is deprecated %(since)s, and "
247-
"support for it will be removed %(removal)s.")
248-
242+
def show(block=None):
249243
## TODO: something to do when keyword block==False ?
250244
from matplotlib._pylab_helpers import Gcf
251245

lib/matplotlib/collections.py

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -304,14 +304,7 @@ def draw(self, renderer):
304304

305305
if self._hatch:
306306
gc.set_hatch(self._hatch)
307-
try:
308-
gc.set_hatch_color(self._hatch_color)
309-
except AttributeError:
310-
# if we end up with a GC that does not have this method
311-
cbook.warn_deprecated(
312-
"3.1", message="Your backend does not support setting the "
313-
"hatch color; such backends will become unsupported in "
314-
"Matplotlib 3.3.")
307+
gc.set_hatch_color(self._hatch_color)
315308

316309
if self.get_sketch_params() is not None:
317310
gc.set_sketch_params(*self.get_sketch_params())

lib/matplotlib/colors.py

Lines changed: 5 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -198,17 +198,11 @@ def _to_rgba_no_colorcycle(c, alpha=None):
198198
# This may turn c into a non-string, so we check again below.
199199
c = _colors_full_map[c]
200200
except KeyError:
201-
try:
202-
c = _colors_full_map[c.lower()]
203-
except KeyError:
204-
pass
205-
else:
206-
if len(orig_c) == 1:
207-
cbook.warn_deprecated(
208-
"3.1", message="Support for uppercase "
209-
"single-letter colors is deprecated since Matplotlib "
210-
"%(since)s and will be removed %(removal)s; please "
211-
"use lowercase instead.")
201+
if len(orig_c) != 1:
202+
try:
203+
c = _colors_full_map[c.lower()]
204+
except KeyError:
205+
pass
212206
if isinstance(c, str):
213207
# hex color in #rrggbb format.
214208
match = re.match(r"\A#[a-fA-F0-9]{6}\Z", c)

0 commit comments

Comments
 (0)