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

Skip to content

Commit bfb28ab

Browse files
committed
MNT: deprecate unused numdecs LogLocator param
1 parent e8101f1 commit bfb28ab

File tree

4 files changed

+22
-3
lines changed

4 files changed

+22
-3
lines changed

ci/mypy-stubtest-allowlist.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -118,6 +118,8 @@ matplotlib.contour.ContourSet.allsegs
118118
matplotlib.contour.ContourSet.tcolors
119119
matplotlib.contour.ContourSet.tlinewidths
120120
matplotlib.figure.FigureBase.get_tightbbox
121+
matplotlib.ticker.LogLocator.__init__
122+
matplotlib.ticker.LogLocator.set_params
121123

122124
# positional-only argument name lacking leading underscores
123125
matplotlib.axes._base._AxesBase.axis
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
*numdecs* parameter of ``LogLocator``
2+
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
3+
... is deprecated without replacement, because it had no effect.

lib/matplotlib/tests/test_ticker.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
import matplotlib as mpl
1212
import matplotlib.pyplot as plt
1313
import matplotlib.ticker as mticker
14+
from matplotlib._api import MatplotlibDeprecationWarning
1415

1516

1617
class TestMaxNLocator:
@@ -233,7 +234,8 @@ def test_set_params(self):
233234
See if change was successful. Should not raise exception.
234235
"""
235236
loc = mticker.LogLocator()
236-
loc.set_params(numticks=7, numdecs=8, subs=[2.0], base=4)
237+
with pytest.warns(MatplotlibDeprecationWarning, match="numdecs"):
238+
loc.set_params(numticks=7, numdecs=8, subs=[2.0], base=4)
237239
assert loc.numticks == 7
238240
assert loc.numdecs == 8
239241
assert loc._base == 4

lib/matplotlib/ticker.py

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2244,6 +2244,7 @@ class LogLocator(Locator):
22442244
22452245
"""
22462246

2247+
@_api.delete_parameter("3.8", "numdecs")
22472248
def __init__(self, base=10.0, subs=(1.0,), numdecs=4, numticks=None):
22482249
"""Place ticks on the locations : subs[j] * base**i."""
22492250
if numticks is None:
@@ -2253,20 +2254,31 @@ def __init__(self, base=10.0, subs=(1.0,), numdecs=4, numticks=None):
22532254
numticks = 'auto'
22542255
self._base = float(base)
22552256
self._set_subs(subs)
2256-
self.numdecs = numdecs
2257+
self._numdecs = numdecs
22572258
self.numticks = numticks
22582259

2260+
@_api.delete_parameter("3.8", "numdecs")
22592261
def set_params(self, base=None, subs=None, numdecs=None, numticks=None):
22602262
"""Set parameters within this locator."""
22612263
if base is not None:
22622264
self._base = float(base)
22632265
if subs is not None:
22642266
self._set_subs(subs)
22652267
if numdecs is not None:
2266-
self.numdecs = numdecs
2268+
self._numdecs = numdecs
22672269
if numticks is not None:
22682270
self.numticks = numticks
22692271

2272+
@_api.deprecated("3.8", addendum="This attribute has no effect.")
2273+
@property
2274+
def numdecs(self):
2275+
return self._numdecs
2276+
2277+
@_api.deprecated("3.8", addendum="This attribute has no effect.")
2278+
@numdecs.setter
2279+
def numdecs(self, numdecs):
2280+
self._numdecs = numdecs
2281+
22702282
def _set_subs(self, subs):
22712283
"""
22722284
Set the minor ticks for the log scaling every ``base**i*subs[j]``.

0 commit comments

Comments
 (0)