Skip to content
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

Reduce reliance on np.random in tests and docs, use new numpy Generator when you must #1016

Open
pllim opened this issue Feb 21, 2023 · 0 comments

Comments

@pllim
Copy link
Member

pllim commented Feb 21, 2023

Tests and doc examples are meant to be reproducible. It does not make sense to use random number generator. I suspect the reason behind such rampant usage was a rush to make fake data in a pinch, not because of true randomness was required. There are two things that need to be addressed:

  1. Reduce the calls to np.random. For example, maybe you can generate it once and store as a test data file, and then just re-use the same data throughout your tests and doctests. Or you can generate it only once in conftest.py or use it as fixture, and then use that same stuff throughout in tests. Or better still, find real data (with reasonable file size) and use that as test data.
  2. When you cannot help it, set a seed. Then refactor the existing calls to use the new numpy random Generator. Stop using the legacy API.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant