@@ -126,8 +126,8 @@ def handle_axis_parameter(init_func):
126
126
Notes
127
127
-----
128
128
If the wrapped constructor defines *axis* as its first argument, the
129
- parameter is preserved. Otherwise, it is safely removed from positional
130
- or keyword arguments .
129
+ parameter is preserved when present . Otherwise, the value `None` is injected
130
+ as the first argument .
131
131
132
132
Examples
133
133
--------
@@ -139,14 +139,12 @@ def handle_axis_parameter(init_func):
139
139
"""
140
140
@wraps (init_func )
141
141
def wrapper (self , * args , ** kwargs ):
142
- sig = inspect .signature (init_func )
143
- params = list (sig .parameters .values ())
144
- if params and params [1 ].name == "axis" :
142
+ # If the first argument is a ScaleBase (axis), pass as is.
143
+ if args and isinstance (args [0 ], ScaleBase ):
145
144
return init_func (self , * args , ** kwargs )
146
- if args :
147
- args = args [1 :]
148
- kwargs .pop ("axis" , None )
149
- return init_func (self , * args , ** kwargs )
145
+ else :
146
+ # Inject None as axis parameter
147
+ return init_func (self , None , * args , ** kwargs )
150
148
return wrapper
151
149
152
150
@@ -801,14 +799,6 @@ def register_scale(scale_class):
801
799
scale_class : subclass of `ScaleBase`
802
800
The scale to register.
803
801
"""
804
- sig = inspect .signature (scale_class .__init__ )
805
- if 'axis' in sig .parameters :
806
- warnings .warn (
807
- f"The scale class { scale_class .__name__ } still uses the 'axis' "
808
- "parameter in its constructor. Consider refactoring it to remove "
809
- "this dependency." ,
810
- DeprecationWarning
811
- )
812
802
_scale_mapping [scale_class .name ] = scale_class
813
803
814
804
0 commit comments