Skip to content

TST use global_random_seed in sklearn/_loss/tests/test_glm_distribution.py #23741

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jun 23, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions sklearn/_loss/tests/test_glm_distribution.py
Original file line number Diff line number Diff line change
Expand Up @@ -101,9 +101,9 @@ def test_deviance_zero(family, chk_values):
],
ids=lambda x: x.__class__.__name__,
)
def test_deviance_derivative(family):
def test_deviance_derivative(family, global_random_seed):
"""Test deviance derivative for different families."""
rng = np.random.RandomState(0)
rng = np.random.RandomState(global_random_seed)
y_true = rng.rand(10)
# make data positive
y_true += np.abs(y_true.min()) + 1e-2
Expand All @@ -120,4 +120,4 @@ def test_deviance_derivative(family):
lambda y_pred: family.deviance_derivative(y_true, y_pred),
y_pred,
) / np.linalg.norm(dev_derivative)
assert abs(err) < 1e-6
assert abs(err) < 3e-6