Skip to content

Commit fb1a4e9

Browse files
committed
with tests update is better
1 parent f1da7b8 commit fb1a4e9

2 files changed

Lines changed: 4 additions & 4 deletions

File tree

sklearn/impute.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -181,7 +181,7 @@ def _validate_input(self, X):
181181
raise ve
182182

183183
if X.dtype.kind not in ("i", "u", "f", "O"):
184-
raise ValueError("SimpleImputer does not work on data with dtype "
184+
raise ValueError("SimpleImputer does not support data with dtype "
185185
"{0}. Please provide either a numeric array (with"
186186
" a floating point or integer dtype) or "
187187
"categorical data represented either as an array "

sklearn/tests/test_impute.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -217,7 +217,7 @@ def test_imputation_mean_median_error_invalid_type(strategy, dtype):
217217
[4, "e", 6],
218218
["g", "h", 9]], dtype=dtype)
219219

220-
with pytest.raises(TypeError, match="non-numeric data"):
220+
with pytest.raises(ValueError, match="non-numeric data"):
221221
imputer = SimpleImputer(strategy=strategy)
222222
imputer.fit_transform(X)
223223

@@ -234,8 +234,8 @@ def test_imputation_const_mostf_error_invalid_types(strategy, dtype):
234234
[np.nan, "c", "d", "h"],
235235
], dtype=dtype)
236236

237-
err_msg = "SimpleImputer does not support this datatype"
238-
with pytest.raises(TypeError, match=err_msg):
237+
err_msg = "SimpleImputer does not support data"
238+
with pytest.raises(ValueError, match=err_msg):
239239
imputer = SimpleImputer(strategy=strategy)
240240
imputer.fit(X).transform(X)
241241

0 commit comments

Comments
 (0)