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

ENH: Add the capability to swap the singleton bit generator #21976

Merged
merged 5 commits into from Aug 11, 2022

Conversation

bashtage
Copy link
Contributor

Add a new version or seed that supports seeding any bit gen
Add set/get_bit_generator as explicity methodds to support swapping

closes #21808

@bashtage
Copy link
Contributor Author

bashtage commented Jul 13, 2022

@rkern A first attempt at an API for this. I followed the set/get pattern that is common in np.random so that there is no need for end users to access private variables.

@bashtage
Copy link
Contributor Author

Random failure.

@rkern
Copy link
Member

rkern commented Jul 13, 2022

This doesn't work because the C pointer from the capsule isn't changed when the Python attribute ._bit_generator gets reassigned.

@bashtage
Copy link
Contributor Author

@rkern thanks - I thought it was a property and didn't check (it once was). Added a cdef method to allow it to be set.

@bashtage bashtage force-pushed the enable-hot-swap branch 2 times, most recently from a148eeb to 0c21d8f Compare July 15, 2022 18:10
numpy/random/mtrand.pyx Outdated Show resolved Hide resolved
numpy/random/mtrand.pyx Outdated Show resolved Hide resolved
@mattip
Copy link
Member

mattip commented Jul 17, 2022

This seems like a reasonable thing to add. Is there anything to add around recommended best practices in the general numpy.random documentation?

@leofang
Copy link
Contributor

leofang commented Jul 17, 2022

cc: @emcastillo @kmaehashi for vis

@charris
Copy link
Member

charris commented Aug 8, 2022

Needs rebase.

bashtage and others added 5 commits August 11, 2022 15:28
Add a new version or seed that supports seeding any bit gen
Add set/get_bit_generator as explicity methodds to support swapping

closes numpy#21808
Fix typos and wrap length
Co-authored-by: Matti Picus <matti.picus@gmail.com>
@bashtage
Copy link
Contributor Author

@charris rebased and green.

@charris charris merged commit 0d87f32 into numpy:main Aug 11, 2022
@charris
Copy link
Member

charris commented Aug 11, 2022

Let's give this a shot. Thanks Kevin.

@bashtage bashtage deleted the enable-hot-swap branch August 11, 2022 17:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

ENH: hot-swapping a BitGenerator
5 participants