-
Notifications
You must be signed in to change notification settings - Fork 295
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
[WIP] Add infrastructure for fixed random seeds in tests #1655
base: master
Are you sure you want to change the base?
Conversation
Got it. So at some point we need to print out the random seed being used so that when tests fail we can reproduce their behavior, right? |
Not really. If we do everything right in writing the tests they always use the same seed on all the platforms. The only time things change is when you reorder/change number of calls to the RNG. Though usually you don't do that for debugging a failure. Alternatively you can go in and fix the seeds for the intermediate steps. (I've seen it done that you provide different seeds as parameters to a |
If you like it, I will spread the approach further around the tests. |
Ah, I see. I misunderstood. In contrast, the GenomeTools library (to which I was previously a frequent contributor) has the CI generate and report a new random seed for each build. This way it's are testing the overall robustness of the randomized procedures, not just for a single seed. It was pretty rare, but every once in a while one of the tests would fail on an edge case, and the seed would enable us to track down exactly what happened. Of course, this often requires a different approach to evaluating the output, so I don't know how relevant it would be here, especially in the short term. |
Codecov Report
@@ Coverage Diff @@
## master #1655 +/- ##
==========================================
+ Coverage 69.81% 69.82% +0.01%
==========================================
Files 66 66
Lines 8971 8978 +7
Branches 3060 3063 +3
==========================================
+ Hits 6263 6269 +6
- Misses 1025 1027 +2
+ Partials 1683 1682 -1
Continue to review full report at Codecov.
|
Proposal for fixing random seeds in tests to make them reproducible.
The basic idea is that if you need randomness, you call
check_random_state(seed)
and that you expose theseed
argument to your callers. If they don't care they can not pass anything in, in which caseseed=None
and we get random numbers that aren't reproducible. If they do care they can either pass in a number or an existing random number generator.@standage this is what I had in mind. Shamelessly cribbed from http://scikit-learn.org/stable/modules/generated/sklearn.utils.check_random_state.html
We also use this approach in scikit-optimize.
make test
Did it pass the tests?make clean diff-cover
If it introduces new functionality inscripts/
is it tested?make format diff_pylint_report doc pydocstyle
Is it wellformatted?
additions are allowed without a major version increment. Changing file
formats also requires a major version number increment.
documented in
CHANGELOG.md
? See keepachangelogfor more details.
changes were made?
tested for streaming IO?)