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 …
-
Show this thread
-
Replying to @generativist
I'm sure this will be valuable for many, but the right approach is to *never* rely on global RNG state. You should always be creating isolated random.Random() or np.random.RandomState() objects, which obviates the need for these save/restore state gymnastics.
1 reply 1 retweet 3 likes -
Replying to @shoyer
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?
2 replies 0 retweets 0 likes -
Replying to @generativist
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.
1 reply 1 retweet 1 like -
Replying to @shoyer @generativist
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 replies 0 retweets 1 like -
Replying to @shoyer
Yea, like you expressed in the intro -- it's valuable to many, but passing around the instantiated PRNG is more robust. That said, it's often expensive in smaller codebases or codebases which rely upon packages that don't allow passing.
1 reply 0 retweets 0 likes
My use case is normally small-ish ABM/DES models whose scheduling patterns don't permit simultaneous computation. In which case, I'm restricted to multiprocessing anyway. (Although, I sometimes use an RNG param as a cheap "stochastic" annotation that also permits robustness.)
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.