@@ -332,7 +332,7 @@ def partial_fit(self, X, y=None):
332
332
self .data_range_ = data_range
333
333
return self
334
334
335
- def transform (self , X ):
335
+ def transform (self , X , copy = None ):
336
336
"""Scaling features of X according to feature_range.
337
337
338
338
Parameters
@@ -341,16 +341,16 @@ def transform(self, X):
341
341
Input data that will be transformed.
342
342
"""
343
343
check_is_fitted (self , 'scale_' )
344
-
345
- X = check_array (X , copy = self . copy , ensure_2d = False , dtype = FLOAT_DTYPES )
344
+ copy = copy if copy is not None else self . copy
345
+ X = check_array (X , copy = copy , ensure_2d = False , dtype = FLOAT_DTYPES )
346
346
if X .ndim == 1 :
347
347
warnings .warn (DEPRECATION_MSG_1D , DeprecationWarning )
348
348
349
349
X *= self .scale_
350
350
X += self .min_
351
351
return X
352
352
353
- def inverse_transform (self , X ):
353
+ def inverse_transform (self , X , copy = None ):
354
354
"""Undo the scaling of X according to feature_range.
355
355
356
356
Parameters
@@ -359,8 +359,8 @@ def inverse_transform(self, X):
359
359
Input data that will be transformed. It cannot be sparse.
360
360
"""
361
361
check_is_fitted (self , 'scale_' )
362
-
363
- X = check_array (X , copy = self . copy , ensure_2d = False , dtype = FLOAT_DTYPES )
362
+ copy = copy if copy is not None else self . copy
363
+ X = check_array (X , copy = copy , ensure_2d = False , dtype = FLOAT_DTYPES )
364
364
if X .ndim == 1 :
365
365
warnings .warn (DEPRECATION_MSG_1D , DeprecationWarning )
366
366
@@ -772,7 +772,7 @@ def partial_fit(self, X, y=None):
772
772
self .scale_ = _handle_zeros_in_scale (max_abs )
773
773
return self
774
774
775
- def transform (self , X , y = None ):
775
+ def transform (self , X , y = None , copy = None ):
776
776
"""Scale the data
777
777
778
778
Parameters
@@ -781,7 +781,8 @@ def transform(self, X, y=None):
781
781
The data that should be scaled.
782
782
"""
783
783
check_is_fitted (self , 'scale_' )
784
- X = check_array (X , accept_sparse = ('csr' , 'csc' ), copy = self .copy ,
784
+ copy = copy if copy is not None else self .copy
785
+ X = check_array (X , accept_sparse = ('csr' , 'csc' ), copy = copy ,
785
786
ensure_2d = False , estimator = self , dtype = FLOAT_DTYPES )
786
787
787
788
if X .ndim == 1 :
@@ -796,7 +797,7 @@ def transform(self, X, y=None):
796
797
X /= self .scale_
797
798
return X
798
799
799
- def inverse_transform (self , X ):
800
+ def inverse_transform (self , X , copy = None ):
800
801
"""Scale back the data to the original representation
801
802
802
803
Parameters
@@ -805,6 +806,7 @@ def inverse_transform(self, X):
805
806
The data that should be transformed back.
806
807
"""
807
808
check_is_fitted (self , 'scale_' )
809
+ copy = copy if copy is not None else self .copy
808
810
X = check_array (X , accept_sparse = ('csr' , 'csc' ), copy = self .copy ,
809
811
ensure_2d = False , estimator = self , dtype = FLOAT_DTYPES )
810
812
if X .ndim == 1 :
@@ -934,9 +936,9 @@ def __init__(self, with_centering=True, with_scaling=True, copy=True):
934
936
self .with_scaling = with_scaling
935
937
self .copy = copy
936
938
937
- def _check_array (self , X , copy ):
939
+ def _check_array (self , X , copy = False ):
938
940
"""Makes sure centering is not enabled for sparse matrices."""
939
- X = check_array (X , accept_sparse = ('csr' , 'csc' ), copy = self . copy ,
941
+ X = check_array (X , accept_sparse = ('csr' , 'csc' ), copy = copy ,
940
942
ensure_2d = False , estimator = self , dtype = FLOAT_DTYPES )
941
943
942
944
if X .ndim == 1 :
@@ -972,7 +974,7 @@ def fit(self, X, y=None):
972
974
self .scale_ = _handle_zeros_in_scale (self .scale_ , copy = False )
973
975
return self
974
976
975
- def transform (self , X , y = None ):
977
+ def transform (self , X , y = None , copy = None ):
976
978
"""Center and scale the data
977
979
978
980
Parameters
@@ -984,7 +986,8 @@ def transform(self, X, y=None):
984
986
check_is_fitted (self , 'center_' )
985
987
if self .with_scaling :
986
988
check_is_fitted (self , 'scale_' )
987
- X = self ._check_array (X , self .copy )
989
+ copy = copy if copy is not None else self .copy
990
+ X = self ._check_array (X , copy )
988
991
if X .ndim == 1 :
989
992
warnings .warn (DEPRECATION_MSG_1D , DeprecationWarning )
990
993
@@ -1001,7 +1004,7 @@ def transform(self, X, y=None):
1001
1004
X /= self .scale_
1002
1005
return X
1003
1006
1004
- def inverse_transform (self , X ):
1007
+ def inverse_transform (self , X , copy = None ):
1005
1008
"""Scale back the data to the original representation
1006
1009
1007
1010
Parameters
@@ -1013,7 +1016,8 @@ def inverse_transform(self, X):
1013
1016
check_is_fitted (self , 'center_' )
1014
1017
if self .with_scaling :
1015
1018
check_is_fitted (self , 'scale_' )
1016
- X = self ._check_array (X , self .copy )
1019
+ copy = copy if copy is not None else self .copy
1020
+ X = self ._check_array (X , copy )
1017
1021
if X .ndim == 1 :
1018
1022
warnings .warn (DEPRECATION_MSG_1D , DeprecationWarning )
1019
1023
0 commit comments