8000 ENH do not catch warning in check_estimators_empty_data_messages · scikit-learn/scikit-learn@1c03c8b · GitHub
[go: up one dir, main page]

Skip to content

Commit 1c03c8b

Browse files
committed
ENH do not catch warning in check_estimators_empty_data_messages
1 parent 67f6ad1 commit 1c03c8b

File tree

1 file changed

+18
-19
lines changed

1 file changed

+18
-19
lines changed

sklearn/utils/estimator_checks.py

Lines changed: 18 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -348,25 +348,24 @@ def check_estimators_dtypes(name, Estimator):
348348

349349

350350
def check_estimators_empty_data_messages(name, Estimator, multi_output=False):
351-
with warnings.catch_warnings(record=True):
352-
e = Estimator()
353-
set_fast_parameters(e)
354-
set_random_state(e, 1)
355-
356-
X_zero_samples = np.empty(0).reshape(0, 3)
357-
# The precise message can change depending on whether X or y is
358-
# validated first. Let us test the type of exception only:
359-
assert_raises(ValueError, e.fit, X_zero_samples, [])
360-
361-
X_zero_features = np.empty(0).reshape(3, 0)
362-
# the following y should be accepted by both classifiers and regressors
363-
# and ignored by unsupervised models
364-
if multi_output:
365-
y = np.array([[1, 1], [0, 1], [0, 1]])
366-
else:
367-
y = [1, 0, 1]
368-
msg = "0 feature(s) (shape=(3, 0)) while a minimum of 1 is required."
369-
assert_raise_message(ValueError, msg, e.fit, X_zero_features, y)
351+
e = Estimator()
352+
set_fast_parameters(e)
353+
set_random_state(e, 1)
354+
355+
X_zero_samples = np.empty(0).reshape(0, 3)
356+
# The precise message can change depending on whether X or y is
357+
# validated first. Let us test the type of exception only:
358+
assert_raises(ValueError, e.fit, X_zero_samples, [])
359+
360+
X_zero_features = np.empty(0).reshape(3, 0)
361+
# the following y should be accepted by both classifiers and regressors
362+
# and ignored by unsupervised models
363+
if multi_output:
364+
y = np.array([[1, 1], [0, 1], [0, 1]])
365+
else:
366+
y = [1, 0, 1]
367+
msg = "0 feature(s) (shape=(3, 0)) while a minimum of 1 is required."
368+
assert_raise_message(ValueError, msg, e.fit, X_zero_features, y)
370369

371370

372371
def check_estimators_nan_inf(name, Estimator):

0 commit comments

Comments
 (0)
0