Skip to content

Commit fc92d96

Browse files
committed
Remove scale internals deprecated in 3.3.
1 parent c8709fd commit fc92d96

File tree

3 files changed

+33
-70
lines changed

3 files changed

+33
-70
lines changed

doc/api/next_api_changes/removals/20331-ES.rst

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,25 @@
1+
``{,Symmetrical}LogScale.{,Inverted}LogTransform``
2+
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
3+
``LogScale.LogTransform``, ``LogScale.InvertedLogTransform``,
4+
``SymmetricalScale.SymmetricalTransform`` and
5+
``SymmetricalScale.InvertedSymmetricalTransform`` have been removed. Directly
6+
access the transform classes from the `matplotlib.scale` module.
7+
8+
log/symlog scale base, ticks, and nonpos specification
9+
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
10+
`~.Axes.semilogx`, `~.Axes.semilogy`, `~.Axes.loglog`, `.LogScale`, and
11+
`.SymmetricalLogScale` used to take keyword arguments that depends on the axis
12+
orientation ("basex" vs "basey", "subsx" vs "subsy", "nonposx" vs "nonposy");
13+
these parameter names have been removed in favor of "base", "subs",
14+
"nonpositive". This removal also affects e.g. ``ax.set_yscale("log",
15+
basey=...)`` which must now be spelled ``ax.set_yscale("log", base=...)``.
16+
17+
The change from "nonpos" to "nonpositive" also affects `~.scale.LogTransform`,
18+
`~.scale.InvertedLogTransform`, `~.scale.SymmetricalLogTransform`, etc.
19+
20+
To use *different* bases for the x-axis and y-axis of a `~.Axes.loglog` plot,
21+
use e.g. ``ax.set_xscale("log", base=10); ax.set_yscale("log", base=2)``.
22+
123
Implicit initialization of ``Tick`` attributes
224
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
325

lib/matplotlib/scale.py

Lines changed: 2 additions & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -202,7 +202,6 @@ def set_default_locators_and_formatters(self, axis):
202202
class LogTransform(Transform):
203203
input_dims = output_dims = 1
204204

205-
@_api.rename_parameter("3.3", "nonpos", "nonpositive")
206205
def __init__(self, base, nonpositive='clip'):
207206
super().__init__()
208207
if base <= 0 or base == 1:
@@ -264,17 +263,7 @@ class LogScale(ScaleBase):
264263
"""
265264
name = 'log'
266265

267-
@_api.deprecated("3.3", alternative="scale.LogTransform")
268-
@property
269-
def LogTransform(self):
270-
return LogTransform
271-
272-
@_api.deprecated("3.3", alternative="scale.InvertedLogTransform")
273-
@property
274-
def InvertedLogTransform(self):
275-
return InvertedLogTransform
276-
277-
def __init__(self, axis, **kwargs):
266+
def __init__(self, axis, *, base=10, subs=None, nonpositive="clip"):
278267
"""
279268
Parameters
280269
----------
@@ -290,18 +279,6 @@ def __init__(self, axis, **kwargs):
290279
in a log10 scale, ``[2, 3, 4, 5, 6, 7, 8, 9]`` will place 8
291280
logarithmically spaced minor ticks between each major tick.
292281
"""
293-
# After the deprecation, the whole (outer) __init__ can be replaced by
294-
# def __init__(self, axis, *, base=10, subs=None, nonpositive="clip")
295-
# The following is to emit the right warnings depending on the axis
296-
# used, as the *old* kwarg names depended on the axis.
297-
axis_name = getattr(axis, "axis_name", "x")
298-
@_api.rename_parameter("3.3", f"base{axis_name}", "base")
299-
@_api.rename_parameter("3.3", f"subs{axis_name}", "subs")
300-
@_api.rename_parameter("3.3", f"nonpos{axis_name}", "nonpositive")
301-
def __init__(*, base=10, subs=None, nonpositive="clip"):
302-
return base, subs, nonpositive
303-
304-
base, subs, nonpositive = __init__(**kwargs)
305282
self._transform = LogTransform(base, nonpositive)
306283
self.subs = subs
307284

@@ -460,28 +437,7 @@ class SymmetricalLogScale(ScaleBase):
460437
"""
461438
name = 'symlog'
462439

463-
@_api.deprecated("3.3", alternative="scale.SymmetricalLogTransform")
464-
@property
465-
def SymmetricalLogTransform(self):
466-
return SymmetricalLogTransform
467-
468-
@_api.deprecated(
469-
"3.3", alternative="scale.InvertedSymmetricalLogTransform")
470-
@property
471-
def InvertedSymmetricalLogTransform(self):
472-
return InvertedSymmetricalLogTransform
473-
474-
def __init__(self, axis, **kwargs):
475-
axis_name = getattr(axis, "axis_name", "x")
476-
# See explanation in LogScale.__init__.
477-
@_api.rename_parameter("3.3", f"base{axis_name}", "base")
478-
@_api.rename_parameter("3.3", f"linthresh{axis_name}", "linthresh")
479-
@_api.rename_parameter("3.3", f"subs{axis_name}", "subs")
480-
@_api.rename_parameter("3.3", f"linscale{axis_name}", "linscale")
481-
def __init__(*, base=10, linthresh=2, subs=None, linscale=1):
482-
return base, linthresh, subs, linscale
483-
484-
base, linthresh, subs, linscale = __init__(**kwargs)
440+
def __init__(self, axis, *, base=10, linthresh=2, subs=None, linscale=1):
485441
self._transform = SymmetricalLogTransform(base, linthresh, linscale)
486442
self.subs = subs
487443

@@ -505,7 +461,6 @@ def get_transform(self):
505461
class LogitTransform(Transform):
506462
input_dims = output_dims = 1
507463

508-
@_api.rename_parameter("3.3", "nonpos", "nonpositive")
509464
def __init__(self, nonpositive='mask'):
510465
super().__init__()
511466
_api.check_in_list(['mask', 'clip'], nonpositive=nonpositive)
@@ -531,7 +486,6 @@ def __str__(self):
531486
class LogisticTransform(Transform):
532487
input_dims = output_dims = 1
533488

534-
@_api.rename_parameter("3.3", "nonpos", "nonpositive")
535489
def __init__(self, nonpositive='mask'):
536490
super().__init__()
537491
self._nonpositive = nonpositive
@@ -556,7 +510,6 @@ class LogitScale(ScaleBase):
556510
"""
557511
name = 'logit'
558512

559-
@_api.rename_parameter("3.3", "nonpos", "nonpositive")
560513
def __init__(self, axis, nonpositive='mask', *,
561514
one_half=r"\frac{1}{2}", use_overline=False):
562515
r"""

lib/matplotlib/tests/test_axes.py

Lines changed: 9 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -5577,38 +5577,26 @@ def test_loglog():
55775577
ax.tick_params(length=15, width=2, which='minor')
55785578

55795579

5580-
@pytest.mark.parametrize("new_api", [False, True])
55815580
@image_comparison(["test_loglog_nonpos.png"], remove_text=True, style='mpl20')
5582-
def test_loglog_nonpos(new_api):
5581+
def test_loglog_nonpos():
55835582
fig, axs = plt.subplots(3, 3)
55845583
x = np.arange(1, 11)
55855584
y = x**3
55865585
y[7] = -3.
55875586
x[4] = -10
5588-
for (i, j), ax in np.ndenumerate(axs):
5589-
mcx = ['mask', 'clip', ''][j]
5590-
mcy = ['mask', 'clip', ''][i]
5591-
if new_api:
5592-
if mcx == mcy:
5593-
if mcx:
5594-
ax.loglog(x, y**3, lw=2, nonpositive=mcx)
5595-
else:
5596-
ax.loglog(x, y**3, lw=2)
5587+
for (mcy, mcx), ax in zip(product(['mask', 'clip', ''], repeat=2),
5588+
axs.flat):
5589+
if mcx == mcy:
5590+
if mcx:
5591+
ax.loglog(x, y**3, lw=2, nonpositive=mcx)
55975592
else:
55985593
ax.loglog(x, y**3, lw=2)
5599-
if mcx:
5600-
ax.set_xscale("log", nonpositive=mcx)
5601-
if mcy:
5602-
ax.set_yscale("log", nonpositive=mcy)
56035594
else:
5604-
kws = {}
5595+
ax.loglog(x, y**3, lw=2)
56055596
if mcx:
5606-
kws['nonposx'] = mcx
5597+
ax.set_xscale("log", nonpositive=mcx)
56075598
if mcy:
5608-
kws['nonposy'] = mcy
5609-
with (pytest.warns(MatplotlibDeprecationWarning) if kws
5610-
else nullcontext()):
5611-
ax.loglog(x, y**3, lw=2, **kws)
5599+
ax.set_yscale("log", nonpositive=mcy)
56125600

56135601

56145602
@pytest.mark.style('default')

0 commit comments

Comments
 (0)