-
Notifications
You must be signed in to change notification settings - Fork 590
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
Deprecate use of global PRNG in strategies #3871
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good!
An idea: What if we check more randomness sources, but for performance reasons only occasionally? For example every nth draw, or random spot checks with p<0.1?
I'm saying this because I'd typically reach to np.random
instead of math.random
myself.
since="RELEASEDAY", | ||
has_codemod=False, | ||
stacklevel=1, | ||
) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe consider factoring this out as
with checked_random_state():
result = self.conjecture_data.draw(strategy, observe_as=f"generate:{desc}")
...
?
That would avoid the duplication w/control.py, plus improve readability in these central functions
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, I like it - and we can check a "drew from st.random_module()
flag there too.
Unfortunately Hypothesis will then complain about Maybe we check that less frequently? Or only if you set a flag? Actually I should check the perf cost of doing it every draw, it might not be that bad with |
Ah, yes, of course. We would have to flag the test and warn when done, I guess. No need to go that far in this PR IMO, it can be added later. |
0cd5c79
to
e769f67
Compare
Fixes #3810.