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

Skip to content

Commit a4a7bd3

Browse files
authored
Merge pull request #12823 from timhoffm/fix-warn_deprecated-usages
Fix usages of warn_deprecated()
2 parents 084b121 + e9024fc commit a4a7bd3

File tree

8 files changed

+25
-21
lines changed

8 files changed

+25
-21
lines changed

lib/matplotlib/axes/_base.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1311,7 +1311,7 @@ def set_adjustable(self, adjustable, share=False):
13111311
"""
13121312
if adjustable == 'box-forced':
13131313
cbook.warn_deprecated(
1314-
"2.2", "box-forced", obj_type="keyword argument")
1314+
"2.2", name="box-forced", obj_type="keyword argument")
13151315
if adjustable not in ('box', 'datalim', 'box-forced'):
13161316
raise ValueError("argument must be 'box', or 'datalim'")
13171317
if share:
@@ -1641,8 +1641,8 @@ def axis(self, *v, **kwargs):
16411641
'auto', 'image', 'square'):
16421642
if s == 'normal':
16431643
cbook.warn_deprecated(
1644-
"3.1", "Passing 'normal' to axis() is deprecated "
1645-
"since %(since)s; use 'auto' instead.")
1644+
"3.1", message="Passing 'normal' to axis() is "
1645+
"deprecated since %(since)s; use 'auto' instead.")
16461646
self.set_autoscale_on(True)
16471647
self.set_aspect('auto')
16481648
self.autoscale_view(tight=False)

lib/matplotlib/axis.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1637,9 +1637,9 @@ def set_ticklabels(self, ticklabels, *args, minor=False, **kwargs):
16371637
"""
16381638
if args:
16391639
cbook.warn_deprecated(
1640-
"3.1", "Additional positional arguments to set_ticklabels are "
1641-
"ignored, and deprecated since Matplotlib 3.1; passing them "
1642-
"will raise a TypeError in Matplotlib 3.3.")
1640+
"3.1", message="Additional positional arguments to "
1641+
"set_ticklabels are ignored, and deprecated since Matplotlib "
1642+
"3.1; passing them will raise a TypeError in Matplotlib 3.3.")
16431643
get_labels = []
16441644
for t in ticklabels:
16451645
# try calling get_text() to check whether it is Text object

lib/matplotlib/cbook/__init__.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -420,9 +420,9 @@ def _string_to_bool(s):
420420
"""Parses the string argument as a boolean"""
421421
if not isinstance(s, str):
422422
return bool(s)
423-
warn_deprecated("2.2", "Passing one of 'on', 'true', 'off', 'false' as a "
424-
"boolean is deprecated; use an actual boolean "
425-
"(True/False) instead.")
423+
warn_deprecated("2.2", message="Passing one of 'on', 'true', 'off', "
424+
"'false' as a boolean is deprecated; use an actual "
425+
"boolean (True/False) instead.")
426426
if s.lower() in ['on', 'true']:
427427
return True
428428
if s.lower() in ['off', 'false']:

lib/matplotlib/cbook/deprecation.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -176,9 +176,9 @@ def the_function_to_deprecate():
176176

177177
if obj_type is not None:
178178
warn_deprecated(
179-
"3.0", "Passing 'obj_type' to the 'deprecated' decorator has no "
180-
"effect, and is deprecated since Matplotlib %(since)s; support "
181-
"for it will be removed %(removal)s.")
179+
"3.0", message="Passing 'obj_type' to the 'deprecated' decorator "
180+
"has no effect, and is deprecated since Matplotlib %(since)s; "
181+
"support for it will be removed %(removal)s.")
182182

183183
def deprecate(obj, message=message, name=name, alternative=alternative,
184184
pending=pending, addendum=addendum):

lib/matplotlib/gridspec.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -290,7 +290,8 @@ def get_subplot_params(self, figure=None, fig=None):
290290
parameters are from rcParams unless a figure attribute is set.
291291
"""
292292
if fig is not None:
293-
cbook.warn_deprecated("2.2", "fig", obj_type="keyword argument",
293+
cbook.warn_deprecated("2.2", name="fig",
294+
obj_type="keyword argument",
294295
alternative="figure")
295296
if figure is None:
296297
figure = fig
@@ -382,7 +383,8 @@ def get_subplot_params(self, figure=None, fig=None):
382383
"""Return a dictionary of subplot layout parameters.
383384
"""
384385
if fig is not None:
385-
cbook.warn_deprecated("2.2", "fig", obj_type="keyword argument",
386+
cbook.warn_deprecated("2.2", name="fig",
387+
obj_type="keyword argument",
386388
alternative="figure")
387389
if figure is None:
388390
figure = fig

lib/matplotlib/offsetbox.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1243,9 +1243,10 @@ def __init__(self, s, loc, pad=0.4, borderpad=0.5, prop=None, **kwargs):
12431243
badkwargs = {'ha', 'horizontalalignment', 'va', 'verticalalignment'}
12441244
if badkwargs & set(prop):
12451245
cbook.warn_deprecated(
1246-
"3.1", "Mixing horizontalalignment or verticalalignment with "
1247-
"AnchoredText is not supported, deprecated since %(version)s, "
1248-
"and will raise an exception %(removal)s.")
1246+
"3.1", message="Mixing horizontalalignment or "
1247+
"verticalalignment with AnchoredText is not supported, "
1248+
"deprecated since %(version)s, and will raise an exception "
1249+
"%(removal)s.")
12491250

12501251
self.txt = TextArea(s, textprops=prop, minimumdescent=False)
12511252
fp = self.txt._text.get_fontproperties()

lib/matplotlib/rcsetup.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -616,7 +616,7 @@ def validate_svg_fonttype(s):
616616
return s
617617
if s == "svgfont":
618618
cbook.warn_deprecated(
619-
"2.2", "'svgfont' support for svg.fonttype is deprecated.")
619+
"2.2", message="'svgfont' support for svg.fonttype is deprecated.")
620620
return s
621621
raise ValueError("Unrecognized svg.fonttype string '{}'; "
622622
"valid strings are 'none', 'path'")

lib/mpl_toolkits/mplot3d/axes3d.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1659,9 +1659,10 @@ def plot_surface(self, X, Y, Z, *args, norm=None, vmin=None,
16591659
if shade is None:
16601660
cbook.warn_deprecated(
16611661
"3.1",
1662-
"Passing shade=None to Axes3D.plot_surface() is deprecated "
1663-
"since matplotlib 3.1 and will change its semantic or raise "
1664-
"an error in matplotlib 3.3. Please use shade=False instead.")
1662+
message="Passing shade=None to Axes3D.plot_surface() is "
1663+
"deprecated since matplotlib 3.1 and will change its "
1664+
"semantic or raise an error in matplotlib 3.3. "
1665+
"Please use shade=False instead.")
16651666

16661667
# evenly spaced, and including both endpoints
16671668
row_inds = list(range(0, rows-1, rstride)) + [rows-1]

0 commit comments

Comments
 (0)