[WIP] Add infrastructure for fixed random seeds in tests#1655
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 theseedargument to your callers. If they don't care they can not pass anything in, in which caseseed=Noneand 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 testDid it pass the tests?make clean diff-coverIf it introduces new functionality inscripts/is it tested?make format diff_pylint_report doc pydocstyleIs 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?)