-
-
Notifications
You must be signed in to change notification settings - Fork 26k
TST Sets random state in test_csr_row_norms #16509
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
TST Sets random state in test_csr_row_norms #16509
Conversation
how does setting random state make the test more deterministic? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Setting the random_state to make the test pass is not enough. We need to fix the thing that makes the test fail. Here it's because a rtol of 1e-7 is not suitable for float32 because machine precision is ~1.2e-7.
I suggest to use rtol=1e-6 for float32
|
||
scipy_norms = sp.linalg.norm(X, axis=1)**2 | ||
norms = csr_row_norms(X) | ||
|
||
assert norms.dtype == dtype | ||
assert_allclose(norms, scipy_norms) | ||
rtol = 1e-6 if dtype == np.float32 else 1e-7 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
don't remove the other assert 😄
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
lgtm. Thanks @thomasjpfan ! feel free to merge when green
Reference Issues/PRs
Fixes #16506
What does this implement/fix? Explain your changes.
Makes test deterministic by setting random state in
test_csr_row_norms
.The alternative is to lower the tolerance for
float32
.