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

Skip to content

Commit 685c002

Browse files
committed
Deprecate @cbook.deprecated and move internal calls to @_api.deprecated
1 parent f23860d commit 685c002

17 files changed

+61
-54
lines changed

lib/matplotlib/_mathtext.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -795,7 +795,7 @@ def __init__(self, default_font_prop, mathtext_backend=None):
795795
self.fonts['default'] = default_font
796796
self.fonts['regular'] = default_font
797797

798-
pswriter = cbook.deprecated("3.4")(property(lambda self: StringIO()))
798+
pswriter = _api.deprecated("3.4")(property(lambda self: StringIO()))
799799

800800
def _get_font(self, font):
801801
if font in self.fontmap:
@@ -1549,7 +1549,7 @@ class Glue(Node):
15491549
it's easier to stick to what TeX does.)
15501550
"""
15511551

1552-
glue_subtype = cbook.deprecated("3.3")(property(lambda self: "normal"))
1552+
glue_subtype = _api.deprecated("3.3")(property(lambda self: "normal"))
15531553

15541554
@_api.delete_parameter("3.3", "copy")
15551555
def __init__(self, glue_type, copy=False):

lib/matplotlib/animation.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -795,7 +795,7 @@ class HTMLWriter(FileMovieWriter):
795795
"""Writer for JavaScript-based HTML movies."""
796796

797797
supported_formats = ['png', 'jpeg', 'tiff', 'svg']
798-
args_key = cbook.deprecated("3.3")(property(
798+
args_key = _api.deprecated("3.3")(property(
799799
lambda self: 'animation.html_args'))
800800

801801
@classmethod

lib/matplotlib/backend_bases.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2710,7 +2710,7 @@ class FigureManagerBase:
27102710
figure.canvas.manager.button_press_handler_id)
27112711
"""
27122712

2713-
statusbar = cbook.deprecated("3.3")(property(lambda self: None))
2713+
statusbar = _api.deprecated("3.3")(property(lambda self: None))
27142714

27152715
def __init__(self, canvas, num):
27162716
self.canvas = canvas

lib/matplotlib/backends/_backend_pdf_ps.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
import functools
66

77
import matplotlib as mpl
8+
from matplotlib import _api
89
from .. import font_manager, ft2font
910
from ..afm import AFM
1011
from ..backend_bases import RendererBase
@@ -27,7 +28,7 @@ class CharacterTracker:
2728
def __init__(self):
2829
self.used = {}
2930

30-
@mpl.cbook.deprecated("3.3")
31+
@_api.deprecated("3.3")
3132
@property
3233
def used_characters(self):
3334
d = {}

lib/matplotlib/backends/backend_cairo.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -121,9 +121,9 @@ def attr(field):
121121

122122

123123
class RendererCairo(RendererBase):
124-
fontweights = cbook.deprecated("3.3")(property(lambda self: {*_f_weights}))
125-
fontangles = cbook.deprecated("3.3")(property(lambda self: {*_f_angles}))
126-
mathtext_parser = cbook.deprecated("3.4")(
124+
fontweights = _api.deprecated("3.3")(property(lambda self: {*_f_weights}))
125+
fontangles = _api.deprecated("3.3")(property(lambda self: {*_f_angles}))
126+
mathtext_parser = _api.deprecated("3.4")(
127127
property(lambda self: MathTextParser('Cairo')))
128128

129129
def __init__(self, dpi):

lib/matplotlib/backends/backend_gtk3.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -432,7 +432,7 @@ def resize(self, width, height):
432432

433433

434434
class NavigationToolbar2GTK3(NavigationToolbar2, Gtk.Toolbar):
435-
ctx = cbook.deprecated("3.3")(property(
435+
ctx = _api.deprecated("3.3")(property(
436436
lambda self: self.canvas.get_property("window").cairo_create()))
437437

438438
def __init__(self, canvas, window):

lib/matplotlib/backends/backend_pgf.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -932,7 +932,7 @@ class PdfPages:
932932
'_info_dict',
933933
'_metadata',
934934
)
935-
metadata = cbook.deprecated('3.3')(property(lambda self: self._metadata))
935+
metadata = _api.deprecated('3.3')(property(lambda self: self._metadata))
936936

937937
def __init__(self, filename, *, keep_empty=True, metadata=None):
938938
"""

lib/matplotlib/backends/backend_ps.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -223,9 +223,9 @@ class RendererPS(_backend_pdf_ps.RendererPDFPSBase):
223223
_afm_font_dir = cbook._get_data_path("fonts/afm")
224224
_use_afm_rc_name = "ps.useafm"
225225

226-
mathtext_parser = cbook.deprecated("3.4")(property(
226+
mathtext_parser = _api.deprecated("3.4")(property(
227227
lambda self: MathTextParser("PS")))
228-
used_characters = cbook.deprecated("3.3")(property(
228+
used_characters = _api.deprecated("3.3")(property(
229229
lambda self: self._character_tracker.used_characters))
230230

231231
def __init__(self, width, height, pswriter, imagedpi=72):

lib/matplotlib/backends/qt_compat.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
import sys
1919

2020
import matplotlib as mpl
21+
from matplotlib import _api
2122

2223

2324
QT_API_PYQT5 = "PyQt5"
@@ -87,7 +88,7 @@ def _isdeleted(obj): return not shiboken2.isValid(obj)
8788
raise ValueError("Unexpected value for the 'backend.qt5' rcparam")
8889
_getSaveFileName = QtWidgets.QFileDialog.getSaveFileName
8990

90-
@mpl.cbook.deprecated("3.3", alternative="QtCore.qVersion()")
91+
@_api.deprecated("3.3", alternative="QtCore.qVersion()")
9192
def is_pyqt5():
9293
return True
9394

@@ -143,7 +144,7 @@ def _isdeleted(obj): return not shiboken.isValid(obj)
143144
raise ValueError("Unexpected value for the 'backend.qt4' rcparam")
144145
QtWidgets = QtGui
145146

146-
@mpl.cbook.deprecated("3.3", alternative="QtCore.qVersion()")
147+
@_api.deprecated("3.3", alternative="QtCore.qVersion()")
147148
def is_pyqt5():
148149
return False
149150

lib/matplotlib/cbook/__init__.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,12 @@
3131
from matplotlib import _api, _c_internal_utils
3232
from matplotlib._api import classproperty as _classproperty
3333
from matplotlib._api.deprecation import (
34-
deprecated, warn_deprecated, MatplotlibDeprecationWarning, mplDeprecation)
34+
warn_deprecated, MatplotlibDeprecationWarning, mplDeprecation)
35+
36+
37+
@_api.deprecated("3.4")
38+
def deprecated(*args, **kwargs):
39+
return _api.deprecated(*args, **kwargs)
3540

3641

3742
def _get_running_interactive_framework():

lib/matplotlib/contour.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -682,7 +682,7 @@ class ContourSet(cm.ScalarMappable, ContourLabeler):
682682
%(contour_set_attributes)s
683683
"""
684684

685-
ax = cbook.deprecated("3.3")(property(lambda self: self.axes))
685+
ax = _api.deprecated("3.3")(property(lambda self: self.axes))
686686

687687
def __init__(self, ax, *args,
688688
levels=None, filled=False, linewidths=None, linestyles=None,

lib/matplotlib/mathtext.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -351,7 +351,7 @@ def get_results(self, box, used_characters):
351351
*[c.__name__ for c in _mathtext.Node.__subclasses__()],
352352
"Ship", "Parser",
353353
]:
354-
globals()[_cls_name] = cbook.deprecated("3.4")(
354+
globals()[_cls_name] = _api.deprecated("3.4")(
355355
type(_cls_name, (getattr(_mathtext, _cls_name),), {}))
356356

357357

lib/matplotlib/sphinxext/plot_directive.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -156,10 +156,10 @@
156156
import matplotlib
157157
from matplotlib.backend_bases import FigureManagerBase
158158
import matplotlib.pyplot as plt
159-
from matplotlib import _pylab_helpers, cbook
159+
from matplotlib import _api, _pylab_helpers, cbook
160160

161161
matplotlib.use("agg")
162-
align = cbook.deprecated(
162+
align = _api.deprecated(
163163
"3.4", alternative="docutils.parsers.rst.directives.images.Image.align")(
164164
Image.align)
165165

lib/matplotlib/texmanager.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -73,19 +73,19 @@ class TexManager:
7373
'computer modern sans serif': ('cmss', r'\usepackage{type1ec}'),
7474
'computer modern typewriter': ('cmtt', r'\usepackage{type1ec}')}
7575

76-
cachedir = cbook.deprecated(
76+
cachedir = _api.deprecated(
7777
"3.3", alternative="matplotlib.get_cachedir()")(
7878
property(lambda self: mpl.get_cachedir()))
79-
rgba_arrayd = cbook.deprecated("3.3")(property(lambda self: {}))
79+
rgba_arrayd = _api.deprecated("3.3")(property(lambda self: {}))
8080
_fonts = {} # Only for deprecation period.
81-
serif = cbook.deprecated("3.3")(property(
81+
serif = _api.deprecated("3.3")(property(
8282
lambda self: self._fonts.get("serif", ('cmr', ''))))
83-
sans_serif = cbook.deprecated("3.3")(property(
83+
sans_serif = _api.deprecated("3.3")(property(
8484
lambda self: self._fonts.get("sans-serif", ('cmss', ''))))
85-
cursive = cbook.deprecated("3.3")(property(
85+
cursive = _api.deprecated("3.3")(property(
8686
lambda self:
8787
self._fonts.get("cursive", ('pzc', r'\usepackage{chancery}'))))
88-
monospace = cbook.deprecated("3.3")(property(
88+
monospace = _api.deprecated("3.3")(property(
8989
lambda self: self._fonts.get("monospace", ('cmtt', ''))))
9090

9191
@functools.lru_cache() # Always return the same instance.

lib/matplotlib/ticker.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2118,11 +2118,11 @@ def __init__(self, *args, **kwargs):
21182118
"""
21192119
if args:
21202120
if 'nbins' in kwargs:
2121-
cbook.deprecated("3.1",
2122-
message='Calling MaxNLocator with positional '
2123-
'and keyword parameter *nbins* is '
2124-
'considered an error and will fail '
2125-
'in future versions of matplotlib.')
2121+
_api.deprecated("3.1",
2122+
message='Calling MaxNLocator with positional '
2123+
'and keyword parameter *nbins* is '
2124+
'considered an error and will fail '
2125+
'in future versions of matplotlib.')
21262126
kwargs['nbins'] = args[0]
21272127
if len(args) > 1:
21282128
raise ValueError(

lib/matplotlib/widgets.py

Lines changed: 19 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,7 @@ class AxesWidget(Widget):
109109
If False, the widget does not respond to events.
110110
"""
111111

112-
cids = cbook.deprecated("3.4")(property(lambda self: self._cids))
112+
cids = _api.deprecated("3.4")(property(lambda self: self._cids))
113113

114114
def __init__(self, ax):
115115
self.ax = ax
@@ -151,9 +151,9 @@ class Button(AxesWidget):
151151
The color of the button when hovering.
152152
"""
153153

154-
cnt = cbook.deprecated("3.4")(property( # Not real, but close enough.
154+
cnt = _api.deprecated("3.4")(property( # Not real, but close enough.
155155
lambda self: len(self._observers.callbacks['clicked'])))
156-
observers = cbook.deprecated("3.4")(property(
156+
observers = _api.deprecated("3.4")(property(
157157
lambda self: self._observers.callbacks['clicked']))
158158

159159
def __init__(self, ax, label, image=None,
@@ -243,9 +243,9 @@ class Slider(AxesWidget):
243243
Slider value.
244244
"""
245245

246-
cnt = cbook.deprecated("3.4")(property( # Not real, but close enough.
246+
cnt = _api.deprecated("3.4")(property( # Not real, but close enough.
247247
lambda self: len(self._observers.callbacks['changed'])))
248-
observers = cbook.deprecated("3.4")(property(
248+
observers = _api.deprecated("3.4")(property(
249249
lambda self: self._observers.callbacks['changed']))
250250

251251
def __init__(self, ax, label, valmin, valmax, valinit=0.5, valfmt=None,
@@ -536,9 +536,9 @@ class CheckButtons(AxesWidget):
536536
each box, but have ``set_visible(False)`` when its box is not checked.
537537
"""
538538

539-
cnt = cbook.deprecated("3.4")(property( # Not real, but close enough.
539+
cnt = _api.deprecated("3.4")(property( # Not real, but close enough.
540540
lambda self: len(self._observers.callbacks['clicked'])))
541-
observers = cbook.deprecated("3.4")(property(
541+
observers = _api.deprecated("3.4")(property(
542542
lambda self: self._observers.callbacks['clicked']))
543543

544544
def __init__(self, ax, labels, actives=None):
@@ -688,13 +688,13 @@ class TextBox(AxesWidget):
688688
The color of the text box when hovering.
689689
"""
690690

691-
params_to_disable = cbook.deprecated("3.3")(property(
691+
params_to_disable = _api.deprecated("3.3")(property(
692692
lambda self: [key for key in mpl.rcParams if 'keymap' in key]))
693-
cnt = cbook.deprecated("3.4")(property( # Not real, but close enough.
693+
cnt = _api.deprecated("3.4")(property( # Not real, but close enough.
694694
lambda self: sum(len(d) for d in self._observers.callbacks.values())))
695-
change_observers = cbook.deprecated("3.4")(property(
695+
change_observers = _api.deprecated("3.4")(property(
696696
lambda self: self._observers.callbacks['change']))
697-
submit_observers = cbook.deprecated("3.4")(property(
697+
submit_observers = _api.deprecated("3.4")(property(
698698
lambda self: self._observers.callbacks['submit']))
699699

700700
def __init__(self, ax, label, initial='',
@@ -1005,9 +1005,9 @@ def __init__(self, ax, labels, active=0, activecolor='blue'):
10051005

10061006
self._observers = cbook.CallbackRegistry()
10071007

1008-
cnt = cbook.deprecated("3.4")(property( # Not real, but close enough.
1008+
cnt = _api.deprecated("3.4")(property( # Not real, but close enough.
10091009
lambda self: len(self._observers.callbacks['clicked'])))
1010-
observers = cbook.deprecated("3.4")(property(
1010+
observers = _api.deprecated("3.4")(property(
10111011
lambda self: self._observers.callbacks['clicked']))
10121012

10131013
def _clicked(self, event):
@@ -1133,17 +1133,17 @@ def _on_reset(self, event):
11331133
event.canvas.draw()
11341134
self.targetfig.canvas.draw()
11351135

1136-
axleft = cbook.deprecated("3.3")(
1136+
axleft = _api.deprecated("3.3")(
11371137
property(lambda self: self.sliderleft.ax))
1138-
axright = cbook.deprecated("3.3")(
1138+
axright = _api.deprecated("3.3")(
11391139
property(lambda self: self.sliderright.ax))
1140-
axbottom = cbook.deprecated("3.3")(
1140+
axbottom = _api.deprecated("3.3")(
11411141
property(lambda self: self.sliderbottom.ax))
1142-
axtop = cbook.deprecated("3.3")(
1142+
axtop = _api.deprecated("3.3")(
11431143
property(lambda self: self.slidertop.ax))
1144-
axwspace = cbook.deprecated("3.3")(
1144+
axwspace = _api.deprecated("3.3")(
11451145
property(lambda self: self.sliderwspace.ax))
1146-
axhspace = cbook.deprecated("3.3")(
1146+
axhspace = _api.deprecated("3.3")(
11471147
property(lambda self: self.sliderhspace.ax))
11481148

11491149
@_api.deprecated("3.3")

lib/mpl_toolkits/mplot3d/axes3d.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -181,11 +181,11 @@ def get_zaxis(self):
181181
get_zgridlines = _axis_method_wrapper("zaxis", "get_gridlines")
182182
get_zticklines = _axis_method_wrapper("zaxis", "get_ticklines")
183183

184-
w_xaxis = cbook.deprecated("3.1", alternative="xaxis", pending=True)(
184+
w_xaxis = _api.deprecated("3.1", alternative="xaxis", pending=True)(
185185
property(lambda self: self.xaxis))
186-
w_yaxis = cbook.deprecated("3.1", alternative="yaxis", pending=True)(
186+
w_yaxis = _api.deprecated("3.1", alternative="yaxis", pending=True)(
187187
property(lambda self: self.yaxis))
188-
w_zaxis = cbook.deprecated("3.1", alternative="zaxis", pending=True)(
188+
w_zaxis = _api.deprecated("3.1", alternative="zaxis", pending=True)(
189189
property(lambda self: self.zaxis))
190190

191191
def _get_axis_list(self):
@@ -406,8 +406,8 @@ def draw(self, renderer):
406406
# the attributes listed below, and they are temporarily attached to
407407
# the _class_ in the `_setattr_cm` call. These can both be removed
408408
# once the deprecation expires
409-
name: cbook.deprecated('3.4', name=name,
410-
alternative=f'self.axes.{name}')(
409+
name: _api.deprecated('3.4', name=name,
410+
alternative=f'self.axes.{name}')(
411411
property(lambda self, _value=getattr(self, name): _value))
412412
for name in ['M', 'vvec', 'eye', 'get_axis_position']
413413
}

0 commit comments

Comments
 (0)