Skip to content

Commit 34968d4

Browse files
lesteveraghavrv
authored andcommitted
Fix tests on numpy master (scikit-learn#7946)
Until now we were in a edge case on assert_array_equal
1 parent 8793ec9 commit 34968d4

File tree

1 file changed

+13
-6
lines changed

1 file changed

+13
-6
lines changed

sklearn/model_selection/tests/test_split.py

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1028,16 +1028,23 @@ def test_cv_iterable_wrapper():
10281028
# Since the wrapped iterable is enlisted and stored,
10291029
# split can be called any number of times to produce
10301030
# consistent results.
1031-
assert_array_equal(list(kf_iter_wrapped.split(X, y)),
1032-
list(kf_iter_wrapped.split(X, y)))
1031+
np.testing.assert_equal(list(kf_iter_wrapped.split(X, y)),
1032+
list(kf_iter_wrapped.split(X, y)))
10331033
# If the splits are randomized, successive calls to split yields different
10341034
# results
10351035
kf_randomized_iter = KFold(n_splits=5, shuffle=True).split(X, y)
10361036
kf_randomized_iter_wrapped = check_cv(kf_randomized_iter)
1037-
assert_array_equal(list(kf_randomized_iter_wrapped.split(X, y)),
1038-
list(kf_randomized_iter_wrapped.split(X, y)))
1039-
assert_true(np.any(np.array(list(kf_iter_wrapped.split(X, y))) !=
1040-
np.array(list(kf_randomized_iter_wrapped.split(X, y)))))
1037+
np.testing.assert_equal(list(kf_randomized_iter_wrapped.split(X, y)),
1038+
list(kf_randomized_iter_wrapped.split(X, y)))
1039+
1040+
try:
1041+
np.testing.assert_equal(list(kf_iter_wrapped.split(X, y)),
1042+
list(kf_randomized_iter_wrapped.split(X, y)))
1043+
splits_are_equal = True
1044+
except AssertionError:
1045+
splits_are_equal = False
1046+
assert_false(splits_are_equal, "If the splits are randomized, "
1047+
"successive calls to split should yield different results")
10411048

10421049

10431050
def test_group_kfold():

0 commit comments

Comments
 (0)