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

Explicitly allow setting a random seed for subsample #916

Merged
merged 8 commits into from
Apr 4, 2023

Conversation

wasade
Copy link
Member

@wasade wasade commented Mar 24, 2023

Fixes #914. You can now specify the random seed on call to Table.subsample(...).

cc @gibsramen @rob-knight

@gibsramen
Copy link

Thanks, @wasade. How much work would it be to rewrite the random shuffling into the new NumPy random API? Setting seed with np.random.seed is now a legacy function that sets the global random seed which can have some unintended consequences. The new RNG documentation is here.

@wasade
Copy link
Member Author

wasade commented Mar 27, 2023

Good observation. Likely easy given the methods are there but the signature for the underlying cython method will need a minor adjustment

>>> from numpy.random import default_rng
>>> rng = default_rng(12345)
>>> rng.multinomial
<built-in method multinomial of numpy.random._generator.Generator object at 0x7f9c385c1900>
>>> rng.permutation
<built-in method permutation of numpy.random._generator.Generator object at 0x7f9c385c1900>
>>> 

@wasade
Copy link
Member Author

wasade commented Apr 4, 2023

@gibsramen if this is green can you merge?

@gibsramen
Copy link

Looks good, thanks! I think this is good to merge.

@wasade
Copy link
Member Author

wasade commented Apr 4, 2023

Thanks!

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

Successfully merging this pull request may close these issues.

Setting a random seed
2 participants