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

Skip to content

Commit 03a3d21

Browse files
authored
Merge pull request #18753 from QuLogic/remove-deprecations
API: Remove several more deprecations
2 parents e03d956 + b1100ab commit 03a3d21

31 files changed

+114
-1116
lines changed

doc/api/axes_api.rst

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -587,7 +587,6 @@ non-rectilinear Axes.
587587
Axes.get_xaxis_transform
588588
Axes.get_yaxis_transform
589589
Axes.get_data_ratio
590-
Axes.get_data_ratio_log
591590

592591
Axes.get_xaxis_text1_transform
593592
Axes.get_xaxis_text2_transform

doc/api/axis_api.rst

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -226,8 +226,6 @@ Other
226226
Axis.limit_range_for_scale
227227
Axis.reset_ticks
228228
Axis.set_default_intervals
229-
Axis.get_smart_bounds
230-
Axis.set_smart_bounds
231229

232230
Discouraged
233231
-----------
Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
``Axes`` methods and properties
2+
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
3+
4+
- ``axes.Axes.get_data_ratio_log``
5+
- ``axes.SubplotBase.rowNum``; use ``ax.get_subplotspec().rowspan.start``
6+
instead
7+
- ``axes.SubplotBase.colNum``; use ``ax.get_subplotspec().colspan.start``
8+
instead
9+
- the *verts* parameter to ``scatter`` (use *marker* instead)
10+
- Passing more than one positional argument to `~matplotlib.axes.Axes.axis`
11+
will now raise an error.
12+
- Passing ``"range"`` to the *whis* parameter of `.Axes.boxplot` and
13+
`.cbook.boxplot_stats` to mean "the whole data range" is no longer
14+
supported.
15+
- Passing scalars to parameter *where* in `.axes.Axes.fill_between` and
16+
`.axes.Axes.fill_betweenx` is no longer accepted and non-matching sizes now
17+
raise a `ValueError`.
18+
19+
``dates`` functions
20+
~~~~~~~~~~~~~~~~~~~
21+
- ``dates.mx2num``
22+
23+
``quiver`` methods
24+
~~~~~~~~~~~~~~~~~~
25+
26+
- ``quiver.QuiverKey.quiverkey_doc`` has been removed; use
27+
``quiver.QuiverKey.__init__.__doc__`` instead.
28+
29+
Smart bounds
30+
~~~~~~~~~~~~
31+
32+
The "smart bounds" functionality on `~.axis.Axis` and `.Spine` has been
33+
deleted, and the following methods are removed:
34+
35+
- ``Axis.set_smart_bounds`` and ``Axis.get_smart_bounds``
36+
- ``Spine.set_smart_bounds`` and ``Spine.get_smart_bounds``
37+
38+
Testing
39+
~~~~~~~
40+
The *switch_backend_warn* parameter to ``matplotlib.test`` has no effect and
41+
has been removed.
42+
43+
``tight_layout()``
44+
~~~~~~~~~~~~~~~~~~
45+
The *renderer* parameter to `.Figure.tight_layout` has been removed; this
46+
method now always uses the renderer instance cached on the `.Figure`.
47+
48+
``axes_grid1``
49+
~~~~~~~~~~~~~~
50+
The ``mpl_toolkits.axes_grid1.colorbar`` module and its colorbar implementation
51+
have been removed in favor of :mod:`matplotlib.colorbar`. Additionally:
52+
53+
- The *locator* parameter to ``colorbar()`` has been removed in favor of its
54+
synonym *ticks* (which already existed previously, and is consistent with
55+
:mod:`matplotlib.colorbar`).
56+
- The ``mpl_toolkits.legacy_colorbar`` rcParam has no effect and also has been
57+
removed.

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

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -142,6 +142,11 @@ Passing scalars to parameter *where* in ``fill_between()`` and
142142
broadcasted to the size of *x*. Non-matching sizes will raise a ``ValueError``
143143
in the future.
144144

145+
``scatter()``
146+
~~~~~~~~~~~~~
147+
Passing the *verts* parameter to `.axes.Axes.scatter` is deprecated; use the
148+
*marker* parameter instead.
149+
145150
``tight_layout()``
146151
~~~~~~~~~~~~~~~~~~
147152
The ``renderer`` parameter to `.Figure.tight_layout` is deprecated; this method
@@ -255,8 +260,8 @@ both 1) matplotlib's conftests have not been called and 2) nose is in
255260
During the deprecation period, to force the generation of nose base tests,
256261
import nose first.
257262

258-
The ``switch_backend_warn`` parameter to ``matplotlib.test`` has no effect and
259-
is deprecated.
263+
The *switch_backend_warn* parameter to ``matplotlib.test`` has no effect and is
264+
deprecated.
260265

261266
``testing.jpl_units.UnitDbl.UnitDbl.checkUnits`` is deprecated.
262267

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

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -57,8 +57,7 @@ The following API elements have been removed:
5757
instead)
5858
- ``axisartist.axes_divider.Axes``, ``axisartist.axes_divider.LocatableAxes``
5959
(use ``axisartist.axislines.Axes`` instead)
60-
- the ``normed`` kwarg to ``hist`` (use ``density`` instead)
61-
- the ``verts`` parameter to ``scatter`` (use ``marker`` instead)
60+
- the *normed* keyword argument to ``hist`` (use *density* instead)
6261
- passing ``(verts, 0)`` or ``(..., 3)`` when specifying a marker to specify a
6362
path or a circle, respectively (instead, use ``verts`` or ``"o"``,
6463
respectively)

doc/api/toolkits/axes_grid1.rst

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,6 @@ See :ref:`axes_grid1_users-guide-index` for a guide on the usage of axes_grid1.
2929
axes_grid1.axes_grid
3030
axes_grid1.axes_rgb
3131
axes_grid1.axes_size
32-
axes_grid1.colorbar
3332
axes_grid1.inset_locator
3433
axes_grid1.mpl_axes
3534
axes_grid1.parasite_axes

doc/missing-references.json

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -191,9 +191,6 @@
191191
"backend_qt5.FigureCanvasQTAgg": [
192192
"doc/api/prev_api_changes/api_changes_2.2.0.rst:210"
193193
],
194-
"datetime": [
195-
"lib/matplotlib/dates.py:docstring of matplotlib.dates.mx2num:2"
196-
],
197194
"dateutil.rrule.rrulebase": [
198195
"<external>/rrule.py:docstring of matplotlib.dates.rrule:1"
199196
],

examples/axes_grid1/demo_axes_grid.py

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,6 @@
1111
from mpl_toolkits.axes_grid1 import ImageGrid
1212

1313

14-
plt.rcParams["mpl_toolkits.legacy_colorbar"] = False
15-
16-
1714
def get_demo_image():
1815
z = cbook.get_sample_data("axes_grid/bivariate_normal.npy", np_load=True)
1916
# z is a numpy array of 15x15

examples/axes_grid1/demo_axes_grid2.py

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,6 @@
1313
from mpl_toolkits.axes_grid1 import ImageGrid
1414

1515

16-
plt.rcParams["mpl_toolkits.legacy_colorbar"] = False
17-
18-
1916
def add_inner_title(ax, title, loc, **kwargs):
2017
from matplotlib.offsetbox import AnchoredText
2118
from matplotlib.patheffects import withStroke

examples/axes_grid1/demo_edge_colorbar.py

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,6 @@
1212
from mpl_toolkits.axes_grid1 import AxesGrid
1313

1414

15-
plt.rcParams["mpl_toolkits.legacy_colorbar"] = False
16-
17-
1815
def get_demo_image():
1916
z = cbook.get_sample_data("axes_grid/bivariate_normal.npy", np_load=True)
2017
# z is a numpy array of 15x15

lib/matplotlib/__init__.py

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -569,6 +569,7 @@ def gen_candidates():
569569
# rcParams deprecated; some can manually be mapped to another key.
570570
# Values are tuples of (version, new_name_or_None).
571571
_deprecated_ignore_map = {
572+
'mpl_toolkits.legacy_colorbar': ('3.4', None),
572573
}
573574

574575
# rcParams deprecated; can use None to suppress warnings; remain actually
@@ -811,7 +812,7 @@ def _rc_params_in_file(fname, transform=lambda x: x, fail_on_error=False):
811812
elif key in _deprecated_ignore_map:
812813
version, alt_key = _deprecated_ignore_map[key]
813814
cbook.warn_deprecated(
814-
version, name=key, alternative=alt_key,
815+
version, name=key, alternative=alt_key, obj_type='rcparam',
815816
addendum="Please update your matplotlibrc.")
816817
else:
817818
version = 'master' if '.post' in __version__ else f'v{__version__}'
@@ -1193,10 +1194,8 @@ def _init_tests():
11931194
"" if ft2font.__freetype_build_type__ == 'local' else "not "))
11941195

11951196

1196-
@cbook._delete_parameter("3.2", "switch_backend_warn")
11971197
@cbook._delete_parameter("3.3", "recursionlimit")
1198-
def test(verbosity=None, coverage=False, switch_backend_warn=True,
1199-
recursionlimit=0, **kwargs):
1198+
def test(verbosity=None, coverage=False, *, recursionlimit=0, **kwargs):
12001199
"""Run the matplotlib test suite."""
12011200

12021201
try:

lib/matplotlib/axes/_axes.py

Lines changed: 4 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -3463,7 +3463,6 @@ def boxplot(self, x, notch=None, sym=None, vert=None, whis=None,
34633463
If a pair of floats, they indicate the percentiles at which to
34643464
draw the whiskers (e.g., (5, 95)). In particular, setting this to
34653465
(0, 100) results in whiskers covering the whole range of the data.
3466-
"range" is a deprecated synonym for (0, 100).
34673466
34683467
In the edge case where ``Q1 == Q3``, *whis* is automatically set
34693468
to (0, 100) (cover the whole range of the data) if *autorange* is
@@ -4215,11 +4214,9 @@ def invalid_shape_exception(csize, xsize):
42154214
"edgecolors", "c", "facecolor",
42164215
"facecolors", "color"],
42174216
label_namer="y")
4218-
@cbook._delete_parameter("3.2", "verts")
42194217
def scatter(self, x, y, s=None, c=None, marker=None, cmap=None, norm=None,
4220-
vmin=None, vmax=None, alpha=None, linewidths=None,
4221-
verts=None, edgecolors=None, *, plotnonfinite=False,
4222-
**kwargs):
4218+
vmin=None, vmax=None, alpha=None, linewidths=None, *,
4219+
edgecolors=None, plotnonfinite=False, **kwargs):
42234220
"""
42244221
A scatter plot of *y* vs. *x* with varying marker size and/or color.
42254222
@@ -5088,7 +5085,6 @@ def _fill_between_x_or_y(
50885085
"""
50895086

50905087
dep_dir = {"x": "y", "y": "x"}[ind_dir]
5091-
func_name = {"x": "fill_between", "y": "fill_betweenx"}[dep_dir]
50925088

50935089
if not rcParams["_internal.classic_mode"]:
50945090
kwargs = cbook.normalize_kwargs(kwargs, mcoll.Collection)
@@ -5111,10 +5107,8 @@ def _fill_between_x_or_y(
51115107
else:
51125108
where = np.asarray(where, dtype=bool)
51135109
if where.size != ind.size:
5114-
cbook.warn_deprecated(
5115-
"3.2", message=f"Since %(since)s, the parameter *where* "
5116-
f"must have the same size as {ind} in {func_name}(). This "
5117-
"will become an error %(removal)s.")
5110+
raise ValueError(f"where size ({where.size}) does not match "
5111+
f"{ind_dir} size ({ind.size})")
51185112
where = where & ~functools.reduce(
51195113
np.logical_or, map(np.ma.getmask, [ind, dep1, dep2]))
51205114

lib/matplotlib/axes/_base.py

Lines changed: 5 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
import inspect
44
import itertools
55
import logging
6-
import math
76
from numbers import Real
87
from operator import attrgetter
98
import types
@@ -1602,23 +1601,6 @@ def get_data_ratio(self):
16021601
ysize = max(abs(tymax - tymin), 1e-30)
16031602
return ysize / xsize
16041603

1605-
@_api.deprecated("3.2")
1606-
def get_data_ratio_log(self):
1607-
"""
1608-
Return the aspect ratio of the raw data in log scale.
1609-
1610-
Notes
1611-
-----
1612-
Will be used when both axis are in log scale.
1613-
"""
1614-
xmin, xmax = self.get_xbound()
1615-
ymin, ymax = self.get_ybound()
1616-
1617-
xsize = max(abs(math.log10(xmax) - math.log10(xmin)), 1e-30)
1618-
ysize = max(abs(math.log10(ymax) - math.log10(ymin)), 1e-30)
1619-
1620-
return ysize / xsize
1621-
16221604
def apply_aspect(self, position=None):
16231605
"""
16241606
Adjust the Axes for a specified data aspect ratio.
@@ -1799,7 +1781,10 @@ def axis(self, *args, emit=True, **kwargs):
17991781
matplotlib.axes.Axes.set_xlim
18001782
matplotlib.axes.Axes.set_ylim
18011783
"""
1802-
if len(args) == 1 and isinstance(args[0], (str, bool)):
1784+
if len(args) > 1:
1785+
raise TypeError("axis() takes 0 or 1 positional arguments but "
1786+
f"{len(args)} were given")
1787+
elif len(args) == 1 and isinstance(args[0], (str, bool)):
18031788
s = args[0]
18041789
if s is True:
18051790
s = 'on'
@@ -1841,12 +1826,7 @@ def axis(self, *args, emit=True, **kwargs):
18411826
raise ValueError('Unrecognized string %s to axis; '
18421827
'try on or off' % s)
18431828
else:
1844-
if len(args) >= 1:
1845-
if len(args) != 1:
1846-
cbook.warn_deprecated(
1847-
"3.2", message="Passing more than one positional "
1848-
"argument to axis() is deprecated and will raise a "
1849-
"TypeError %(removal)s.")
1829+
if len(args) == 1:
18501830
limits = args[0]
18511831
try:
18521832
xmin, xmax, ymin, ymax = limits

lib/matplotlib/axes/_subplots.py

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -98,16 +98,6 @@ def update_params(self):
9898
# Now a no-op, as figbox/numRows/numCols are (deprecated) auto-updating
9999
# properties.
100100

101-
@_api.deprecated("3.2", alternative="ax.get_subplotspec().rowspan.start")
102-
@property
103-
def rowNum(self):
104-
return self.get_subplotspec().rowspan.start
105-
106-
@_api.deprecated("3.2", alternative="ax.get_subplotspec().colspan.start")
107-
@property
108-
def colNum(self):
109-
return self.get_subplotspec().colspan.start
110-
111101
@_api.deprecated("3.4", alternative="ax.get_subplotspec().is_first_row()")
112102
def is_first_row(self):
113103
return self.get_subplotspec().rowspan.start == 0

lib/matplotlib/axis.py

Lines changed: 0 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -673,7 +673,6 @@ def __init__(self, axes, pickradius=15):
673673
self.callbacks = cbook.CallbackRegistry()
674674

675675
self._autolabelpos = True
676-
self._smart_bounds = False # Deprecated in 3.2
677676

678677
self.label = mtext.Text(
679678
np.nan, np.nan,
@@ -1010,17 +1009,6 @@ def get_ticklabel_extents(self, renderer):
10101009
bbox2 = mtransforms.Bbox.from_extents(0, 0, 0, 0)
10111010
return bbox, bbox2
10121011

1013-
@_api.deprecated("3.2")
1014-
def set_smart_bounds(self, value):
1015-
"""Set the axis to have smart bounds."""
1016-
self._smart_bounds = value
1017-
self.stale = True
1018-
1019-
@_api.deprecated("3.2")
1020-
def get_smart_bounds(self):
1021-
"""Return whether the axis has smart bounds."""
1022-
return self._smart_bounds
1023-
10241012
def _update_ticks(self):
10251013
"""
10261014
Update ticks (position and labels) using the current data interval of
@@ -1048,36 +1036,6 @@ def _update_ticks(self):
10481036
if view_low > view_high:
10491037
view_low, view_high = view_high, view_low
10501038

1051-
if self._smart_bounds and ticks: # _smart_bounds is deprecated in 3.2
1052-
# handle inverted limits
1053-
data_low, data_high = sorted(self.get_data_interval())
1054-
locs = np.sort([tick.get_loc() for tick in ticks])
1055-
if data_low <= view_low:
1056-
# data extends beyond view, take view as limit
1057-
ilow = view_low
1058-
else:
1059-
# data stops within view, take best tick
1060-
good_locs = locs[locs <= data_low]
1061-
if len(good_locs):
1062-
# last tick prior or equal to first data point
1063-
ilow = good_locs[-1]
1064-
else:
1065-
# No ticks (why not?), take first tick
1066-
ilow = locs[0]
1067-
if data_high >= view_high:
1068-
# data extends beyond view, take view as limit
1069-
ihigh = view_high
1070-
else:
1071-
# data stops within view, take best tick
1072-
good_locs = locs[locs >= data_high]
1073-
if len(good_locs):
1074-
# first tick after or equal to last data point
1075-
ihigh = good_locs[0]
1076-
else:
1077-
# No ticks (why not?), take last tick
1078-
ihigh = locs[-1]
1079-
ticks = [tick for tick in ticks if ilow <= tick.get_loc() <= ihigh]
1080-
10811039
interval_t = self.get_transform().transform([view_low, view_high])
10821040

10831041
ticks_to_draw = []

0 commit comments

Comments
 (0)