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

Skip to content

Commit 4ecaba5

Browse files
authored
Merge pull request #16001 from timhoffm/delete-deprecated-parameters
Remove parameters deprecated in 3.1
2 parents 4848787 + 9e1eaac commit 4ecaba5

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
@@ -102,4 +102,16 @@ Classes and methods
102102
Arguments
103103
~~~~~~~~~
104104
- ``Axes.text()`` / ``pyplot.text()`` do not support the parameter ``withdash``
105-
anymore. Use ``Axes.annotate()`` and ``pyplot.annotate()`` instead.
105+
anymore. Use ``Axes.annotate()`` and ``pyplot.annotate()`` instead.
106+
- The first parameter of `matplotlib.use` has been renamed from ``arg`` to
107+
``backend`` (only relevant if you pass by keyword).
108+
- The parameter ``warn`` of `matplotlib.use` has been removed. A failure to
109+
switch the backend will now always raise an ``ImportError`` if ``force`` is
110+
set; catch that error if necessary.
111+
- All parameters of `matplotlib.use` except the first one are now keyword-only.
112+
- The unused parameters ``shape`` and ``imlim`` of `~.axes.Axes.imshow()` are
113+
now removed. All parameters beyond ``extent`` are now keyword-only.
114+
- The unused parameter ``interp_at_native`` of `.BboxImage` has been removed.
115+
- The parameter ``usetex`` of `.TextToPath.get_text_path` has been removed.
116+
Use ``ismath='TeX'`` instead.
117+
- 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
@@ -5389,12 +5389,10 @@ def get_interp_point(ind):
53895389

53905390
#### plotting z(x, y): imshow, pcolor and relatives, contour
53915391
@_preprocess_data()
5392-
@cbook._delete_parameter("3.1", "shape")
5393-
@cbook._delete_parameter("3.1", "imlim")
53945392
def imshow(self, X, cmap=None, norm=None, aspect=None,
53955393
interpolation=None, alpha=None, vmin=None, vmax=None,
5396-
origin=None, extent=None, shape=None, filternorm=True,
5397-
filterrad=4.0, imlim=None, resample=None, url=None, **kwargs):
5394+
origin=None, extent=None, *, filternorm=True, filterrad=4.0,
5395+
resample=None, url=None, **kwargs):
53985396
"""
53995397
Display data as an image; i.e. on a 2D regular raster.
54005398

lib/matplotlib/backend_bases.py

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

33643364
@classmethod
3365-
@cbook._make_keyword_only("3.1", "block")
3366-
def show(cls, block=None):
3365+
def show(cls, *, block=None):
33673366
"""
33683367
Show all figures.
33693368

lib/matplotlib/image.py

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

1325-
@cbook._delete_parameter("3.1", "interp_at_native")
13261325
def __init__(self, bbox,
13271326
cmap=None,
13281327
norm=None,
@@ -1331,7 +1330,6 @@ def __init__(self, bbox,
13311330
filternorm=True,
13321331
filterrad=4.0,
13331332
resample=False,
1334-
interp_at_native=True,
13351333
**kwargs
13361334
):
13371335
"""
@@ -1353,7 +1351,6 @@ def __init__(self, bbox,
13531351
)
13541352

13551353
self.bbox = bbox
1356-
self._interp_at_native = interp_at_native
13571354
self._transform = IdentityTransform()
13581355

13591356
def get_transform(self):

lib/matplotlib/pyplot.py

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

lib/matplotlib/tests/test_image.py

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

1515
from matplotlib import (
1616
colors, image as mimage, patches, pyplot as plt, style, rcParams)
17-
from matplotlib.cbook import MatplotlibDeprecationWarning
1817
from matplotlib.image import (AxesImage, BboxImage, FigureImage,
1918
NonUniformImage, PcolorImage)
2019
from matplotlib.testing.decorators import check_figures_equal, image_comparison
@@ -1102,20 +1101,6 @@ def test_relim():
11021101
assert ax.get_xlim() == ax.get_ylim() == (0, 1)
11031102

11041103

1105-
def test_deprecation():
1106-
data = [[1, 2], [3, 4]]
1107-
ax = plt.figure().subplots()
1108-
for obj in [ax, plt]:
1109-
with pytest.warns(None) as record:
1110-
obj.imshow(data)
1111-
assert len(record) == 0
1112-
with pytest.warns(MatplotlibDeprecationWarning):
1113-
obj.imshow(data, shape=None)
1114-
with pytest.warns(MatplotlibDeprecationWarning):
1115-
# Enough arguments to pass "shape" positionally.
1116-
obj.imshow(data, *[None] * 10)
1117-
1118-
11191104
def test_respects_bbox():
11201105
fig, axs = plt.subplots(2)
11211106
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)