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

Skip to content

Commit 60163b5

Browse files
authored
Merge pull request #25651 from rcomer/loglocator-numdecs
MNT: deprecate unused numdecs LogLocator param
2 parents bff4681 + e1391cf commit 60163b5

File tree

4 files changed

+16
-4
lines changed

4 files changed

+16
-4
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 and attribute of ``LogLocator``
2+
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
3+
... are deprecated without replacement, because they have no effect.

lib/matplotlib/tests/test_ticker.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -233,9 +233,11 @@ def test_set_params(self):
233233
See if change was successful. Should not raise exception.
234234
"""
235235
loc = mticker.LogLocator()
236-
loc.set_params(numticks=7, numdecs=8, subs=[2.0], base=4)
236+
with pytest.warns(mpl.MatplotlibDeprecationWarning, match="numdecs"):
237+
loc.set_params(numticks=7, numdecs=8, subs=[2.0], base=4)
237238
assert loc.numticks == 7
238-
assert loc.numdecs == 8
239+
with pytest.warns(mpl.MatplotlibDeprecationWarning, match="numdecs"):
240+
assert loc.numdecs == 8
239241
assert loc._base == 4
240242
assert list(loc._subs) == [2.0]
241243

lib/matplotlib/ticker.py

Lines changed: 7 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,24 @@ 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+
numdecs = _api.deprecate_privatize_attribute(
2273+
"3.8", addendum="This attribute has no effect.")
2274+
22702275
def _set_subs(self, subs):
22712276
"""
22722277
Set the minor ticks for the log scaling every ``base**i*subs[j]``.

0 commit comments

Comments
 (0)