Common infrastructure for seeding random number generators.
Project description
Python Seed Manager
Python programs, particularly data science applications, often need to interact with multiple different random number generators.
This package provides a unified interface to seeding them, along with APIs for deriving additional RNG seeds in a predictable way (using NumPy 1.17's new random infrastructure) and constructing random generators.
Quick Start
To get started, just use the seedbank.initialize() function to seed all available random number generators:
import seedbank
seedbank.initialize(65000)
SeedBank will seed all of the known generators that will be available, including:
- Python standard random
- NumPy legacy random
numpy.random
- PyTorch (with
torch.manual_seed()
) - Numba’s NumPy random
- TensorFlow (with
tf.random.set_seed()
) - cupy (with
cupy.random.seed()
)
In addition, it will initialize a root seed for constructing new-style NumPy Generator
instances.
If SeedBank doesn’t support your RNG yet, please submit a pull request!
Developing SeedBank
SeedBank uses Flit for managing dependencies. To set up in a fresh virtual environment:
python -m pip install flit
flit install --pth-file
[conda-lock][] can help you set up a Conda environment (replace linux-64
with your platform):
# install conda-lock in base environment
# alternatively: pip install conda-lock
conda install -c conda-forge conda-lock
# create the lock file
conda-lock -p linux-64 -f pyproject.toml
# create the environment
conda env create -n seedbank -f conda-linux-64.lock
Acknowledgements
This material is based upon work supported by the National Science Foundation under Grant No. IIS 17-51278. Any opinions, findings, and conclusions or recommendations expressed in this material are those of the author(s) and do not necessarily reflect the views of the National Science Foundation.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
File details
Details for the file seedbank-0.2.0a1.tar.gz
.
File metadata
- Download URL: seedbank-0.2.0a1.tar.gz
- Upload date:
- Size: 18.3 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.10.13
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | f0e42d10f9da3316a0152bad2b01ce173dde34312ea7c03e11e10d9852e46b62 |
|
MD5 | 6e24bcf2b247f58ea06ad0f2db10a9cc |
|
BLAKE2b-256 | 5172d3ff439ed020175a4619bd8360f85a1c35ff6600f2b588553ccbeb21511c |
File details
Details for the file seedbank-0.2.0a1-py3-none-any.whl
.
File metadata
- Download URL: seedbank-0.2.0a1-py3-none-any.whl
- Upload date:
- Size: 11.9 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.10.13
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 94d75b78cedc3bb6e04705743672a962f3bc636c9bcefc3c0310755988f1384e |
|
MD5 | b10b227805a3387095d347a19088ee93 |
|
BLAKE2b-256 | 995b80247fe44e8b35997361690ff24ae2cb5cd9934b32cc01a0852d0f56022a |