Skip to content

Commit fda4e58

Browse files
author
giorgiop
committed
test
1 parent 3301893 commit fda4e58

File tree

1 file changed

+22
-0
lines changed

1 file changed

+22
-0
lines changed

sklearn/preprocessing/tests/test_data.py

+22
Original file line numberDiff line numberDiff line change
@@ -1498,3 +1498,25 @@ def test_one_hot_encoder_unknown_transform():
14981498
oh = OneHotEncoder(handle_unknown='42')
14991499
oh.fit(X)
15001500
assert_raises(ValueError, oh.transform, y)
1501+
1502+
1503+
def test_fit_cold_start():
1504+
X = iris.data
1505+
X_2d = X[:, :2]
1506+
1507+
# Scalers that have a partial_fit method
1508+
scalers = [StandardScaler(with_mean=False, with_std=False),
1509+
MinMaxScaler(),
1510+
MaxAbsScaler()]
1511+
1512+
for scaler in scalers:
1513+
scaler.fit_transform(X)
1514+
# with a different shape, this may break the scaler unless the internal
1515+
# state is re-set
1516+
try:
1517+
scaler.fit_transform(X_2d)
1518+
except ValueError as err:
1519+
print("Cannot fit %s a second time with different shape "
1520+
"of input. Error message: %s"
1521+
% (scaler.__class__.__name__, str(err)))
1522+
assert False

0 commit comments

Comments
 (0)