@@ -60,15 +60,17 @@ def test_with_without_gram_tol():
60
60
61
61
62
62
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 ))
67
68
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
72
74
73
75
74
76
def test_bad_input ():
@@ -122,5 +124,7 @@ def test_identical_regressors():
122
124
gamma = np .zeros (n_features )
123
125
gamma [0 ] = gamma [1 ] = 1.
124
126
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