@@ -1624,11 +1624,11 @@ def test_enet_sample_weight_does_not_overwrite_sample_weight(check_input):
16241624@pytest .mark .parametrize (
16251625 ["precompute" , "n_targets" ], [(False , 1 ), (True , 1 ), (False , 3 )]
16261626)
1627- def test_enet_ridge_consistency (ridge_alpha , precompute , n_targets ):
1627+ def test_enet_ridge_consistency (ridge_alpha , precompute , n_targets , global_random_seed ):
16281628 # Check that ElasticNet(l1_ratio=0) converges to the same solution as Ridge
16291629 # provided that the value of alpha is adapted.
16301630
1631- rng = np .random .RandomState (42 )
1631+ rng = np .random .RandomState (global_random_seed )
16321632 n_samples = 300
16331633 X , y = make_regression (
16341634 n_samples = n_samples ,
@@ -1660,9 +1660,10 @@ def test_enet_ridge_consistency(ridge_alpha, precompute, n_targets):
16601660 # The CD solver using the gram matrix (precompute = True) loses numerical precision
16611661 # by working with the squares of matrices like Q=X'X (=gram) and
16621662 # R^2 = y^2 + wQw - 2yQw (=square of residuals).
1663- rtol = 1e-5 if precompute else 1e-7
1664- assert_allclose (enet .coef_ , ridge .coef_ , rtol = rtol )
1665- assert_allclose (enet .intercept_ , ridge .intercept_ )
1663+ rtol = 1e-5 if precompute else 5e-7
1664+ atol = 3e-11
1665+ assert_allclose (enet .coef_ , ridge .coef_ , rtol = rtol , atol = atol )
1666+ assert_allclose (enet .intercept_ , ridge .intercept_ , atol = atol )
16661667
16671668
16681669@pytest .mark .filterwarnings ("ignore:With alpha=0, this algorithm:UserWarning" )
0 commit comments