@@ -656,19 +656,20 @@ def test_glm_sample_weight_consistency(fit_intercept, alpha, GLMEstimator):
656
656
X = rng .rand (n_samples , n_features )
657
657
y = rng .rand (n_samples )
658
658
glm_params = dict (alpha = alpha , fit_intercept = fit_intercept )
659
+ tols = dict (rtol = 1e-12 , atol = 1e-14 )
659
660
660
661
glm = GLMEstimator (** glm_params ).fit (X , y )
661
662
coef = glm .coef_ .copy ()
662
663
663
664
# sample_weight=np.ones(..) should be equivalent to sample_weight=None
664
665
sample_weight = np .ones (y .shape )
665
666
glm .fit (X , y , sample_weight = sample_weight )
666
- assert_allclose (glm .coef_ , coef , rtol = 1e-12 )
667
+ assert_allclose (glm .coef_ , coef , ** tols )
667
668
668
669
# sample_weight are normalized to 1 so, scaling them has no effect
669
670
sample_weight = 2 * np .ones (y .shape )
670
671
glm .fit (X , y , sample_weight = sample_weight )
671
- assert_allclose (glm .coef_ , coef , rtol = 1e-12 )
672
+ assert_allclose (glm .coef_ , coef , ** tols )
672
673
673
674
# setting one element of sample_weight to 0 is equivalent to removing
674
675
# the corresponding sample
@@ -677,7 +678,7 @@ def test_glm_sample_weight_consistency(fit_intercept, alpha, GLMEstimator):
677
678
glm .fit (X , y , sample_weight = sample_weight )
678
679
coef1 = glm .coef_ .copy ()
679
680
glm .fit (X [:- 1 ], y [:- 1 ])
680
- assert_allclose (glm .coef_ , coef1 , rtol = 1e-12 )
681
+ assert_allclose (glm .coef_ , coef1 , ** tols )
681
682
682
683
# check that multiplying sample_weight by 2 is equivalent
683
684
# to repeating corresponding samples twice
@@ -687,9 +688,8 @@ def test_glm_sample_weight_consistency(fit_intercept, alpha, GLMEstimator):
687
688
sample_weight_1 [: n_samples // 2 ] = 2
688
689
689
690
glm1 = GLMEstimator (** glm_params ).fit (X , y , sample_weight = sample_weight_1 )
690
-
691
691
glm2 = GLMEstimator (** glm_params ).fit (X2 , y2 , sample_weight = None )
692
- assert_allclose (glm1 .coef_ , glm2 .coef_ )
692
+ assert_allclose (glm1 .coef_ , glm2 .coef_ , ** tols )
693
693
694
694
695
695
@pytest .mark .parametrize ("solver" , SOLVERS )
0 commit comments