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

Commit1c20824

Browse files
authored
Merge pull request#18823 from timhoffm/update-deprecation-api
Move from @cbook.deprecated to @_api.deprecated
2 parents07145c2 +47f73d7 commit1c20824

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

47 files changed

+193
-186
lines changed

‎.flake8

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@ per-file-ignores =
4949
tools/subset.py: E221, E251, E261, E302, E501
5050

5151
lib/matplotlib/__init__.py: F401
52+
lib/matplotlib/_api/__init__.py: F401
5253
lib/matplotlib/_cm.py: E202, E203, E302
5354
lib/matplotlib/_mathtext.py: E221, E251
5455
lib/matplotlib/_mathtext_data.py: E203, E261

‎lib/matplotlib/_api/__init__.py

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

18+
from .deprecationimport (
19+
deprecated,warn_deprecated,
20+
_rename_parameter,_delete_parameter,_make_keyword_only,
21+
_deprecate_method_override,_deprecate_privatize_attribute,
22+
_suppress_matplotlib_deprecation_warning,
23+
MatplotlibDeprecationWarning)
24+
1825

1926
defcheck_in_list(_values,*,_print_supported_values=True,**kwargs):
2027
"""

‎lib/matplotlib/_api/deprecation.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ class MatplotlibDeprecationWarning(UserWarning):
3030

3131

3232
# mplDeprecation is deprecated. Use MatplotlibDeprecationWarning instead.
33+
# remove when removing the re-import from cbook
3334
mplDeprecation=MatplotlibDeprecationWarning
3435

3536

‎lib/matplotlib/_mathtext.py

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
ParseResults,QuotedString,Regex,StringEnd,Suppress,ZeroOrMore)
1919

2020
importmatplotlibasmpl
21-
from .importcbook
21+
from .import_api,cbook
2222
from ._mathtext_dataimport (
2323
latex_to_bakoma,latex_to_standard,stix_virtual_fonts,tex2uni)
2424
from .afmimportAFM
@@ -91,7 +91,7 @@ def __init__(self, default_font_prop, mathtext_backend):
9191
self.mathtext_backend=mathtext_backend
9292
self.used_characters= {}
9393

94-
@cbook.deprecated("3.4")
94+
@_api.deprecated("3.4")
9595
defdestroy(self):
9696
"""
9797
Fix any cyclical references before the object is about
@@ -234,7 +234,7 @@ def __init__(self, default_font_prop, mathtext_backend):
234234
self._fonts['default']=default_font
235235
self._fonts['regular']=default_font
236236

237-
@cbook.deprecated("3.4")
237+
@_api.deprecated("3.4")
238238
defdestroy(self):
239239
self.glyphd=None
240240
super().destroy()
@@ -1577,43 +1577,43 @@ def grow(self):
15771577
# Some convenient ways to get common kinds of glue
15781578

15791579

1580-
@cbook.deprecated("3.3",alternative="Glue('fil')")
1580+
@_api.deprecated("3.3",alternative="Glue('fil')")
15811581
classFil(Glue):
15821582
def__init__(self):
15831583
super().__init__('fil')
15841584

15851585

1586-
@cbook.deprecated("3.3",alternative="Glue('fill')")
1586+
@_api.deprecated("3.3",alternative="Glue('fill')")
15871587
classFill(Glue):
15881588
def__init__(self):
15891589
super().__init__('fill')
15901590

15911591

1592-
@cbook.deprecated("3.3",alternative="Glue('filll')")
1592+
@_api.deprecated("3.3",alternative="Glue('filll')")
15931593
classFilll(Glue):
15941594
def__init__(self):
15951595
super().__init__('filll')
15961596

15971597

1598-
@cbook.deprecated("3.3",alternative="Glue('neg_fil')")
1598+
@_api.deprecated("3.3",alternative="Glue('neg_fil')")
15991599
classNegFil(Glue):
16001600
def__init__(self):
16011601
super().__init__('neg_fil')
16021602

16031603

1604-
@cbook.deprecated("3.3",alternative="Glue('neg_fill')")
1604+
@_api.deprecated("3.3",alternative="Glue('neg_fill')")
16051605
classNegFill(Glue):
16061606
def__init__(self):
16071607
super().__init__('neg_fill')
16081608

16091609

1610-
@cbook.deprecated("3.3",alternative="Glue('neg_filll')")
1610+
@_api.deprecated("3.3",alternative="Glue('neg_filll')")
16111611
classNegFilll(Glue):
16121612
def__init__(self):
16131613
super().__init__('neg_filll')
16141614

16151615

1616-
@cbook.deprecated("3.3",alternative="Glue('ss')")
1616+
@_api.deprecated("3.3",alternative="Glue('ss')")
16171617
classSsGlue(Glue):
16181618
def__init__(self):
16191619
super().__init__('ss')

‎lib/matplotlib/animation.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -445,7 +445,7 @@ def __del__(self):
445445
ifself._tmpdir:
446446
self._tmpdir.cleanup()
447447

448-
@cbook.deprecated("3.3")
448+
@_api.deprecated("3.3")
449449
@property
450450
defclear_temp(self):
451451
returnself._clear_temp
@@ -641,7 +641,7 @@ def _args(self):
641641

642642

643643
# Base class of avconv information. AVConv has identical arguments to FFMpeg.
644-
@cbook.deprecated('3.3')
644+
@_api.deprecated('3.3')
645645
classAVConvBase(FFMpegBase):
646646
"""
647647
Mixin class for avconv output.

‎lib/matplotlib/artist.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
importnumpyasnp
1010

1111
importmatplotlibasmpl
12-
from .importcbook,docstring
12+
from .import_api,cbook,docstring
1313
from .pathimportPath
1414
from .transformsimport (Bbox,IdentityTransform,Transform,TransformedBbox,
1515
TransformedPatchPath,TransformedPath)
@@ -456,7 +456,7 @@ def contains(self, mouseevent):
456456
_log.warning("%r needs 'contains' method",self.__class__.__name__)
457457
returnFalse, {}
458458

459-
@cbook.deprecated("3.3",alternative="set_picker")
459+
@_api.deprecated("3.3",alternative="set_picker")
460460
defset_contains(self,picker):
461461
"""
462462
Define a custom contains test for the artist.
@@ -484,7 +484,7 @@ def contains(artist: Artist, event: MouseEvent) -> bool, dict
484484
raiseTypeError("picker is not a callable")
485485
self._contains=picker
486486

487-
@cbook.deprecated("3.3",alternative="get_picker")
487+
@_api.deprecated("3.3",alternative="get_picker")
488488
defget_contains(self):
489489
"""
490490
Return the custom contains function of the artist if set, or *None*.

‎lib/matplotlib/axes/_base.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1602,7 +1602,7 @@ def get_data_ratio(self):
16021602
ysize=max(abs(tymax-tymin),1e-30)
16031603
returnysize/xsize
16041604

1605-
@cbook.deprecated("3.2")
1605+
@_api.deprecated("3.2")
16061606
defget_data_ratio_log(self):
16071607
"""
16081608
Return the aspect ratio of the raw data in log scale.
@@ -2213,7 +2213,7 @@ def update_datalim(self, xys, updatex=True, updatey=True):
22132213
updatex=updatex,updatey=updatey)
22142214
self.ignore_existing_data_limits=False
22152215

2216-
@cbook.deprecated(
2216+
@_api.deprecated(
22172217
"3.3",alternative="ax.dataLim.set(Bbox.union([ax.dataLim, bounds]))")
22182218
defupdate_datalim_bounds(self,bounds):
22192219
"""

‎lib/matplotlib/axes/_subplots.py

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
importfunctools
22
importuuid
33

4-
frommatplotlibimportcbook,docstring
4+
frommatplotlibimport_api,cbook,docstring
55
importmatplotlib.artistasmartist
66
frommatplotlib.axes._axesimportAxes
77
frommatplotlib.gridspecimportGridSpec,SubplotSpec
@@ -47,15 +47,15 @@ def __reduce__(self):
4747
(axes_class,),
4848
self.__getstate__())
4949

50-
@cbook.deprecated(
50+
@_api.deprecated(
5151
"3.4",alternative="get_subplotspec",
5252
addendum="(get_subplotspec returns a SubplotSpec instance.)")
5353
defget_geometry(self):
5454
"""Get the subplot geometry, e.g., (2, 2, 3)."""
5555
rows,cols,num1,num2=self.get_subplotspec().get_geometry()
5656
returnrows,cols,num1+1# for compatibility
5757

58-
@cbook.deprecated("3.4",alternative="set_subplotspec")
58+
@_api.deprecated("3.4",alternative="set_subplotspec")
5959
defchange_geometry(self,numrows,numcols,num):
6060
"""Change subplot geometry, e.g., from (1, 1, 1) to (2, 2, 3)."""
6161
self._subplotspec=GridSpec(numrows,numcols,
@@ -76,51 +76,51 @@ def get_gridspec(self):
7676
"""Return the `.GridSpec` instance associated with the subplot."""
7777
returnself._subplotspec.get_gridspec()
7878

79-
@cbook.deprecated(
79+
@_api.deprecated(
8080
"3.4",alternative="get_subplotspec().get_position(self.figure)")
8181
@property
8282
deffigbox(self):
8383
returnself.get_subplotspec().get_position(self.figure)
8484

85-
@cbook.deprecated("3.4",alternative="get_gridspec().nrows")
85+
@_api.deprecated("3.4",alternative="get_gridspec().nrows")
8686
@property
8787
defnumRows(self):
8888
returnself.get_gridspec().nrows
8989

90-
@cbook.deprecated("3.4",alternative="get_gridspec().ncols")
90+
@_api.deprecated("3.4",alternative="get_gridspec().ncols")
9191
@property
9292
defnumCols(self):
9393
returnself.get_gridspec().ncols
9494

95-
@cbook.deprecated("3.4")
95+
@_api.deprecated("3.4")
9696
defupdate_params(self):
9797
"""Update the subplot position from ``self.figure.subplotpars``."""
9898
# Now a no-op, as figbox/numRows/numCols are (deprecated) auto-updating
9999
# properties.
100100

101-
@cbook.deprecated("3.2",alternative="ax.get_subplotspec().rowspan.start")
101+
@_api.deprecated("3.2",alternative="ax.get_subplotspec().rowspan.start")
102102
@property
103103
defrowNum(self):
104104
returnself.get_subplotspec().rowspan.start
105105

106-
@cbook.deprecated("3.2",alternative="ax.get_subplotspec().colspan.start")
106+
@_api.deprecated("3.2",alternative="ax.get_subplotspec().colspan.start")
107107
@property
108108
defcolNum(self):
109109
returnself.get_subplotspec().colspan.start
110110

111-
@cbook.deprecated("3.4",alternative="ax.get_subplotspec().is_first_row()")
111+
@_api.deprecated("3.4",alternative="ax.get_subplotspec().is_first_row()")
112112
defis_first_row(self):
113113
returnself.get_subplotspec().rowspan.start==0
114114

115-
@cbook.deprecated("3.4",alternative="ax.get_subplotspec().is_last_row()")
115+
@_api.deprecated("3.4",alternative="ax.get_subplotspec().is_last_row()")
116116
defis_last_row(self):
117117
returnself.get_subplotspec().rowspan.stop==self.get_gridspec().nrows
118118

119-
@cbook.deprecated("3.4",alternative="ax.get_subplotspec().is_first_col()")
119+
@_api.deprecated("3.4",alternative="ax.get_subplotspec().is_first_col()")
120120
defis_first_col(self):
121121
returnself.get_subplotspec().colspan.start==0
122122

123-
@cbook.deprecated("3.4",alternative="ax.get_subplotspec().is_last_col()")
123+
@_api.deprecated("3.4",alternative="ax.get_subplotspec().is_last_col()")
124124
defis_last_col(self):
125125
returnself.get_subplotspec().colspan.stop==self.get_gridspec().ncols
126126

‎lib/matplotlib/axis.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -194,7 +194,7 @@ def __init__(self, axes, loc, label=None,
194194
self.update_position(loc)
195195

196196
@property
197-
@cbook.deprecated("3.1",alternative="Tick.label1",pending=True)
197+
@_api.deprecated("3.1",alternative="Tick.label1",pending=True)
198198
deflabel(self):
199199
returnself.label1
200200

@@ -796,7 +796,7 @@ def clear(self):
796796
self.set_units(None)
797797
self.stale=True
798798

799-
@cbook.deprecated("3.4",alternative="Axis.clear()")
799+
@_api.deprecated("3.4",alternative="Axis.clear()")
800800
defcla(self):
801801
"""Clear this axis."""
802802
returnself.clear()
@@ -1011,13 +1011,13 @@ def get_ticklabel_extents(self, renderer):
10111011
bbox2=mtransforms.Bbox.from_extents(0,0,0,0)
10121012
returnbbox,bbox2
10131013

1014-
@cbook.deprecated("3.2")
1014+
@_api.deprecated("3.2")
10151015
defset_smart_bounds(self,value):
10161016
"""Set the axis to have smart bounds."""
10171017
self._smart_bounds=value
10181018
self.stale=True
10191019

1020-
@cbook.deprecated("3.2")
1020+
@_api.deprecated("3.2")
10211021
defget_smart_bounds(self):
10221022
"""Return whether the axis has smart bounds."""
10231023
returnself._smart_bounds
@@ -1900,12 +1900,12 @@ def _update_offset_text_position(self, bboxes, bboxes2):
19001900
"""
19011901
raiseNotImplementedError('Derived must override')
19021902

1903-
@cbook.deprecated("3.3")
1903+
@_api.deprecated("3.3")
19041904
defpan(self,numsteps):
19051905
"""Pan by *numsteps* (can be positive or negative)."""
19061906
self.major.locator.pan(numsteps)
19071907

1908-
@cbook.deprecated("3.3")
1908+
@_api.deprecated("3.3")
19091909
defzoom(self,direction):
19101910
"""Zoom in/out on axis; if *direction* is >0 zoom in, else zoom out."""
19111911
self.major.locator.zoom(direction)

‎lib/matplotlib/backend_bases.py

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@
4343

4444
importmatplotlibasmpl
4545
frommatplotlibimport (
46-
backend_toolsastools,cbook,colors,textpath,tight_bbox,
46+
_api,backend_toolsastools,cbook,colors,textpath,tight_bbox,
4747
transforms,widgets,get_backend,is_interactive,rcParams)
4848
frommatplotlib._pylab_helpersimportGcf
4949
frommatplotlib.backend_managersimportToolManager
@@ -2254,7 +2254,7 @@ def get_default_filetype(cls):
22542254
"""
22552255
returnrcParams['savefig.format']
22562256

2257-
@cbook.deprecated(
2257+
@_api.deprecated(
22582258
"3.4",alternative="manager.get_window_title or GUI-specific methods")
22592259
defget_window_title(self):
22602260
"""
@@ -2264,7 +2264,7 @@ def get_window_title(self):
22642264
ifself.managerisnotNone:
22652265
returnself.manager.get_window_title()
22662266

2267-
@cbook.deprecated(
2267+
@_api.deprecated(
22682268
"3.4",alternative="manager.set_window_title or GUI-specific methods")
22692269
defset_window_title(self,title):
22702270
"""
@@ -2945,7 +2945,7 @@ def forward(self, *args):
29452945
self.set_history_buttons()
29462946
self._update_view()
29472947

2948-
@cbook.deprecated("3.3",alternative="__init__")
2948+
@_api.deprecated("3.3",alternative="__init__")
29492949
def_init_toolbar(self):
29502950
"""
29512951
This is where you actually build the GUI widgets (called by
@@ -3050,11 +3050,11 @@ def _zoom_pan_handler(self, event):
30503050
elifevent.name=="button_release_event":
30513051
self.release_zoom(event)
30523052

3053-
@cbook.deprecated("3.3")
3053+
@_api.deprecated("3.3")
30543054
defpress(self,event):
30553055
"""Called whenever a mouse button is pressed."""
30563056

3057-
@cbook.deprecated("3.3")
3057+
@_api.deprecated("3.3")
30583058
defrelease(self,event):
30593059
"""Callback for mouse button release."""
30603060

@@ -3247,7 +3247,7 @@ def push_current(self):
32473247
foraxinself.canvas.figure.axes}))
32483248
self.set_history_buttons()
32493249

3250-
@cbook.deprecated("3.3",alternative="toolbar.canvas.draw_idle()")
3250+
@_api.deprecated("3.3",alternative="toolbar.canvas.draw_idle()")
32513251
defdraw(self):
32523252
"""Redraw the canvases, update the locators."""
32533253
self._draw()
@@ -3471,7 +3471,7 @@ def set_message(self, s):
34713471
raiseNotImplementedError
34723472

34733473

3474-
@cbook.deprecated("3.3")
3474+
@_api.deprecated("3.3")
34753475
classStatusbarBase:
34763476
"""Base class for the statusbar."""
34773477
def__init__(self,toolmanager):

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp