-
Notifications
You must be signed in to change notification settings - Fork 30
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
Support numpy.random.default_rng #558
Comments
As a workaround, one can use
or similar. The seed and therefore |
Thanks for the note. I haven’t kept up with numpy development since creating pytest-randomly. It doesn’t look like we would be able to support default_rng. There can be may rng instances in user code and we don’t know where they are to reset their seeds. We could perhaps document a pattern for using randomly’s seed to reset other rngs. I have been thinking some hook or pytest fixture could be better than the existing entry points solution. Would that work for you? Maybe we could remove the default numpy support too, since it’s legacy. Updating this library for new python versions always stalls waiting for new numpy versions. |
Yes, I've come to the same conclusion.
That would be a good solution for my purposes. At work, we already use a pytest fixture to provide (new and freshly seeded) numpy RNGs on demand, but we have a custom solution to set the initial seed. It works well, but I'm still interested in randomly because it has a better interface and can shuffle tests.
Do note that numpy has "no plans to remove" the legacy method. |
Okay, I've documented this as legacy in 2cef1c4. |
Description
The readme says:
Nowadays, numpy recommends
numpy.random.default_rng
, which returns a PRNG object and using its methods, e.g.They call
numpy.random.some_probability_distribution
the legacy way.Randomly supports the legacy way. It reseeds with numpy.random.seed, which doesn't affect dedicated generators (which is what one gets from
default_rng
).It'd be great if randomly supported
default_rng
or if the README was adapted.The text was updated successfully, but these errors were encountered: