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

Skip to content

Commit 538dbd2

Browse files
committed
change in parameters and in decorator
1 parent d18d7a1 commit 538dbd2

File tree

1 file changed

+8
-8
lines changed

1 file changed

+8
-8
lines changed

lib/matplotlib/scale.py

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -133,16 +133,16 @@ def handle_axis_parameter(init_func):
133133
>>> from matplotlib.scale import ScaleBase
134134
>>> class CustomScale(ScaleBase):
135135
... @handle_axis_parameter
136-
... def __init__(self, axis=None, custom_param=1):
136+
... def __init__(self, axis, custom_param=1):
137137
... self.custom_param = custom_param
138138
"""
139139
@wraps(init_func)
140140
def wrapper(self, *args, **kwargs):
141-
# If the first argument is a ScaleBase (axis), pass as is.
142-
if args and isinstance(args[0], ScaleBase):
141+
if args and isinstance(args[0], mpl.axis.Axis):
143142
return init_func(self, *args, **kwargs)
144143
else:
145-
# Inject None as axis parameter
144+
# Remove 'axis' from kwargs to avoid double assignment
145+
kwargs.pop('axis', None)
146146
return init_func(self, None, *args, **kwargs)
147147
return wrapper
148148

@@ -155,7 +155,7 @@ class LinearScale(ScaleBase):
155155
name = 'linear'
156156

157157
@handle_axis_parameter
158-
def __init__(self, axis=None):
158+
def __init__(self, axis):
159159
# This method is present only to prevent inheritance of the base class'
160160
# constructor docstring, which would otherwise end up interpolated into
161161
# the docstring of Axis.set_scale.
@@ -326,7 +326,7 @@ class LogScale(ScaleBase):
326326
name = 'log'
327327

328328
@handle_axis_parameter
329-
def __init__(self, axis=None, *, base=10, subs=None, nonpositive="clip"):
329+
def __init__(self, axis, *, base=10, subs=None, nonpositive="clip"):
330330
"""
331331
Parameters
332332
----------
@@ -504,7 +504,7 @@ class SymmetricalLogScale(ScaleBase):
504504
name = 'symlog'
505505

506506
@handle_axis_parameter
507-
def __init__(self, axis=None, *, base=10, linthresh=2, subs=None, linscale=1):
507+
def __init__(self, axis, *, base=10, linthresh=2, subs=None, linscale=1):
508508
self._transform = SymmetricalLogTransform(base, linthresh, linscale)
509509
self.subs = subs
510510

@@ -696,7 +696,7 @@ class LogitScale(ScaleBase):
696696
name = 'logit'
697697

698698
@handle_axis_parameter
699-
def __init__(self, axis=None, nonpositive='mask', *,
699+
def __init__(self, axis, nonpositive='mask', *,
700700
one_half=r"\frac{1}{2}", use_overline=False):
701701
r"""
702702
Parameters

0 commit comments

Comments
 (0)