Skip to content

Remove several more deprecations #18753

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 5 commits into from
Dec 16, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion doc/api/axes_api.rst
Original file line number Diff line number Diff line change
Expand Up @@ -587,7 +587,6 @@ non-rectilinear Axes.
Axes.get_xaxis_transform
Axes.get_yaxis_transform
Axes.get_data_ratio
Axes.get_data_ratio_log

Axes.get_xaxis_text1_transform
Axes.get_xaxis_text2_transform
Expand Down
2 changes: 0 additions & 2 deletions doc/api/axis_api.rst
Original file line number Diff line number Diff line change
Expand Up @@ -226,8 +226,6 @@ Other
Axis.limit_range_for_scale
Axis.reset_ticks
Axis.set_default_intervals
Axis.get_smart_bounds
Axis.set_smart_bounds

Discouraged
-----------
Expand Down
57 changes: 57 additions & 0 deletions doc/api/next_api_changes/removals/18747-ES.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
``Axes`` methods and properties
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

- ``axes.Axes.get_data_ratio_log``
- ``axes.SubplotBase.rowNum``; use ``ax.get_subplotspec().rowspan.start``
instead
- ``axes.SubplotBase.colNum``; use ``ax.get_subplotspec().colspan.start``
instead
- the *verts* parameter to ``scatter`` (use *marker* instead)
- Passing more than one positional argument to `~matplotlib.axes.Axes.axis`
will now raise an error.
- Passing ``"range"`` to the *whis* parameter of `.Axes.boxplot` and
`.cbook.boxplot_stats` to mean "the whole data range" is no longer
supported.
- Passing scalars to parameter *where* in `.axes.Axes.fill_between` and
`.axes.Axes.fill_betweenx` is no longer accepted and non-matching sizes now
raise a `ValueError`.

``dates`` functions
~~~~~~~~~~~~~~~~~~~
- ``dates.mx2num``

``quiver`` methods
~~~~~~~~~~~~~~~~~~

- ``quiver.QuiverKey.quiverkey_doc`` has been removed; use
``quiver.QuiverKey.__init__.__doc__`` instead.

Smart bounds
~~~~~~~~~~~~

The "smart bounds" functionality on `~.axis.Axis` and `.Spine` has been
deleted, and the following methods are removed:

- ``Axis.set_smart_bounds`` and ``Axis.get_smart_bounds``
- ``Spine.set_smart_bounds`` and ``Spine.get_smart_bounds``

Testing
~~~~~~~
The *switch_backend_warn* parameter to ``matplotlib.test`` has no effect and
has been removed.

``tight_layout()``
~~~~~~~~~~~~~~~~~~
The *renderer* parameter to `.Figure.tight_layout` has been removed; this
method now always uses the renderer instance cached on the `.Figure`.

``axes_grid1``
~~~~~~~~~~~~~~
The ``mpl_toolkits.axes_grid1.colorbar`` module and its colorbar implementation
have been removed in favor of :mod:`matplotlib.colorbar`. Additionally:

- The *locator* parameter to ``colorbar()`` has been removed in favor of its
synonym *ticks* (which already existed previously, and is consistent with
:mod:`matplotlib.colorbar`).
- The ``mpl_toolkits.legacy_colorbar`` rcParam has no effect and also has been
removed.
9 changes: 7 additions & 2 deletions doc/api/prev_api_changes/api_changes_3.2.0/deprecations.rst
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,11 @@ Passing scalars to parameter *where* in ``fill_between()`` and
broadcasted to the size of *x*. Non-matching sizes will raise a ``ValueError``
in the future.

``scatter()``
~~~~~~~~~~~~~
Passing the *verts* parameter to `.axes.Axes.scatter` is deprecated; use the
*marker* parameter instead.

``tight_layout()``
~~~~~~~~~~~~~~~~~~
The ``renderer`` parameter to `.Figure.tight_layout` is deprecated; this method
Expand Down Expand Up @@ -255,8 +260,8 @@ both 1) matplotlib's conftests have not been called and 2) nose is in
During the deprecation period, to force the generation of nose base tests,
import nose first.

The ``switch_backend_warn`` parameter to ``matplotlib.test`` has no effect and
is deprecated.
The *switch_backend_warn* parameter to ``matplotlib.test`` has no effect and is
deprecated.

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

Expand Down
3 changes: 1 addition & 2 deletions doc/api/prev_api_changes/api_changes_3.2.0/removals.rst
Original file line number Diff line number Diff line change
Expand Up @@ -57,8 +57,7 @@ The following API elements have been removed:
instead)
- ``axisartist.axes_divider.Axes``, ``axisartist.axes_divider.LocatableAxes``
(use ``axisartist.axislines.Axes`` instead)
- the ``normed`` kwarg to ``hist`` (use ``density`` instead)
- the ``verts`` parameter to ``scatter`` (use ``marker`` instead)
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Note, this was incorrectly documented as removed, but it was only deprecated.

- the *normed* keyword argument to ``hist`` (use *density* instead)
- passing ``(verts, 0)`` or ``(..., 3)`` when specifying a marker to specify a
path or a circle, respectively (instead, use ``verts`` or ``"o"``,
respectively)
Expand Down
1 change: 0 additions & 1 deletion doc/api/toolkits/axes_grid1.rst
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@ See :ref:`axes_grid1_users-guide-index` for a guide on the usage of axes_grid1.
axes_grid1.axes_grid
axes_grid1.axes_rgb
axes_grid1.axes_size
axes_grid1.colorbar
axes_grid1.inset_locator
axes_grid1.mpl_axes
axes_grid1.parasite_axes
Expand Down
3 changes: 0 additions & 3 deletions doc/missing-references.json
Original file line number Diff line number Diff line change
Expand Up @@ -191,9 +191,6 @@
"backend_qt5.FigureCanvasQTAgg": [
"doc/api/prev_api_changes/api_changes_2.2.0.rst:210"
],
"datetime": [
"lib/matplotlib/dates.py:docstring of matplotlib.dates.mx2num:2"
],
"dateutil.rrule.rrulebase": [
"<external>/rrule.py:docstring of matplotlib.dates.rrule:1"
],
Expand Down
3 changes: 0 additions & 3 deletions examples/axes_grid1/demo_axes_grid.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,6 @@
from mpl_toolkits.axes_grid1 import ImageGrid


plt.rcParams["mpl_toolkits.legacy_colorbar"] = False


def get_demo_image():
z = cbook.get_sample_data("axes_grid/bivariate_normal.npy", np_load=True)
# z is a numpy array of 15x15
Expand Down
3 changes: 0 additions & 3 deletions examples/axes_grid1/demo_axes_grid2.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,6 @@
from mpl_toolkits.axes_grid1 import ImageGrid


plt.rcParams["mpl_toolkits.legacy_colorbar"] = False


def add_inner_title(ax, title, loc, **kwargs):
from matplotlib.offsetbox import AnchoredText
from matplotlib.patheffects import withStroke
Expand Down
3 changes: 0 additions & 3 deletions examples/axes_grid1/demo_edge_colorbar.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,6 @@
from mpl_toolkits.axes_grid1 import AxesGrid


plt.rcParams["mpl_toolkits.legacy_colorbar"] = False


def get_demo_image():
z = cbook.get_sample_data("axes_grid/bivariate_normal.npy", np_load=True)
# z is a numpy array of 15x15
Expand Down
7 changes: 3 additions & 4 deletions lib/matplotlib/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -569,6 +569,7 @@ def gen_candidates():
# rcParams deprecated; some can manually be mapped to another key.
# Values are tuples of (version, new_name_or_None).
_deprecated_ignore_map = {
'mpl_toolkits.legacy_colorbar': ('3.4', None),
}

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


@cbook._delete_parameter("3.2", "switch_backend_warn")
@cbook._delete_parameter("3.3", "recursionlimit")
def test(verbosity=None, coverage=False, switch_backend_warn=True,
recursionlimit=0, **kwargs):
def test(verbosity=None, coverage=False, *, recursionlimit=0, **kwargs):
"""Run the matplotlib test suite."""

try:
Expand Down
14 changes: 4 additions & 10 deletions lib/matplotlib/axes/_axes.py
Original file line number Diff line number Diff line change
Expand Up @@ -3472,7 +3472,6 @@ def boxplot(self, x, notch=None, sym=None, vert=None, whis=None,
If a pair of floats, they indicate the percentiles at which to
draw the whiskers (e.g., (5, 95)). In particular, setting this to
(0, 100) results in whiskers covering the whole range of the data.
"range" is a deprecated synonym for (0, 100).

In the edge case where ``Q1 == Q3``, *whis* is automatically set
to (0, 100) (cover the whole range of the data) if *autorange* is
Expand Down Expand Up @@ -4224,11 +4223,9 @@ def invalid_shape_exception(csize, xsize):
"edgecolors", "c", "facecolor",
"facecolors", "color"],
label_namer="y")
@cbook._delete_parameter("3.2", "verts")
def scatter(self, x, y, s=None, c=None, marker=None, cmap=None, norm=None,
vmin=None, vmax=None, alpha=None, linewidths=None,
verts=None, edgecolors=None, *, plotnonfinite=False,
**kwargs):
vmin=None, vmax=None, alpha=None, linewidths=None, *,
edgecolors=None, plotnonfinite=False, **kwargs):
"""
A scatter plot of *y* vs. *x* with varying marker size and/or color.

Expand Down Expand Up @@ -5097,7 +5094,6 @@ def _fill_between_x_or_y(
"""

dep_dir = {"x": "y", "y": "x"}[ind_dir]
func_name = {"x": "fill_between", "y": "fill_betweenx"}[dep_dir]

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

Expand Down
30 changes: 5 additions & 25 deletions lib/matplotlib/axes/_base.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
import inspect
import itertools
import logging
import math
from numbers import Real
from operator import attrgetter
import types
Expand Down Expand Up @@ -1602,23 +1601,6 @@ def get_data_ratio(self):
ysize = max(abs(tymax - tymin), 1e-30)
return ysize / xsize

@_api.deprecated("3.2")
def get_data_ratio_log(self):
"""
Return the aspect ratio of the raw data in log scale.

Notes
-----
Will be used when both axis are in log scale.
"""
xmin, xmax = self.get_xbound()
ymin, ymax = self.get_ybound()

xsize = max(abs(math.log10(xmax) - math.log10(xmin)), 1e-30)
ysize = max(abs(math.log10(ymax) - math.log10(ymin)), 1e-30)

return ysize / xsize

def apply_aspect(self, position=None):
"""
Adjust the Axes for a specified data aspect ratio.
Expand Down Expand Up @@ -1799,7 +1781,10 @@ def axis(self, *args, emit=True, **kwargs):
matplotlib.axes.Axes.set_xlim
matplotlib.axes.Axes.set_ylim
"""
if len(args) == 1 and isinstance(args[0], (str, bool)):
if len(args) > 1:
raise TypeError("axis() takes 0 or 1 positional arguments but "
f"{len(args)} were given")
elif len(args) == 1 and isinstance(args[0], (str, bool)):
s = args[0]
if s is True:
s = 'on'
Expand Down Expand Up @@ -1841,12 +1826,7 @@ def axis(self, *args, emit=True, **kwargs):
raise ValueError('Unrecognized string %s to axis; '
'try on or off' % s)
else:
if len(args) >= 1:
if len(args) != 1:
cbook.warn_deprecated(
"3.2", message="Passing more than one positional "
"argument to axis() is deprecated and will raise a "
"TypeError %(removal)s.")
if len(args) == 1:
limits = args[0]
try:
xmin, xmax, ymin, ymax = limits
Expand Down
10 changes: 0 additions & 10 deletions lib/matplotlib/axes/_subplots.py
Original file line number Diff line number Diff line change
Expand Up @@ -98,16 +98,6 @@ def update_params(self):
# Now a no-op, as figbox/numRows/numCols are (deprecated) auto-updating
# properties.

@_api.deprecated("3.2", alternative="ax.get_subplotspec().rowspan.start")
@property
def rowNum(self):
return self.get_subplotspec().rowspan.start

@_api.deprecated("3.2", alternative="ax.get_subplotspec().colspan.start")
@property
def colNum(self):
return self.get_subplotspec().colspan.start

@_api.deprecated("3.4", alternative="ax.get_subplotspec().is_first_row()")
def is_first_row(self):
return self.get_subplotspec().rowspan.start == 0
Expand Down
42 changes: 0 additions & 42 deletions lib/matplotlib/axis.py
Original file line number Diff line number Diff line change
Expand Up @@ -673,7 +673,6 @@ def __init__(self, axes, pickradius=15):
self.callbacks = cbook.CallbackRegistry()

self._autolabelpos = True
self._smart_bounds = False # Deprecated in 3.2

self.label = mtext.Text(
np.nan, np.nan,
Expand Down Expand Up @@ -1010,17 +1009,6 @@ def get_ticklabel_extents(self, renderer):
bbox2 = mtransforms.Bbox.from_extents(0, 0, 0, 0)
return bbox, bbox2

@_api.deprecated("3.2")
def set_smart_bounds(self, value):
"""Set the axis to have smart bounds."""
self._smart_bounds = value
self.stale = True

@_api.deprecated("3.2")
def get_smart_bounds(self):
"""Return whether the axis has smart bounds."""
return self._smart_bounds

def _update_ticks(self):
"""
Update ticks (position and labels) using the current data interval of
Expand Down Expand Up @@ -1048,36 +1036,6 @@ def _update_ticks(self):
if view_low > view_high:
view_low, view_high = view_high, view_low

if self._smart_bounds and ticks: # _smart_bounds is deprecated in 3.2
# handle inverted limits
data_low, data_high = sorted(self.get_data_interval())
locs = np.sort([tick.get_loc() for tick in ticks])
if data_low <= view_low:
# data extends beyond view, take view as limit
ilow = view_low
else:
# data stops within view, take best tick
good_locs = locs[locs <= data_low]
if len(good_locs):
# last tick prior or equal to first data point
ilow = good_locs[-1]
else:
# No ticks (why not?), take first tick
ilow = locs[0]
if data_high >= view_high:
# data extends beyond view, take view as limit
ihigh = view_high
else:
# data stops within view, take best tick
good_locs = locs[locs >= data_high]
if len(good_locs):
# first tick after or equal to last data point
ihigh = good_locs[0]
else:
# No ticks (why not?), take last tick
ihigh = locs[-1]
ticks = [tick for tick in ticks if ilow <= tick.get_loc() <= ihigh]

interval_t = self.get_transform().transform([view_low, view_high])

ticks_to_draw = []
Expand Down
Loading