Skip to content

Commit f0c5568

Browse files
authored
[MRG+1] FIX common test failures on Windows (#9115)
1 parent 7cfec78 commit f0c5568

File tree

2 files changed

+13
-3
lines changed

2 files changed

+13
-3
lines changed

sklearn/utils/estimator_checks.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1142,7 +1142,7 @@ def check_classifiers_train(name, classifier_orig):
11421142
if hasattr(classifier, "predict_log_proba"):
11431143
# predict_log_proba is a transformation of predict_proba
11441144
y_log_prob = classifier.predict_log_proba(X)
1145-
assert_allclose(y_log_prob, np.log(y_prob), 8)
1145+
assert_allclose(y_log_prob, np.log(y_prob), 8, atol=1e-9)
11461146
assert_array_equal(np.argsort(y_log_prob), np.argsort(y_prob))
11471147

11481148

@@ -1378,7 +1378,9 @@ def check_class_weight_classifiers(name, classifier_orig):
13781378
set_random_state(classifier)
13791379
classifier.fit(X_train, y_train)
13801380
y_pred = classifier.predict(X_test)
1381-
assert_greater(np.mean(y_pred == 0), 0.89)
1381+
# XXX: Generally can use 0.89 here. On Windows, LinearSVC gets
1382+
# 0.88 (Issue #9111)
1383+
assert_greater(np.mean(y_pred == 0), 0.87)
13821384

13831385

13841386
@ignore_warnings(category=DeprecationWarning)

sklearn/utils/testing.py

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -375,7 +375,7 @@ def assert_raise_message(exceptions, message, function, *args, **kwargs):
375375
(names, function.__name__))
376376

377377

378-
def assert_allclose_dense_sparse(x, y, rtol=1e-07, atol=0, err_msg=''):
378+
def assert_allclose_dense_sparse(x, y, rtol=1e-07, atol=1e-9, err_msg=''):
379379
"""Assert allclose for sparse and dense data.
380380
381381
Both x and y need to be either sparse or dense, they
@@ -389,6 +389,14 @@ def assert_allclose_dense_sparse(x, y, rtol=1e-07, atol=0, err_msg=''):
389389
y : array-like or sparse matrix
390390
Second array to compare.
391391
392+
rtol : float, optional
393+
relative tolerance; see numpy.allclose
394+
395+
atol : float, optional
396+
absolute tolerance; see numpy.allclose. Note that the default here is
397+
more tolerant than the default for numpy.testing.assert_allclose, where
398+
atol=0.
399+
392400
err_msg : string, default=''
393401
Error message to raise.
394402
"""

0 commit comments

Comments
 (0)