-
Notifications
You must be signed in to change notification settings - Fork 106
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
New approach to handling randomness in pyMOR #1736
Conversation
@pymor/main, @artpelling this should be roughly what we have discussed at the sprint last week. Please take a look if it makes sense to you. (I did not look at the notebooks/tests yet, and documentation is still missing.) |
@renefritze, @pmli, I have reworked how the random state is set/initialized: |
Codecov Report
Additional details and impacted files
Flags with carried forward coverage won't be shown. Click here to find out more.
|
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 to me (I might have found some commas). I tested it locally with my randomized LinA stuff and it works like a charm!
Closes #1564. |
5a3bcf6
to
d21123f
Compare
Ok, so after rebasing CI segfaults on gitlab. @renefritze, any clue why? |
Seems like some/all other current PRs are affected as well. |
None. |
7d74951
to
52d6909
Compare
Co-authored-by: Petar Mlinarić <mlinaric@vt.edu>
Co-authored-by: Petar Mlinarić <mlinaric@vt.edu>
Co-authored-by: Petar Mlinarić <mlinaric@vt.edu>
Co-authored-by: Art Pelling <a.pelling@tu-berlin.de>
Co-authored-by: Petar Mlinarić <mlinaric@vt.edu>
52d6909
to
b22aa56
Compare
This seems to be a related but different issue with codecove, @renefritze? |
Yeah, no idea what's even failing there. Turned both total and patch coverage targets to 0 now. |
This PR implements a new approach to handling a global random state in pyMOR. Most notable changes compared to the previous approach:
np.random.Generator
class is used instead ofnp.random.RandomState
.seed
andrandom_state
arguments are removed from all function signatures. Instead to execute some function with a prescribed random state, a new global random generator can be locally installed by used theRNG
object returned bynew_rng
as a context manager:spawn_rng
wrapper can be used to create child RNGs to ensure deterministic and uncorrelated behavior. Not callingspawn_rng
where needed will be detected and cause warnings to be emitted.