Thanks to visit codestin.com
Credit goes to github.com

Skip to content

[MNT]: Replace numpy.random in tests by default_rng #23224

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

Closed
timhoffm opened this issue Jun 8, 2022 · 12 comments
Closed

[MNT]: Replace numpy.random in tests by default_rng #23224

timhoffm opened this issue Jun 8, 2022 · 12 comments

Comments

@timhoffm
Copy link
Member

timhoffm commented Jun 8, 2022

as documented in #23221.

To be checked: Is this the same algorithm as before? If not tests would fail and we should not replace the existing calls.

@story645
Copy link
Member

story645 commented Jun 8, 2022

I'm a little confused how this diverges from the discussions in #19706.
ETA: is it cause a) targeted for 3.6, b)intended as a change all the examples together, c) now documented in the tests w/ #23221 ?

@timhoffm
Copy link
Member Author

timhoffm commented Jun 8, 2022

#19706 changed user-facing examples. The fear there is that users are sitting on older versions of matplotlib and numpy and get an error when they copy the example code.

Here the scope is limited to tests. We require numpy 1.17+ for the current codebase and that also applies to tests. People working on matplotlib cannot fall into the numpy-too-old trap.

@tacaswell
Copy link
Member

I am 50/50 if the tests pass with the new generator (seems like a bunch of work and code changes for a low pay-off if numpy is not going to deprecate the old API) and πŸ‘ŽπŸ» if this change requires any tests to be changed (because changing tests is a bad idea on principle).

@timhoffm
Copy link
Member Author

timhoffm commented Jun 8, 2022

I'm fine with closing. But then we should add a note as a follow up to #23221 that existing tests should be kept with the old API.

@tacaswell
Copy link
Member

I honestly neutral on this. Despite my concerns, Jody is right that this is an easy first issue and people are at least as likely to find another test and copy-paste-edit rather than read the docs and write one from scratch so it will be easier on everyone if our tests all follow the documentation.

We should at least find out if it breaks stuff before before closing.

@rcomer
Copy link
Member

rcomer commented Jan 2, 2024

I tried this with one test and it fails because generated data is not the same. A lot of tests in that module that use random data are also using check_figures_equal, so would presumably be fine if the generated data changed. Some tests in the module use random data without setting a seed.

@QuLogic
Copy link
Member

QuLogic commented Jan 3, 2024

Isn't that because you didn't change the standard_normal on the next line, causing it to use the default (un-seeded) generator?

@rcomer
Copy link
Member

rcomer commented Jan 3, 2024

πŸ€¦β€β™€οΈ now updated, but the test still fails.

@QuLogic
Copy link
Member

QuLogic commented Jan 4, 2024

Yes, it appears that default_rng uses PCG64, while the older global functions use MT19937, though I'm not sure how to best replicate that with the objects.

@timhoffm
Copy link
Member Author

timhoffm commented Jan 4, 2024

My 2 cents: If this cannot be simply replaced, it's not worth the effort.

@rcomer
Copy link
Member

rcomer commented Mar 31, 2024

I think the consensus here is that, because the new generator does not give the same numbers, we should not go forward with the replacement.

@tacaswell πŸ‘ŽπŸ» if this change requires any tests to be changed

@timhoffm If this cannot be simply replaced, it's not worth the effort.

So I am going to close. Obviously re-open if you disagree.

@rcomer rcomer closed this as not planned Won't fix, can't repro, duplicate, stale Mar 31, 2024
@WeatherGod
Copy link
Member

WeatherGod commented Mar 31, 2024 via email

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

6 participants