FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

ENH: Add the capability to swap the singleton bit generator by bashtage · Pull Request #21976 · numpy/numpy · GitHub

/ numpy Public

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

Merged
charris merged 5 commits into
numpy:mainfrom
bashtage:enable-hot-swap
Aug 11, 2022
Merged

charris merged 5 commits into
numpy:mainfrom
bashtage:enable-hot-swap

Conversation

Copy link
Copy Markdown
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 commented Jul 13, 2022
edited
Loading

Copy link
Copy Markdown
Contributor Author

@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.

Copy link
Copy Markdown
Contributor Author

Random failure.

rkern commented Jul 13, 2022

Copy link
Copy Markdown
Member

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

Copy link
Copy Markdown
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 force-pushed the enable-hot-swap branch 2 times, most recently from a148eeb to 0c21d8f Compare July 15, 2022 18:10
Comment thread numpy/random/mtrand.pyx Outdated
Comment thread numpy/random/mtrand.pyx Outdated

mattip commented Jul 17, 2022

Copy link
Copy Markdown
Member

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

leofang commented Jul 17, 2022

Copy link
Copy Markdown
Contributor

cc: @emcastillo @kmaehashi for vis

charris commented Aug 8, 2022

Copy link
Copy Markdown
Member

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>

Copy link
Copy Markdown
Contributor Author

@charris rebased and green.

charris merged commit 0d87f32 into numpy:main Aug 11, 2022

charris commented Aug 11, 2022

Copy link
Copy Markdown
Member

Let's give this a shot. Thanks Kevin.

bashtage deleted the enable-hot-swap branch August 11, 2022 17:22
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
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


Back | FazBrowse Home | New Git URL