Skip to content

TST use global_random_seed in sklearn/decomposition/tests/test_factor_analysis.py #29272

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 6 commits into from
Jun 20, 2024

Conversation

marenwestermann
Copy link
Member

Reference Issues/PRs

towards #22827

What does this implement/fix? Explain your changes.

I added the global_random_seed fixture to the test test_factor_analysis.

Any other comments?

I haven't submitted anything myself in a while and thought I'll annoy you a bit. 😁

Copy link

github-actions bot commented Jun 16, 2024

✔️ Linting Passed

All linting checks passed. Your pull request is in excellent shape! ☀️

Generated for commit: c78f661. Link to the linter CI: here

@@ -57,7 +57,7 @@ def test_factor_analysis():
# Model Covariance
mcov = fa.get_covariance()
diff = np.sum(np.abs(scov - mcov)) / W.size
assert diff < 0.1, "Mean absolute difference is %f" % diff
assert diff < 0.2, "Mean absolute difference is %f" % diff
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

When I added the global_random_seed fixture I got the following test failures:

FAILED sklearn/decomposition/tests/test_factor_analysis.py::test_factor_analysis[16] - AssertionError: Mean absolute difference is 0.170675
FAILED sklearn/decomposition/tests/test_factor_analysis.py::test_factor_analysis[38] - AssertionError: Mean absolute difference is 0.130926
FAILED sklearn/decomposition/tests/test_factor_analysis.py::test_factor_analysis[96] - AssertionError: Mean absolute difference is 0.134258

By increasing the threshold the failures are fixed. 0.2 looks acceptable to me but let me know if you disagree.

@ogrisel
Copy link
Member

ogrisel commented Jun 17, 2024

Thanks for the PR. Can you please run for all the seeds on the CI?

@marenwestermann
Copy link
Member Author

I triggered the CI twice with the same results. The failures seem to be related to #29278

@lesteve
Copy link
Member

lesteve commented Jun 18, 2024

I triggered the CI twice with the same results. The failures seem to be related to #29278

CI is green now ✅.

The error was actually related to macOS-11 brownout and was fixed by #29281 so I guess merging main into your branch fixed it.

Copy link
Member

@lesteve lesteve left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, thanks!

@lesteve
Copy link
Member

lesteve commented Jun 18, 2024

Just in case (probably overcautious but oh well 😅) I pushed an empty commit to trigger a full CI.

For completeness, you could imagine a very edge case scenario where the last commit has a green CI because it is running a single test with all global random seeds, but actually the last commit has broken some other tests ...

@marenwestermann
Copy link
Member Author

Thanks for your review @lesteve !

The error was actually related to macOS-11 brownout and was fixed by #29281 so I guess merging main into your branch fixed it.

Yes, I saw that. Good to see that it seems to have fixed the issue.

@lesteve lesteve added the Quick Review For PRs that are quick to review label Jun 18, 2024
Copy link
Contributor

@OmarManzoor OmarManzoor left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM. Thanks @marenwestermann

@OmarManzoor OmarManzoor merged commit f6cf690 into scikit-learn:main Jun 20, 2024
31 checks passed
@marenwestermann marenwestermann deleted the test-factor-analysis branch June 20, 2024 14:56
@jeremiedbb jeremiedbb mentioned this pull request Jul 2, 2024
11 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants