Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit99e6240

Browse files
authored
Merge pull request#19151 from timhoffm/change-deprecated-usage
Deprecate @cbook.deprecated and move internal calls to @_api.deprecated
2 parents3798e5f +fa71a21 commit99e6240

File tree

17 files changed

+64
-57
lines changed

17 files changed

+64
-57
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(lambdaself:StringIO()))
798+
pswriter=_api.deprecated("3.4")(property(lambdaself:StringIO()))
799799

800800
def_get_font(self,font):
801801
iffontinself.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(lambdaself:"normal"))
1552+
glue_subtype=_api.deprecated("3.3")(property(lambdaself:"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
lambdaself:'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(lambdaself:None))
2713+
statusbar=_api.deprecated("3.3")(property(lambdaself: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
importfunctools
66

77
importmatplotlibasmpl
8+
frommatplotlibimport_api
89
from ..importfont_manager,ft2font
910
from ..afmimportAFM
1011
from ..backend_basesimportRendererBase
@@ -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
defused_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
classRendererCairo(RendererBase):
124-
fontweights=cbook.deprecated("3.3")(property(lambdaself: {*_f_weights}))
125-
fontangles=cbook.deprecated("3.3")(property(lambdaself: {*_f_angles}))
126-
mathtext_parser=cbook.deprecated("3.4")(
124+
fontweights=_api.deprecated("3.3")(property(lambdaself: {*_f_weights}))
125+
fontangles=_api.deprecated("3.3")(property(lambdaself: {*_f_angles}))
126+
mathtext_parser=_api.deprecated("3.4")(
127127
property(lambdaself: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
classNavigationToolbar2GTK3(NavigationToolbar2,Gtk.Toolbar):
435-
ctx=cbook.deprecated("3.3")(property(
435+
ctx=_api.deprecated("3.3")(property(
436436
lambdaself: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(lambdaself:self._metadata))
935+
metadata=_api.deprecated('3.3')(property(lambdaself: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
lambdaself:MathTextParser("PS")))
228-
used_characters=cbook.deprecated("3.3")(property(
228+
used_characters=_api.deprecated("3.3")(property(
229229
lambdaself: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
importsys
1919

2020
importmatplotlibasmpl
21+
frommatplotlibimport_api
2122

2223

2324
QT_API_PYQT5="PyQt5"
@@ -87,7 +88,7 @@ def _isdeleted(obj): return not shiboken2.isValid(obj)
8788
raiseValueError("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
defis_pyqt5():
9293
returnTrue
9394

@@ -143,7 +144,7 @@ def _isdeleted(obj): return not shiboken.isValid(obj)
143144
raiseValueError("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
defis_pyqt5():
148149
returnFalse
149150

‎lib/matplotlib/cbook/__init__.py

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,12 @@
3030
importmatplotlib
3131
frommatplotlibimport_api,_c_internal_utils
3232
frommatplotlib._api.deprecationimport (
33-
deprecated,warn_deprecated,MatplotlibDeprecationWarning,mplDeprecation)
33+
warn_deprecated,MatplotlibDeprecationWarning,mplDeprecation)
34+
35+
36+
@_api.deprecated("3.4")
37+
defdeprecated(*args,**kwargs):
38+
return_api.deprecated(*args,**kwargs)
3439

3540

3641
def_get_running_interactive_framework():
@@ -287,7 +292,7 @@ def __repr__(self):
287292
return"<an empty list>"
288293

289294

290-
@deprecated("3.3")
295+
@_api.deprecated("3.3")
291296
classIgnoredKeywordWarning(UserWarning):
292297
"""
293298
A class for issuing warnings about keyword arguments that will be ignored
@@ -296,7 +301,7 @@ class IgnoredKeywordWarning(UserWarning):
296301
pass
297302

298303

299-
@deprecated("3.3",alternative="normalize_kwargs")
304+
@_api.deprecated("3.3",alternative="normalize_kwargs")
300305
deflocal_over_kwdict(local_var,kwargs,*keys):
301306
"""
302307
Enforces the priority of a local variable over potentially conflicting
@@ -532,7 +537,7 @@ def flatten(seq, scalarp=is_scalar_or_string):
532537
yieldfromflatten(item,scalarp)
533538

534539

535-
@deprecated("3.3",alternative="os.path.realpath and os.stat")
540+
@_api.deprecated("3.3",alternative="os.path.realpath and os.stat")
536541
@functools.lru_cache()
537542
defget_realpath_and_stat(path):
538543
realpath=os.path.realpath(path)

‎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(lambdaself:self.axes))
685+
ax=_api.deprecated("3.3")(property(lambdaself: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__forcin_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
importmatplotlib
157157
frommatplotlib.backend_basesimportFigureManagerBase
158158
importmatplotlib.pyplotasplt
159-
frommatplotlibimport_pylab_helpers,cbook
159+
frommatplotlibimport_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(lambdaself:mpl.get_cachedir()))
79-
rgba_arrayd=cbook.deprecated("3.3")(property(lambdaself: {}))
79+
rgba_arrayd=_api.deprecated("3.3")(property(lambdaself: {}))
8080
_fonts= {}# Only for deprecation period.
81-
serif=cbook.deprecated("3.3")(property(
81+
serif=_api.deprecated("3.3")(property(
8282
lambdaself:self._fonts.get("serif", ('cmr',''))))
83-
sans_serif=cbook.deprecated("3.3")(property(
83+
sans_serif=_api.deprecated("3.3")(property(
8484
lambdaself:self._fonts.get("sans-serif", ('cmss',''))))
85-
cursive=cbook.deprecated("3.3")(property(
85+
cursive=_api.deprecated("3.3")(property(
8686
lambdaself:
8787
self._fonts.get("cursive", ('pzc',r'\usepackage{chancery}'))))
88-
monospace=cbook.deprecated("3.3")(property(
88+
monospace=_api.deprecated("3.3")(property(
8989
lambdaself: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
ifargs:
21202120
if'nbins'inkwargs:
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
iflen(args)>1:
21282128
raiseValueError(

‎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(lambdaself:self._cids))
112+
cids=_api.deprecated("3.4")(property(lambdaself: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
lambdaself:len(self._observers.callbacks['clicked'])))
156-
observers=cbook.deprecated("3.4")(property(
156+
observers=_api.deprecated("3.4")(property(
157157
lambdaself: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
lambdaself:len(self._observers.callbacks['changed'])))
248-
observers=cbook.deprecated("3.4")(property(
248+
observers=_api.deprecated("3.4")(property(
249249
lambdaself: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
lambdaself:len(self._observers.callbacks['clicked'])))
541-
observers=cbook.deprecated("3.4")(property(
541+
observers=_api.deprecated("3.4")(property(
542542
lambdaself: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
lambdaself: [keyforkeyinmpl.rcParamsif'keymap'inkey]))
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
lambdaself:sum(len(d)fordinself._observers.callbacks.values())))
695-
change_observers=cbook.deprecated("3.4")(property(
695+
change_observers=_api.deprecated("3.4")(property(
696696
lambdaself:self._observers.callbacks['change']))
697-
submit_observers=cbook.deprecated("3.4")(property(
697+
submit_observers=_api.deprecated("3.4")(property(
698698
lambdaself: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
lambdaself:len(self._observers.callbacks['clicked'])))
1010-
observers=cbook.deprecated("3.4")(property(
1010+
observers=_api.deprecated("3.4")(property(
10111011
lambdaself: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(lambdaself:self.sliderleft.ax))
1138-
axright=cbook.deprecated("3.3")(
1138+
axright=_api.deprecated("3.3")(
11391139
property(lambdaself:self.sliderright.ax))
1140-
axbottom=cbook.deprecated("3.3")(
1140+
axbottom=_api.deprecated("3.3")(
11411141
property(lambdaself:self.sliderbottom.ax))
1142-
axtop=cbook.deprecated("3.3")(
1142+
axtop=_api.deprecated("3.3")(
11431143
property(lambdaself:self.slidertop.ax))
1144-
axwspace=cbook.deprecated("3.3")(
1144+
axwspace=_api.deprecated("3.3")(
11451145
property(lambdaself:self.sliderwspace.ax))
1146-
axhspace=cbook.deprecated("3.3")(
1146+
axhspace=_api.deprecated("3.3")(
11471147
property(lambdaself: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(lambdaself: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(lambdaself: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(lambdaself: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(lambdaself,_value=getattr(self,name):_value))
412412
fornamein ['M','vvec','eye','get_axis_position']
413413
}

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp