Skip to content

Commit c8246f2

Browse files
committed
TypeError -> ValueError
1 parent fb1a4e9 commit c8246f2

File tree

2 files changed

+4
-4
lines changed

2 files changed

+4
-4
lines changed

sklearn/impute.py

+3-3
Original file line numberDiff line numberDiff line change
@@ -219,9 +219,9 @@ def fit(self, X, y=None):
219219
if (self.strategy == "constant" and
220220
X.dtype.kind in ("i", "u", "f") and
221221
not isinstance(fill_value, numbers.Real)):
222-
raise TypeError("'fill_value'={0} is invalid. Expected a numerical"
223-
" value when imputing numerical"
224-
" data".format(fill_value))
222+
raise ValueError("'fill_value'={0} is invalid. Expected a "
223+
"numerical value when imputing numerical "
224+
"data".format(fill_value))
225225

226226
if sparse.issparse(X):
227227
self.statistics_ = self._sparse_fit(X,

sklearn/tests/test_impute.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -319,7 +319,7 @@ def test_imputation_constant_error_invalid_type(X_data, missing_value):
319319
X = np.full((3, 5), X_data)
320320
X[0, 0] = missing_value
321321

322-
with pytest.raises(TypeError, match="imputing numerical"):
322+
with pytest.raises(ValueError, match="imputing numerical"):
323323
imputer = SimpleImputer(missing_values=missing_value,
324324
strategy="constant",
325325
fill_value="x")

0 commit comments

Comments
 (0)