4
4
# License: BSD 3 clause
5
5
6
6
import math
7
+ import pytest
7
8
import numpy as np
8
9
import scipy .sparse as sp
9
10
20
21
from sklearn .utils .testing import assert_allclose
21
22
from sklearn .utils .testing import assert_greater
22
23
from sklearn .utils .testing import assert_raise_message
23
- from sklearn .utils .testing import ignore_warnings
24
24
from sklearn .utils import compute_class_weight
25
25
from sklearn .utils import check_random_state
26
26
from sklearn .preprocessing import LabelEncoder , LabelBinarizer
@@ -231,7 +231,6 @@ def get_step_size(X, alpha, fit_intercept, classification=True):
231
231
return 1.0 / (np .max (np .sum (X * X , axis = 1 )) + fit_intercept + alpha )
232
232
233
233
234
- @ignore_warnings
235
234
def test_classifier_matching ():
236
235
n_samples = 20
237
236
X , y = make_blobs (n_samples = n_samples , centers = 2 , random_state = 0 ,
@@ -301,7 +300,7 @@ def test_regressor_matching():
301
300
assert_allclose (intercept2 , clf .intercept_ )
302
301
303
302
304
- @ignore_warnings
303
+ @pytest . mark . filterwarnings ( 'ignore:The max_iter was reached' )
305
304
def test_sag_pobj_matches_logistic_regression ():
306
305
"""tests if the sag pobj matches log reg"""
307
306
n_samples = 100
@@ -331,7 +330,7 @@ def test_sag_pobj_matches_logistic_regression():
331
330
assert_array_almost_equal (pobj3 , pobj1 , decimal = 4 )
332
331
333
332
334
- @ignore_warnings
333
+ @pytest . mark . filterwarnings ( 'ignore:The max_iter was reached' )
335
334
def test_sag_pobj_matches_ridge_regression ():
336
335
"""tests if the sag pobj matches ridge reg"""
337
336
n_samples = 100
@@ -363,7 +362,7 @@ def test_sag_pobj_matches_ridge_regression():
363
362
assert_array_almost_equal (pobj3 , pobj2 , decimal = 4 )
364
363
365
364
366
- @ignore_warnings
365
+ @pytest . mark . filterwarnings ( 'ignore:The max_iter was reached' )
367
366
def test_sag_regressor_computed_correctly ():
368
367
"""tests if the sag regressor is computed correctly"""
369
368
alpha = .1
@@ -407,7 +406,6 @@ def test_sag_regressor_computed_correctly():
407
406
# assert_almost_equal(clf2.intercept_, spintercept2, decimal=1)'''
408
407
409
408
410
- @ignore_warnings
411
409
def test_get_auto_step_size ():
412
410
X = np .array ([[1 , 2 , 3 ], [2 , 3 , 4 ], [2 , 3 , 2 ]], dtype = np .float64 )
413
411
alpha = 1.2
@@ -452,7 +450,7 @@ def test_get_auto_step_size():
452
450
max_squared_sum_ , alpha , "wrong" , fit_intercept )
453
451
454
452
455
- @ignore_warnings
453
+ @pytest . mark . filterwarnings ( 'ignore:The max_iter was reached' )
456
454
def test_sag_regressor ():
457
455
"""tests if the sag regressor performs well"""
458
456
xmin , xmax = - 5 , 5
@@ -491,7 +489,7 @@ def test_sag_regressor():
491
489
assert_greater (score2 , 0.5 )
492
490
493
491
494
- @ignore_warnings
492
+ @pytest . mark . filterwarnings ( 'ignore:The max_iter was reached' )
495
493
def test_sag_classifier_computed_correctly ():
496
494
"""tests if the binary classifier is computed correctly"""
497
495
alpha = .1
@@ -534,7 +532,7 @@ def test_sag_classifier_computed_correctly():
534
532
assert_almost_equal (clf2 .intercept_ , spintercept2 , decimal = 1 )
535
533
536
534
537
- @ignore_warnings
535
+ @pytest . mark . filterwarnings ( 'ignore:The max_iter was reached' )
538
536
def test_sag_multiclass_computed_correctly ():
539
537
"""tests if the multiclass classifier is computed correctly"""
540
538
alpha = .1
@@ -593,7 +591,6 @@ def test_sag_multiclass_computed_correctly():
593
591
assert_almost_equal (clf2 .intercept_ [i ], intercept2 [i ], decimal = 1 )
594
592
595
593
596
- @ignore_warnings
597
594
def test_classifier_results ():
598
595
"""tests if classifier results match target"""
599
596
alpha = .1
@@ -618,7 +615,7 @@ def test_classifier_results():
618
615
assert_almost_equal (pred2 , y , decimal = 12 )
619
616
620
617
621
- @ignore_warnings
618
+ @pytest . mark . filterwarnings ( 'ignore:The max_iter was reached' )
622
619
def test_binary_classifier_class_weight ():
623
620
"""tests binary classifier with classweights for each class"""
624
621
alpha = .1
@@ -668,7 +665,7 @@ def test_binary_classifier_class_weight():
668
665
assert_almost_equal (clf2 .intercept_ , spintercept2 , decimal = 1 )
669
666
670
667
671
- @ignore_warnings
668
+ @pytest . mark . filterwarnings ( 'ignore:The max_iter was reached' )
672
669
def test_multiclass_classifier_class_weight ():
673
670
"""tests multiclass with classweights for each class"""
674
671
alpha = .1
0 commit comments