Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 455e214

Browse files
author
Fabian Pedregosa
committed
Revert "Comment out non-python2.5 test"
This reverts commit 59a7b18.
1 parent 45e8ac7 commit 455e214

File tree

1 file changed

+14
-10
lines changed

1 file changed

+14
-10
lines changed

sklearn/linear_model/tests/test_omp.py

Lines changed: 14 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -60,15 +60,17 @@ def test_with_without_gram_tol():
6060

6161

6262
def test_unreachable_accuracy():
63-
warnings.simplefilter('always')
64-
assert_array_almost_equal(
65-
orthogonal_mp(X, y, tol=0),
66-
orthogonal_mp(X, y, n_nonzero_coefs=n_features))
63+
with warnings.catch_warnings(record=True) as w:
64+
warnings.simplefilter('always')
65+
assert_array_almost_equal(
66+
orthogonal_mp(X, y, tol=0),
67+
orthogonal_mp(X, y, n_nonzero_coefs=n_features))
6768

68-
assert_array_almost_equal(
69-
orthogonal_mp(X, y, tol=0, precompute_gram=True),
70-
orthogonal_mp(X, y, precompute_gram=True,
71-
n_nonzero_coefs=n_features))
69+
assert_array_almost_equal(
70+
orthogonal_mp(X, y, tol=0, precompute_gram=True),
71+
orthogonal_mp(X, y, precompute_gram=True,
72+
n_nonzero_coefs=n_features))
73+
assert len(w) > 0 # warnings should be raised
7274

7375

7476
def test_bad_input():
@@ -122,5 +124,7 @@ def test_identical_regressors():
122124
gamma = np.zeros(n_features)
123125
gamma[0] = gamma[1] = 1.
124126
newy = np.dot(newX, gamma)
125-
warnings.simplefilter('always')
126-
orthogonal_mp(newX, newy, 2)
127+
with warnings.catch_warnings(record=True) as w:
128+
warnings.simplefilter('always')
129+
orthogonal_mp(newX, newy, 2)
130+
assert len(w) == 1

0 commit comments

Comments
 (0)