@@ -133,16 +133,16 @@ def handle_axis_parameter(init_func):
133
133
>>> from matplotlib.scale import ScaleBase
134
134
>>> class CustomScale(ScaleBase):
135
135
... @handle_axis_parameter
136
- ... def __init__(self, axis=None , custom_param=1):
136
+ ... def __init__(self, axis, custom_param=1):
137
137
... self.custom_param = custom_param
138
138
"""
139
139
@wraps (init_func )
140
140
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 ):
143
142
return init_func (self , * args , ** kwargs )
144
143
else :
145
- # Inject None as axis parameter
144
+ # Remove 'axis' from kwargs to avoid double assignment
145
+ kwargs .pop ('axis' , None )
146
146
return init_func (self , None , * args , ** kwargs )
147
147
return wrapper
148
148
@@ -155,7 +155,7 @@ class LinearScale(ScaleBase):
155
155
name = 'linear'
156
156
157
157
@handle_axis_parameter
158
- def __init__ (self , axis = None ):
158
+ def __init__ (self , axis ):
159
159
# This method is present only to prevent inheritance of the base class'
160
160
# constructor docstring, which would otherwise end up interpolated into
161
161
# the docstring of Axis.set_scale.
@@ -326,7 +326,7 @@ class LogScale(ScaleBase):
326
326
name = 'log'
327
327
328
328
@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" ):
330
330
"""
331
331
Parameters
332
332
----------
@@ -504,7 +504,7 @@ class SymmetricalLogScale(ScaleBase):
504
504
name = 'symlog'
505
505
506
506
@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 ):
508
508
self ._transform = SymmetricalLogTransform (base , linthresh , linscale )
509
509
self .subs = subs
510
510
@@ -696,7 +696,7 @@ class LogitScale(ScaleBase):
696
696
name = 'logit'
697
697
698
698
@handle_axis_parameter
699
- def __init__ (self , axis = None , nonpositive = 'mask' , * ,
699
+ def __init__ (self , axis , nonpositive = 'mask' , * ,
700
700
one_half = r"\frac{1}{2}" , use_overline = False ):
701
701
r"""
702
702
Parameters
0 commit comments