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

I have a better way to solve exercise 12 #218

Open
anthonyduong9 opened this issue Oct 1, 2024 · 2 comments
Open

I have a better way to solve exercise 12 #218

anthonyduong9 opened this issue Oct 1, 2024 · 2 comments

Comments

@anthonyduong9
Copy link

I think

rng = np.random.default_rng()
x = rng.random((3, 3, 3))

would be better than

Z = np.random.random((3,3,3))

because the documentation says "[RandomState] should only be used if it is essential to have randoms that are identical to what would have been produced by previous versions of NumPy.".

@anthonyduong9
Copy link
Author

Similarly, the documentation for numpy.random.uniform says random.Generator.uniform "should be used for new code". And a similar thing for the documentation for numpy.random.randint, numpy.random.normal and numpy.random.choice.

@rougier I assume you don't want me to open an issue and PR for every exercise we could change (since there'd be dozens of issues and dozens of PRs), so I'm happy to make all the changes in one PR.

@rougier
Copy link
Owner

rougier commented Oct 21, 2024

One PR per issue is better actually and in this case, I prefer to keep the code identical to "what would have been produced by previous versions of NumPy" because it is important for reproducibility. You could make a PR and keeping both the "deprecated" version and the now recommended one.

Have a look at https://www.frontiersin.org/journals/neuroinformatics/articles/10.3389/fninf.2017.00069/full to read my concern.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants