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

Skip to content

Commit 9e1eaac

Browse files
committed
Remove parameters deprecated in 3.1
1 parent e70c9d2 commit 9e1eaac

8 files changed

Lines changed: 26 additions & 52 deletions

File tree

doc/api/next_api_changes/removals.rst

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,4 +74,16 @@ Classes and methods
7474
Arguments
7575
~~~~~~~~~
7676
- ``Axes.text()`` / ``pyplot.text()`` do not support the parameter ``withdash``
77-
anymore. Use ``Axes.annotate()`` and ``pyplot.annotate()`` instead.
77+
anymore. Use ``Axes.annotate()`` and ``pyplot.annotate()`` instead.
78+
- The first parameter of `matplotlib.use` has been renamed from ``arg`` to
79+
``backend`` (only relevant if you pass by keyword).
80+
- The parameter ``warn`` of `matplotlib.use` has been removed. A failure to
81+
switch the backend will now always raise an ``ImportError`` if ``force`` is
82+
set; catch that error if necessary.
83+
- All parameters of `matplotlib.use` except the first one are now keyword-only.
84+
- The unused parameters ``shape`` and ``imlim`` of `~.axes.Axes.imshow()` are
85+
now removed. All parameters beyond ``extent`` are now keyword-only.
86+
- The unused parameter ``interp_at_native`` of `.BboxImage` has been removed.
87+
- The parameter ``usetex`` of `.TextToPath.get_text_path` has been removed.
88+
Use ``ismath='TeX'`` instead.
89+
- The parameter ``block`` of ``show()`` is now keyword-only.

lib/matplotlib/__init__.py

Lines changed: 2 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1098,9 +1098,7 @@ def __exit__(self, exc_type, exc_value, exc_tb):
10981098
self.__fallback()
10991099

11001100

1101-
@cbook._rename_parameter("3.1", "arg", "backend")
1102-
@cbook._delete_parameter("3.1", "warn")
1103-
def use(backend, warn=False, force=True):
1101+
def use(backend, *, force=True):
11041102
"""
11051103
Select the backend used for rendering and GUI integration.
11061104
@@ -1120,10 +1118,6 @@ def use(backend, warn=False, force=True):
11201118
11211119
or a string of the form: ``module://my.module.name``.
11221120
1123-
warn : bool, default: False
1124-
If True and not *force*, emit a warning if a failure-to-switch
1125-
`ImportError` has been suppressed. This parameter is deprecated.
1126-
11271121
force : bool, default: True
11281122
If True (the default), raise an `ImportError` if the backend cannot be
11291123
set up (either because it fails to import, or because an incompatible
@@ -1148,12 +1142,9 @@ def use(backend, warn=False, force=True):
11481142
try:
11491143
from matplotlib import pyplot as plt
11501144
plt.switch_backend(name)
1151-
except ImportError as exc:
1145+
except ImportError:
11521146
if force:
11531147
raise
1154-
if warn:
1155-
cbook._warn_external(
1156-
f"Failed to switch backend to {backend}: {exc}")
11571148

11581149

11591150
if os.environ.get('MPLBACKEND'):

lib/matplotlib/axes/_axes.py

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5392,12 +5392,10 @@ def get_interp_point(ind):
53925392

53935393
#### plotting z(x, y): imshow, pcolor and relatives, contour
53945394
@_preprocess_data()
5395-
@cbook._delete_parameter("3.1", "shape")
5396-
@cbook._delete_parameter("3.1", "imlim")
53975395
def imshow(self, X, cmap=None, norm=None, aspect=None,
53985396
interpolation=None, alpha=None, vmin=None, vmax=None,
5399-
origin=None, extent=None, shape=None, filternorm=True,
5400-
filterrad=4.0, imlim=None, resample=None, url=None, **kwargs):
5397+
origin=None, extent=None, *, filternorm=True, filterrad=4.0,
5398+
resample=None, url=None, **kwargs):
54015399
"""
54025400
Display data as an image; i.e. on a 2D regular raster.
54035401

lib/matplotlib/backend_bases.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3338,8 +3338,7 @@ def draw_if_interactive(cls):
33383338
cls.trigger_manager_draw(manager)
33393339

33403340
@classmethod
3341-
@cbook._make_keyword_only("3.1", "block")
3342-
def show(cls, block=None):
3341+
def show(cls, *, block=None):
33433342
"""
33443343
Show all figures.
33453344

lib/matplotlib/image.py

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1323,7 +1323,6 @@ def set_data(self, A):
13231323
class BboxImage(_ImageBase):
13241324
"""The Image class whose size is determined by the given bbox."""
13251325

1326-
@cbook._delete_parameter("3.1", "interp_at_native")
13271326
def __init__(self, bbox,
13281327
cmap=None,
13291328
norm=None,
@@ -1332,7 +1331,6 @@ def __init__(self, bbox,
13321331
filternorm=True,
13331332
filterrad=4.0,
13341333
resample=False,
1335-
interp_at_native=True,
13361334
**kwargs
13371335
):
13381336
"""
@@ -1354,7 +1352,6 @@ def __init__(self, bbox,
13541352
)
13551353

13561354
self.bbox = bbox
1357-
self._interp_at_native = interp_at_native
13581355
self._transform = IdentityTransform()
13591356

13601357
def get_transform(self):

lib/matplotlib/pyplot.py

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2447,18 +2447,16 @@ def hlines(
24472447
@docstring.copy(Axes.imshow)
24482448
def imshow(
24492449
X, cmap=None, norm=None, aspect=None, interpolation=None,
2450-
alpha=None, vmin=None, vmax=None, origin=None, extent=None,
2451-
shape=cbook.deprecation._deprecated_parameter,
2452-
filternorm=True, filterrad=4.0,
2453-
imlim=cbook.deprecation._deprecated_parameter, resample=None,
2454-
url=None, *, data=None, **kwargs):
2450+
alpha=None, vmin=None, vmax=None, origin=None, extent=None, *,
2451+
filternorm=True, filterrad=4.0, resample=None, url=None,
2452+
data=None, **kwargs):
24552453
__ret = gca().imshow(
24562454
X, cmap=cmap, norm=norm, aspect=aspect,
24572455
interpolation=interpolation, alpha=alpha, vmin=vmin,
2458-
vmax=vmax, origin=origin, extent=extent, shape=shape,
2459-
filternorm=filternorm, filterrad=filterrad, imlim=imlim,
2460-
resample=resample, url=url, **({"data": data} if data is not
2461-
None else {}), **kwargs)
2456+
vmax=vmax, origin=origin, extent=extent,
2457+
filternorm=filternorm, filterrad=filterrad, resample=resample,
2458+
url=url, **({"data": data} if data is not None else {}),
2459+
**kwargs)
24622460
sci(__ret)
24632461
return __ret
24642462

lib/matplotlib/tests/test_image.py

Lines changed: 0 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@
1515

1616
from matplotlib import (
1717
colors, image as mimage, patches, pyplot as plt, style, rcParams)
18-
from matplotlib.cbook import MatplotlibDeprecationWarning
1918
from matplotlib.image import (AxesImage, BboxImage, FigureImage,
2019
NonUniformImage, PcolorImage)
2120
from matplotlib.testing.decorators import check_figures_equal, image_comparison
@@ -1105,20 +1104,6 @@ def test_relim():
11051104
assert ax.get_xlim() == ax.get_ylim() == (0, 1)
11061105

11071106

1108-
def test_deprecation():
1109-
data = [[1, 2], [3, 4]]
1110-
ax = plt.figure().subplots()
1111-
for obj in [ax, plt]:
1112-
with pytest.warns(None) as record:
1113-
obj.imshow(data)
1114-
assert len(record) == 0
1115-
with pytest.warns(MatplotlibDeprecationWarning):
1116-
obj.imshow(data, shape=None)
1117-
with pytest.warns(MatplotlibDeprecationWarning):
1118-
# Enough arguments to pass "shape" positionally.
1119-
obj.imshow(data, *[None] * 10)
1120-
1121-
11221107
def test_respects_bbox():
11231108
fig, axs = plt.subplots(2)
11241109
for ax in axs:

lib/matplotlib/textpath.py

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -89,8 +89,7 @@ def get_text_width_height_descent(self, s, prop, ismath):
8989
d /= 64.0
9090
return w * scale, h * scale, d * scale
9191

92-
@cbook._delete_parameter("3.1", "usetex")
93-
def get_text_path(self, prop, s, ismath=False, usetex=False):
92+
def get_text_path(self, prop, s, ismath=False):
9493
"""
9594
Convert text *s* to path (a tuple of vertices and codes for
9695
matplotlib.path.Path).
@@ -106,9 +105,6 @@ def get_text_path(self, prop, s, ismath=False, usetex=False):
106105
ismath : {False, True, "TeX"}
107106
If True, use mathtext parser. If "TeX", use tex for renderering.
108107
109-
usetex : bool, optional
110-
If set, forces *ismath* to True. This parameter is deprecated.
111-
112108
Returns
113109
-------
114110
verts, codes : tuple of lists
@@ -130,8 +126,6 @@ def get_text_path(self, prop, s, ismath=False, usetex=False):
130126
131127
Also see `TextPath` for a more direct way to create a path from a text.
132128
"""
133-
if usetex:
134-
ismath = "TeX"
135129
if ismath == "TeX":
136130
glyph_info, glyph_map, rects = self.get_glyphs_tex(prop, s)
137131
elif not ismath:

0 commit comments

Comments
 (0)