diff --git a/doc/api/next_api_changes/removals.rst b/doc/api/next_api_changes/removals.rst index 12b7967c8bfe..badca455f4a3 100644 --- a/doc/api/next_api_changes/removals.rst +++ b/doc/api/next_api_changes/removals.rst @@ -39,6 +39,11 @@ Classes and methods - ``backend_qt5.NavigationToolbar2QT.buttons`` property (no replacement) - ``backend_qt5.NavigationToolbar2QT.adj_window`` property (no replacement) +- ``docstring.Appender`` (no replacement) +- ``docstring.dedent()`` (use `inspect.getdoc` instead) +- ``docstring.copy_dedent()`` + (use ``docstring.copy()`` and `inspect.getdoc` instead) + - ``matplotlib.checkdep_dvipng`` (no replacement) - ``matplotlib.checkdep_ghostscript`` (no replacement) - ``matplotlib.checkdep_pdftops`` (no replacement) @@ -59,6 +64,21 @@ Classes and methods - ``sphinxext.mathmpl.math_directive()`` (use the class ``MathDirective`` instead) +- ``scale.LogTransformBase`` (use ``scale.LogTransform`` instead) +- ``scale.InvertedLogTransformBase`` (use ``scale.InvertedLogTransform`` instead) +- ``scale.Log10Transform`` (use ``scale.LogTransform`` instead) +- ``scale.InvertedLog10Transform`` (use ``scale.InvertedLogTransform`` instead) +- ``scale.Log2Transform`` (use ``scale.LogTransform`` instead) +- ``scale.InvertedLog2Transform`` (use ``scale.InvertedLogTransform`` instead) +- ``scale.NaturalLogTransform`` (use ``scale.LogTransform`` instead) +- ``scale.InvertedNaturalLogTransform`` (use ``scale.InvertedLogTransform`` instead) + +- ``ticker.OldScalarFormatter.pprint_val()`` (no replacement) +- ``ticker.ScalarFormatter.pprint_val()`` (no replacement) +- ``ticker.LogFormatter.pprint_val()`` (no replacement) +- ``ticker.decade_down()`` (no replacement) +- ``ticker.decade_up()`` (no replacement) + - ``Artist.aname`` property (no replacement) - ``Axis.iter_ticks`` (no replacement) diff --git a/lib/matplotlib/docstring.py b/lib/matplotlib/docstring.py index 3d008911b468..03b50688dcc5 100644 --- a/lib/matplotlib/docstring.py +++ b/lib/matplotlib/docstring.py @@ -1,7 +1,5 @@ import inspect -from matplotlib import cbook - class Substitution: """ @@ -59,43 +57,6 @@ def from_params(cls, params): return result -@cbook.deprecated("3.1") -class Appender: - r""" - A function decorator that will append an addendum to the docstring - of the target function. - - This decorator should be robust even if func.__doc__ is None - (for example, if -OO was passed to the interpreter). - - Usage: construct a docstring.Appender with a string to be joined to - the original docstring. An optional 'join' parameter may be supplied - which will be used to join the docstring and addendum. e.g. - - add_copyright = Appender("Copyright (c) 2009", join='\n') - - @add_copyright - def my_dog(has='fleas'): - "This docstring will have a copyright below" - pass - """ - def __init__(self, addendum, join=''): - self.addendum = addendum - self.join = join - - def __call__(self, func): - docitems = [func.__doc__, self.addendum] - func.__doc__ = func.__doc__ and self.join.join(docitems) - return func - - -@cbook.deprecated("3.1", alternative="inspect.getdoc()") -def dedent(func): - """Dedent a docstring (if present).""" - func.__doc__ = func.__doc__ and cbook.dedent(func.__doc__) - return func - - def copy(source): """Copy a docstring from another source function (if present).""" def do_copy(target): @@ -114,14 +75,3 @@ def dedent_interpd(func): """Dedent *func*'s docstring, then interpolate it with ``interpd``.""" func.__doc__ = inspect.getdoc(func) return interpd(func) - - -@cbook.deprecated("3.1", alternative="docstring.copy() and cbook.dedent()") -def copy_dedent(source): - """A decorator that will copy the docstring from the source and - then dedent it""" - # note the following is ugly because "Python is not a functional - # language" - GVR. Perhaps one day, functools.compose will exist. - # or perhaps not. - # http://mail.python.org/pipermail/patches/2007-February/021687.html - return lambda target: dedent(copy(source)(target)) diff --git a/lib/matplotlib/scale.py b/lib/matplotlib/scale.py index a25d474f09a6..a55e375c171f 100644 --- a/lib/matplotlib/scale.py +++ b/lib/matplotlib/scale.py @@ -201,81 +201,6 @@ def set_default_locators_and_formatters(self, axis): axis.set_minor_locator(NullLocator()) -@cbook.deprecated("3.1", alternative="LogTransform") -class LogTransformBase(Transform): - input_dims = output_dims = 1 - - def __init__(self, nonpos='clip'): - Transform.__init__(self) - self._clip = {"clip": True, "mask": False}[nonpos] - - def transform_non_affine(self, a): - return LogTransform.transform_non_affine(self, a) - - def __str__(self): - return "{}({!r})".format( - type(self).__name__, "clip" if self._clip else "mask") - - -@cbook.deprecated("3.1", alternative="InvertedLogTransform") -class InvertedLogTransformBase(Transform): - input_dims = output_dims = 1 - - def transform_non_affine(self, a): - return ma.power(self.base, a) - - def __str__(self): - return "{}()".format(type(self).__name__) - - -@cbook.deprecated("3.1", alternative="LogTransform") -class Log10Transform(LogTransformBase): - base = 10.0 - - def inverted(self): - return InvertedLog10Transform() - - -@cbook.deprecated("3.1", alternative="InvertedLogTransform") -class InvertedLog10Transform(InvertedLogTransformBase): - base = 10.0 - - def inverted(self): - return Log10Transform() - - -@cbook.deprecated("3.1", alternative="LogTransform") -class Log2Transform(LogTransformBase): - base = 2.0 - - def inverted(self): - return InvertedLog2Transform() - - -@cbook.deprecated("3.1", alternative="InvertedLogTransform") -class InvertedLog2Transform(InvertedLogTransformBase): - base = 2.0 - - def inverted(self): - return Log2Transform() - - -@cbook.deprecated("3.1", alternative="LogTransform") -class NaturalLogTransform(LogTransformBase): - base = np.e - - def inverted(self): - return InvertedNaturalLogTransform() - - -@cbook.deprecated("3.1", alternative="InvertedLogTransform") -class InvertedNaturalLogTransform(InvertedLogTransformBase): - base = np.e - - def inverted(self): - return NaturalLogTransform() - - class LogTransform(Transform): input_dims = output_dims = 1 @@ -341,15 +266,6 @@ class LogScale(ScaleBase): """ name = 'log' - # compatibility shim - LogTransformBase = LogTransformBase - Log10Transform = Log10Transform - InvertedLog10Transform = InvertedLog10Transform - Log2Transform = Log2Transform - InvertedLog2Transform = InvertedLog2Transform - NaturalLogTransform = NaturalLogTransform - InvertedNaturalLogTransform = InvertedNaturalLogTransform - @cbook.deprecated("3.3", alternative="scale.LogTransform") @property def LogTransform(self): diff --git a/lib/matplotlib/tests/test_scale.py b/lib/matplotlib/tests/test_scale.py index d119940a13a3..c9bed31ab4f9 100644 --- a/lib/matplotlib/tests/test_scale.py +++ b/lib/matplotlib/tests/test_scale.py @@ -1,7 +1,7 @@ from matplotlib.cbook import MatplotlibDeprecationWarning import matplotlib.pyplot as plt from matplotlib.scale import ( - LogTransform, Log10Transform, InvertedLog10Transform, + LogTransform, InvertedLogTransform, SymmetricalLogTransform) from matplotlib.testing.decorators import check_figures_equal, image_comparison @@ -126,8 +126,9 @@ def test_logscale_invert_transform(): tform = (ax.transAxes + ax.transData.inverted()).inverted() # direct test of log transform inversion - with pytest.warns(MatplotlibDeprecationWarning): - assert isinstance(Log10Transform().inverted(), InvertedLog10Transform) + inverted_transform = LogTransform(base=2).inverted() + assert isinstance(inverted_transform, InvertedLogTransform) + assert inverted_transform.base == 2 def test_logscale_transform_repr(): diff --git a/lib/matplotlib/ticker.py b/lib/matplotlib/ticker.py index fe4f5d5cc3d9..8cffd92046c7 100644 --- a/lib/matplotlib/ticker.py +++ b/lib/matplotlib/ticker.py @@ -467,38 +467,6 @@ def __call__(self, x, pos=None): s = s.rstrip('0').rstrip('.') return s - @cbook.deprecated("3.1") - def pprint_val(self, x, d): - """ - Formats the value *x* based on the size of the axis range *d*. - """ - # If the number is not too big and it's an int, format it as an int. - if abs(x) < 1e4 and x == int(x): - return '%d' % x - - if d < 1e-2: - fmt = '%1.3e' - elif d < 1e-1: - fmt = '%1.3f' - elif d > 1e5: - fmt = '%1.1e' - elif d > 10: - fmt = '%1.1f' - elif d > 1: - fmt = '%1.2f' - else: - fmt = '%1.3f' - s = fmt % x - tup = s.split('e') - if len(tup) == 2: - mantissa = tup[0].rstrip('0').rstrip('.') - sign = tup[1][0].replace('+', '') - exponent = tup[1][1:].lstrip('0') - s = '%se%s%s' % (mantissa, sign, exponent) - else: - s = s.rstrip('0').rstrip('.') - return s - class ScalarFormatter(Formatter): """ @@ -780,16 +748,6 @@ def _set_format(self): if self._usetex or self._useMathText: self.format = r'$\mathdefault{%s}$' % self.format - @cbook.deprecated("3.1") - def pprint_val(self, x): - xp = (x - self.offset) / (10. ** self.orderOfMagnitude) - if abs(xp) < 1e-8: - xp = 0 - if self._useLocale: - return locale.format_string(self.format, (xp,)) - else: - return self.format % xp - def _formatSciNotation(self, s): # transform 1e+004 into 1e4, for example if self._useLocale: @@ -1020,10 +978,6 @@ def format_data_short(self, value): # docstring inherited return '%-12g' % value - @cbook.deprecated("3.1") - def pprint_val(self, *args, **kwargs): - return self._pprint_val(*args, **kwargs) - def _pprint_val(self, x, d): # If the number is not too big and it's an int, format it as an int. if abs(x) < 1e4 and x == int(x): @@ -2214,24 +2168,6 @@ def view_limits(self, dmin, dmax): return dmin, dmax -@cbook.deprecated("3.1") -def decade_down(x, base=10): - """Floor x to the nearest lower decade.""" - if x == 0.0: - return -base - lx = np.floor(np.log(x) / np.log(base)) - return base ** lx - - -@cbook.deprecated("3.1") -def decade_up(x, base=10): - """Ceil x to the nearest higher decade.""" - if x == 0.0: - return base - lx = np.ceil(np.log(x) / np.log(base)) - return base ** lx - - def is_decade(x, base=10, *, rtol=1e-10): if not np.isfinite(x): return False