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

Skip to content

Commit 51444ba

Browse files
committed
Move from @cbook.deprecated to @_api.deprecated
1 parent 0163d0d commit 51444ba

Some content is hidden

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

46 files changed

+191
-185
lines changed

lib/matplotlib/_api/__init__.py

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

18+
from .deprecation import (
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
def check_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
import matplotlib as mpl
21-
from . import cbook
21+
from . import _api, cbook
2222
from ._mathtext_data import (
2323
latex_to_bakoma, latex_to_standard, stix_virtual_fonts, tex2uni)
2424
from .afm import AFM
@@ -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
def destroy(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
def destroy(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
class Fil(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
class Fill(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
class Filll(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
class NegFil(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
class NegFill(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
class NegFilll(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
class SsGlue(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
if self._tmpdir:
446446
self._tmpdir.cleanup()
447447

448-
@cbook.deprecated("3.3")
448+
@_api.deprecated("3.3")
449449
@property
450450
def clear_temp(self):
451451
return self._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
class AVConvBase(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
import numpy as np
1010

1111
import matplotlib as mpl
12-
from . import cbook, docstring
12+
from . import _api, cbook, docstring
1313
from .path import Path
1414
from .transforms import (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
return False, {}
458458

459-
@cbook.deprecated("3.3", alternative="set_picker")
459+
@_api.deprecated("3.3", alternative="set_picker")
460460
def set_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
raise TypeError("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
def get_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
return ysize / xsize
16041604

1605-
@cbook.deprecated("3.2")
1605+
@_api.deprecated("3.2")
16061606
def get_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
def update_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
import functools
22
import uuid
33

4-
from matplotlib import cbook, docstring
4+
from matplotlib import _api, cbook, docstring
55
import matplotlib.artist as martist
66
from matplotlib.axes._axes import Axes
77
from matplotlib.gridspec import GridSpec, 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
def get_geometry(self):
5454
"""Get the subplot geometry, e.g., (2, 2, 3)."""
5555
rows, cols, num1, num2 = self.get_subplotspec().get_geometry()
5656
return rows, cols, num1 + 1 # for compatibility
5757

58-
@cbook.deprecated("3.4", alternative="set_subplotspec")
58+
@_api.deprecated("3.4", alternative="set_subplotspec")
5959
def change_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
return self._subplotspec.get_gridspec()
7878

79-
@cbook.deprecated(
79+
@_api.deprecated(
8080
"3.4", alternative="get_subplotspec().get_position(self.figure)")
8181
@property
8282
def figbox(self):
8383
return self.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
def numRows(self):
8888
return self.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
def numCols(self):
9393
return self.get_gridspec().ncols
9494

95-
@cbook.deprecated("3.4")
95+
@_api.deprecated("3.4")
9696
def update_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
def rowNum(self):
104104
return self.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
def colNum(self):
109109
return self.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
def is_first_row(self):
113113
return self.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
def is_last_row(self):
117117
return self.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
def is_first_col(self):
121121
return self.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
def is_last_col(self):
125125
return self.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
def label(self):
199199
return self.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
def cla(self):
801801
"""Clear this axis."""
802802
return self.clear()
@@ -1011,13 +1011,13 @@ def get_ticklabel_extents(self, renderer):
10111011
bbox2 = mtransforms.Bbox.from_extents(0, 0, 0, 0)
10121012
return bbox, bbox2
10131013

1014-
@cbook.deprecated("3.2")
1014+
@_api.deprecated("3.2")
10151015
def set_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
def get_smart_bounds(self):
10221022
"""Return whether the axis has smart bounds."""
10231023
return self._smart_bounds
@@ -1900,12 +1900,12 @@ def _update_offset_text_position(self, bboxes, bboxes2):
19001900
"""
19011901
raise NotImplementedError('Derived must override')
19021902

1903-
@cbook.deprecated("3.3")
1903+
@_api.deprecated("3.3")
19041904
def pan(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
def zoom(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
import matplotlib as mpl
4545
from matplotlib import (
46-
backend_tools as tools, cbook, colors, textpath, tight_bbox,
46+
_api, backend_tools as tools, cbook, colors, textpath, tight_bbox,
4747
transforms, widgets, get_backend, is_interactive, rcParams)
4848
from matplotlib._pylab_helpers import Gcf
4949
from matplotlib.backend_managers import ToolManager
@@ -2254,7 +2254,7 @@ def get_default_filetype(cls):
22542254
"""
22552255
return rcParams['savefig.format']
22562256

2257-
@cbook.deprecated(
2257+
@_api.deprecated(
22582258
"3.4", alternative="manager.get_window_title or GUI-specific methods")
22592259
def get_window_title(self):
22602260
"""
@@ -2264,7 +2264,7 @@ def get_window_title(self):
22642264
if self.manager is not None:
22652265
return self.manager.get_window_title()
22662266

2267-
@cbook.deprecated(
2267+
@_api.deprecated(
22682268
"3.4", alternative="manager.set_window_title or GUI-specific methods")
22692269
def set_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
elif event.name == "button_release_event":
30513051
self.release_zoom(event)
30523052

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

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

@@ -3247,7 +3247,7 @@ def push_current(self):
32473247
for ax in self.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
def draw(self):
32523252
"""Redraw the canvases, update the locators."""
32533253
self._draw()
@@ -3471,7 +3471,7 @@ def set_message(self, s):
34713471
raise NotImplementedError
34723472

34733473

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

0 commit comments

Comments
 (0)