You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
As per discussion in #2129, currently if users seed the global PRNG before each test they will get bad results because tests will be weirdly correlated with eachother. We have plenty of mechanisms for controlling determinism if they want to use them, they shouldn't be using this one.
It is still important that we respect random.seed at a global level - i.e. that calling it once makes the whole test suite deterministic - but we don't want to respect it at a per test level.
My recommended solution is as follows:
We store a single Random instance in hypothesis.core which we use as our source of random seeds instead of the global random number generator.
Initially it is set to None. When it is first accessed it will be initialized with a seed from random. This ensures that we respect any seeding that occurs before the first hypothesis test is run.
We fix all of the places in our test suite where we call random.seed.
The third will be the fiddly bit. The first two should be relatively straightforward.
We may also optionally want to think about exposing this as a property that people can set. For example, if we exposed a hypothesis.global_random module attribute that people could set and we used that for everything, this would allow more fine grained control. However I think we don't need to do that to start with - we can just do the first bits and see if anyone complains.
The text was updated successfully, but these errors were encountered:
As per discussion in #2129, currently if users seed the global PRNG before each test they will get bad results because tests will be weirdly correlated with eachother. We have plenty of mechanisms for controlling determinism if they want to use them, they shouldn't be using this one.
It is still important that we respect
random.seedat a global level - i.e. that calling it once makes the whole test suite deterministic - but we don't want to respect it at a per test level.My recommended solution is as follows:
Randominstance inhypothesis.corewhich we use as our source of random seeds instead of the global random number generator.None. When it is first accessed it will be initialized with a seed fromrandom. This ensures that we respect any seeding that occurs before the first hypothesis test is run.random.seed.The third will be the fiddly bit. The first two should be relatively straightforward.
We may also optionally want to think about exposing this as a property that people can set. For example, if we exposed a
hypothesis.global_randommodule attribute that people could set and we used that for everything, this would allow more fine grained control. However I think we don't need to do that to start with - we can just do the first bits and see if anyone complains.The text was updated successfully, but these errors were encountered: