1/ RFC: I just released a rough cut of pytest-caprng. It captures the state of your random number generator before each test; saves it on failure; and, replays it *exactly* on the next run. If you write randomized algos or simulations, you'll like this.https://github.com/jbn/pytest-caprng …
That's nice in theory, but I find it rarely works in practice. Passing around instantiated RNGs becomes to tedious. E.G. How often do you see scipy.stats dists rvs() sampled with the optional rng param?
-
-
(Although, that does seed an idea for an excellent extension. For those that do are passing around states, a fixture that injects an instantiated RNG which gets cached on failure rather than the global alone is useful!)
- End of conversation
New conversation -
-
-
I mostly use numpy.random's generators rather than scipy.stats, but I do pass around explicit seeds or RNG states in all of my code. scikit-learn is also religious about doing things this way.
-
Beyond easier debugging for failed tests, using explicit states makes it possible to refactor your code independently from RNG changes, and also eliminates flaky tests (which to be fair is much more problematic in larger codebases).
- 2 more replies
New conversation -
Loading seems to be taking a while.
Twitter may be over capacity or experiencing a momentary hiccup. Try again or visit Twitter Status for more information.