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

Skip to content

Move from @cbook.deprecated to @_api.deprecated #18823

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Nov 5, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .flake8
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ per-file-ignores =
tools/subset.py: E221, E251, E261, E302, E501

lib/matplotlib/__init__.py: F401
lib/matplotlib/_api/__init__.py: F401
lib/matplotlib/_cm.py: E202, E203, E302
lib/matplotlib/_mathtext.py: E221, E251
lib/matplotlib/_mathtext_data.py: E203, E261
Expand Down
7 changes: 7 additions & 0 deletions lib/matplotlib/_api/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,13 @@
import sys
import warnings

from .deprecation import (
deprecated, warn_deprecated,
_rename_parameter, _delete_parameter, _make_keyword_only,
_deprecate_method_override, _deprecate_privatize_attribute,
_suppress_matplotlib_deprecation_warning,
MatplotlibDeprecationWarning)


def check_in_list(_values, *, _print_supported_values=True, **kwargs):
"""
Expand Down
1 change: 1 addition & 0 deletions lib/matplotlib/_api/deprecation.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ class MatplotlibDeprecationWarning(UserWarning):


# mplDeprecation is deprecated. Use MatplotlibDeprecationWarning instead.
# remove when removing the re-import from cbook
mplDeprecation = MatplotlibDeprecationWarning


Expand Down
20 changes: 10 additions & 10 deletions lib/matplotlib/_mathtext.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
ParseResults, QuotedString, Regex, StringEnd, Suppress, ZeroOrMore)

import matplotlib as mpl
from . import cbook
from . import _api, cbook
from ._mathtext_data import (
latex_to_bakoma, latex_to_standard, stix_virtual_fonts, tex2uni)
from .afm import AFM
Expand Down Expand Up @@ -91,7 +91,7 @@ def __init__(self, default_font_prop, mathtext_backend):
self.mathtext_backend = mathtext_backend
self.used_characters = {}

@cbook.deprecated("3.4")
@_api.deprecated("3.4")
def destroy(self):
"""
Fix any cyclical references before the object is about
Expand Down Expand Up @@ -234,7 +234,7 @@ def __init__(self, default_font_prop, mathtext_backend):
self._fonts['default'] = default_font
self._fonts['regular'] = default_font

@cbook.deprecated("3.4")
@_api.deprecated("3.4")
def destroy(self):
self.glyphd = None
super().destroy()
Expand Down Expand Up @@ -1577,43 +1577,43 @@ def grow(self):
# Some convenient ways to get common kinds of glue


@cbook.deprecated("3.3", alternative="Glue('fil')")
@_api.deprecated("3.3", alternative="Glue('fil')")
class Fil(Glue):
def __init__(self):
super().__init__('fil')


@cbook.deprecated("3.3", alternative="Glue('fill')")
@_api.deprecated("3.3", alternative="Glue('fill')")
class Fill(Glue):
def __init__(self):
super().__init__('fill')


@cbook.deprecated("3.3", alternative="Glue('filll')")
@_api.deprecated("3.3", alternative="Glue('filll')")
class Filll(Glue):
def __init__(self):
super().__init__('filll')


@cbook.deprecated("3.3", alternative="Glue('neg_fil')")
@_api.deprecated("3.3", alternative="Glue('neg_fil')")
class NegFil(Glue):
def __init__(self):
super().__init__('neg_fil')


@cbook.deprecated("3.3", alternative="Glue('neg_fill')")
@_api.deprecated("3.3", alternative="Glue('neg_fill')")
class NegFill(Glue):
def __init__(self):
super().__init__('neg_fill')


@cbook.deprecated("3.3", alternative="Glue('neg_filll')")
@_api.deprecated("3.3", alternative="Glue('neg_filll')")
class NegFilll(Glue):
def __init__(self):
super().__init__('neg_filll')


@cbook.deprecated("3.3", alternative="Glue('ss')")
@_api.deprecated("3.3", alternative="Glue('ss')")
class SsGlue(Glue):
def __init__(self):
super().__init__('ss')
Expand Down
4 changes: 2 additions & 2 deletions lib/matplotlib/animation.py
Original file line number Diff line number Diff line change
Expand Up @@ -445,7 +445,7 @@ def __del__(self):
if self._tmpdir:
self._tmpdir.cleanup()

@cbook.deprecated("3.3")
@_api.deprecated("3.3")
@property
def clear_temp(self):
return self._clear_temp
Expand Down Expand Up @@ -641,7 +641,7 @@ def _args(self):


# Base class of avconv information. AVConv has identical arguments to FFMpeg.
@cbook.deprecated('3.3')
@_api.deprecated('3.3')
class AVConvBase(FFMpegBase):
"""
Mixin class for avconv output.
Expand Down
6 changes: 3 additions & 3 deletions lib/matplotlib/artist.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
import numpy as np

import matplotlib as mpl
from . import cbook, docstring
from . import _api, cbook, docstring
from .path import Path
from .transforms import (Bbox, IdentityTransform, Transform, TransformedBbox,
TransformedPatchPath, TransformedPath)
Expand Down Expand Up @@ -456,7 +456,7 @@ def contains(self, mouseevent):
_log.warning("%r needs 'contains' method", self.__class__.__name__)
return False, {}

@cbook.deprecated("3.3", alternative="set_picker")
@_api.deprecated("3.3", alternative="set_picker")
def set_contains(self, picker):
"""
Define a custom contains test for the artist.
Expand Down Expand Up @@ -484,7 +484,7 @@ def contains(artist: Artist, event: MouseEvent) -> bool, dict
raise TypeError("picker is not a callable")
self._contains = picker

@cbook.deprecated("3.3", alternative="get_picker")
@_api.deprecated("3.3", alternative="get_picker")
def get_contains(self):
"""
Return the custom contains function of the artist if set, or *None*.
Expand Down
4 changes: 2 additions & 2 deletions lib/matplotlib/axes/_base.py
Original file line number Diff line number Diff line change
Expand Up @@ -1602,7 +1602,7 @@ def get_data_ratio(self):
ysize = max(abs(tymax - tymin), 1e-30)
return ysize / xsize

@cbook.deprecated("3.2")
@_api.deprecated("3.2")
def get_data_ratio_log(self):
"""
Return the aspect ratio of the raw data in log scale.
Expand Down Expand Up @@ -2213,7 +2213,7 @@ def update_datalim(self, xys, updatex=True, updatey=True):
updatex=updatex, updatey=updatey)
self.ignore_existing_data_limits = False

@cbook.deprecated(
@_api.deprecated(
"3.3", alternative="ax.dataLim.set(Bbox.union([ax.dataLim, bounds]))")
def update_datalim_bounds(self, bounds):
"""
Expand Down
26 changes: 13 additions & 13 deletions lib/matplotlib/axes/_subplots.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import functools
import uuid

from matplotlib import cbook, docstring
from matplotlib import _api, cbook, docstring
import matplotlib.artist as martist
from matplotlib.axes._axes import Axes
from matplotlib.gridspec import GridSpec, SubplotSpec
Expand Down Expand Up @@ -47,15 +47,15 @@ def __reduce__(self):
(axes_class,),
self.__getstate__())

@cbook.deprecated(
@_api.deprecated(
"3.4", alternative="get_subplotspec",
addendum="(get_subplotspec returns a SubplotSpec instance.)")
def get_geometry(self):
"""Get the subplot geometry, e.g., (2, 2, 3)."""
rows, cols, num1, num2 = self.get_subplotspec().get_geometry()
return rows, cols, num1 + 1 # for compatibility

@cbook.deprecated("3.4", alternative="set_subplotspec")
@_api.deprecated("3.4", alternative="set_subplotspec")
def change_geometry(self, numrows, numcols, num):
"""Change subplot geometry, e.g., from (1, 1, 1) to (2, 2, 3)."""
self._subplotspec = GridSpec(numrows, numcols,
Expand All @@ -76,51 +76,51 @@ def get_gridspec(self):
"""Return the `.GridSpec` instance associated with the subplot."""
return self._subplotspec.get_gridspec()

@cbook.deprecated(
@_api.deprecated(
"3.4", alternative="get_subplotspec().get_position(self.figure)")
@property
def figbox(self):
return self.get_subplotspec().get_position(self.figure)

@cbook.deprecated("3.4", alternative="get_gridspec().nrows")
@_api.deprecated("3.4", alternative="get_gridspec().nrows")
@property
def numRows(self):
return self.get_gridspec().nrows

@cbook.deprecated("3.4", alternative="get_gridspec().ncols")
@_api.deprecated("3.4", alternative="get_gridspec().ncols")
@property
def numCols(self):
return self.get_gridspec().ncols

@cbook.deprecated("3.4")
@_api.deprecated("3.4")
def update_params(self):
"""Update the subplot position from ``self.figure.subplotpars``."""
# Now a no-op, as figbox/numRows/numCols are (deprecated) auto-updating
# properties.

@cbook.deprecated("3.2", alternative="ax.get_subplotspec().rowspan.start")
@_api.deprecated("3.2", alternative="ax.get_subplotspec().rowspan.start")
@property
def rowNum(self):
return self.get_subplotspec().rowspan.start

@cbook.deprecated("3.2", alternative="ax.get_subplotspec().colspan.start")
@_api.deprecated("3.2", alternative="ax.get_subplotspec().colspan.start")
@property
def colNum(self):
return self.get_subplotspec().colspan.start

@cbook.deprecated("3.4", alternative="ax.get_subplotspec().is_first_row()")
@_api.deprecated("3.4", alternative="ax.get_subplotspec().is_first_row()")
def is_first_row(self):
return self.get_subplotspec().rowspan.start == 0

@cbook.deprecated("3.4", alternative="ax.get_subplotspec().is_last_row()")
@_api.deprecated("3.4", alternative="ax.get_subplotspec().is_last_row()")
def is_last_row(self):
return self.get_subplotspec().rowspan.stop == self.get_gridspec().nrows

@cbook.deprecated("3.4", alternative="ax.get_subplotspec().is_first_col()")
@_api.deprecated("3.4", alternative="ax.get_subplotspec().is_first_col()")
def is_first_col(self):
return self.get_subplotspec().colspan.start == 0

@cbook.deprecated("3.4", alternative="ax.get_subplotspec().is_last_col()")
@_api.deprecated("3.4", alternative="ax.get_subplotspec().is_last_col()")
def is_last_col(self):
return self.get_subplotspec().colspan.stop == self.get_gridspec().ncols

Expand Down
12 changes: 6 additions & 6 deletions lib/matplotlib/axis.py
Original file line number Diff line number Diff line change
Expand Up @@ -194,7 +194,7 @@ def __init__(self, axes, loc, label=None,
self.update_position(loc)

@property
@cbook.deprecated("3.1", alternative="Tick.label1", pending=True)
@_api.deprecated("3.1", alternative="Tick.label1", pending=True)
def label(self):
return self.label1

Expand Down Expand Up @@ -796,7 +796,7 @@ def clear(self):
self.set_units(None)
self.stale = True

@cbook.deprecated("3.4", alternative="Axis.clear()")
@_api.deprecated("3.4", alternative="Axis.clear()")
def cla(self):
"""Clear this axis."""
return self.clear()
Expand Down Expand Up @@ -1011,13 +1011,13 @@ def get_ticklabel_extents(self, renderer):
bbox2 = mtransforms.Bbox.from_extents(0, 0, 0, 0)
return bbox, bbox2

@cbook.deprecated("3.2")
@_api.deprecated("3.2")
def set_smart_bounds(self, value):
"""Set the axis to have smart bounds."""
self._smart_bounds = value
self.stale = True

@cbook.deprecated("3.2")
@_api.deprecated("3.2")
def get_smart_bounds(self):
"""Return whether the axis has smart bounds."""
return self._smart_bounds
Expand Down Expand Up @@ -1900,12 +1900,12 @@ def _update_offset_text_position(self, bboxes, bboxes2):
"""
raise NotImplementedError('Derived must override')

@cbook.deprecated("3.3")
@_api.deprecated("3.3")
def pan(self, numsteps):
"""Pan by *numsteps* (can be positive or negative)."""
self.major.locator.pan(numsteps)

@cbook.deprecated("3.3")
@_api.deprecated("3.3")
def zoom(self, direction):
"""Zoom in/out on axis; if *direction* is >0 zoom in, else zoom out."""
self.major.locator.zoom(direction)
Expand Down
16 changes: 8 additions & 8 deletions lib/matplotlib/backend_bases.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@

import matplotlib as mpl
from matplotlib import (
backend_tools as tools, cbook, colors, textpath, tight_bbox,
_api, backend_tools as tools, cbook, colors, textpath, tight_bbox,
transforms, widgets, get_backend, is_interactive, rcParams)
from matplotlib._pylab_helpers import Gcf
from matplotlib.backend_managers import ToolManager
Expand Down Expand Up @@ -2254,7 +2254,7 @@ def get_default_filetype(cls):
"""
return rcParams['savefig.format']

@cbook.deprecated(
@_api.deprecated(
"3.4", alternative="manager.get_window_title or GUI-specific methods")
def get_window_title(self):
"""
Expand All @@ -2264,7 +2264,7 @@ def get_window_title(self):
if self.manager is not None:
return self.manager.get_window_title()

@cbook.deprecated(
@_api.deprecated(
"3.4", alternative="manager.set_window_title or GUI-specific methods")
def set_window_title(self, title):
"""
Expand Down Expand Up @@ -2945,7 +2945,7 @@ def forward(self, *args):
self.set_history_buttons()
self._update_view()

@cbook.deprecated("3.3", alternative="__init__")
@_api.deprecated("3.3", alternative="__init__")
def _init_toolbar(self):
"""
This is where you actually build the GUI widgets (called by
Expand Down Expand Up @@ -3050,11 +3050,11 @@ def _zoom_pan_handler(self, event):
elif event.name == "button_release_event":
self.release_zoom(event)

@cbook.deprecated("3.3")
@_api.deprecated("3.3")
def press(self, event):
"""Called whenever a mouse button is pressed."""

@cbook.deprecated("3.3")
@_api.deprecated("3.3")
def release(self, event):
"""Callback for mouse button release."""

Expand Down Expand Up @@ -3247,7 +3247,7 @@ def push_current(self):
for ax in self.canvas.figure.axes}))
self.set_history_buttons()

@cbook.deprecated("3.3", alternative="toolbar.canvas.draw_idle()")
@_api.deprecated("3.3", alternative="toolbar.canvas.draw_idle()")
def draw(self):
"""Redraw the canvases, update the locators."""
self._draw()
Expand Down Expand Up @@ -3471,7 +3471,7 @@ def set_message(self, s):
raise NotImplementedError


@cbook.deprecated("3.3")
@_api.deprecated("3.3")
class StatusbarBase:
"""Base class for the statusbar."""
def __init__(self, toolmanager):
Expand Down
Loading