Seed all common RNGs in one call for reproducible experiments.
Project description
seedall
Seed all common RNGs in one call for reproducible experiments.
import seedall
seedall.seed(42) # seeds random, numpy, torch, tensorflow, jax, cupy — whatever is installed
Supported backends
| Backend | What gets seeded |
|---|---|
random |
Python stdlib random |
hashseed |
PYTHONHASHSEED env var |
numpy |
np.random.seed() |
torch |
torch.manual_seed() + cuda.manual_seed_all() |
tensorflow |
tf.random.set_seed() |
jax |
Creates a jax.random.PRNGKey (retrieve via states API) |
cupy |
cp.random.seed() |
Missing libraries are silently skipped — install only what you need.
API
seedall.seed(value, *, backends=None, deterministic=False, warn_missing=False)
Seed all (or selected) backends. Returns dict[str, bool] showing what was seeded.
# Seed everything
seedall.seed(42)
# Seed only specific backends
seedall.seed(42, backends=["numpy", "torch"])
# Also enable PyTorch deterministic mode (slower but fully reproducible)
seedall.seed(42, deterministic=True)
seedall.temp_seed(value, *, deterministic=False)
Context manager — seeds on entry, restores previous RNG states on exit.
with seedall.temp_seed(0):
x = np.random.rand(100) # reproducible
y = np.random.rand(100) # back to original sequence
seedall.available()
List detected backends:
>>> seedall.available()
['random', 'hashseed', 'numpy', 'torch']
seedall.get_states() / seedall.set_states(states)
Snapshot and restore RNG states manually:
states = seedall.get_states()
# ... do stuff ...
seedall.set_states(states) # rewind
seedall.SeedContext(value)
Class-based alternative when a context manager isn't convenient:
ctx = seedall.SeedContext(42)
ctx.enter() # seed
# ... run experiment ...
ctx.exit() # restore
Install
pip install seedall # core (stdlib random only)
pip install seedall[numpy] # + numpy
pip install seedall[torch] # + pytorch
pip install seedall[all] # everything
License
MIT
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
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file seedall-0.2.0.tar.gz.
File metadata
- Download URL: seedall-0.2.0.tar.gz
- Upload date:
- Size: 4.7 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
e5ce94e9ef7585cadc89d760976465760d98193fe7028a1bc322348e1f17e131
|
|
| MD5 |
75109e450cf9174fe52d1010e59fed42
|
|
| BLAKE2b-256 |
ba6e695e34a310e27c5c9fb58ccd12f104cf49456f6e363c37ffd6f1cfe5d289
|
Provenance
The following attestation bundles were made for seedall-0.2.0.tar.gz:
Publisher:
python-publish.yml on jdhouseholder/seedall
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
seedall-0.2.0.tar.gz -
Subject digest:
e5ce94e9ef7585cadc89d760976465760d98193fe7028a1bc322348e1f17e131 - Sigstore transparency entry: 1197117706
- Sigstore integration time:
-
Permalink:
jdhouseholder/seedall@dcefc38f03a26e218c20e5bbff25b9853bdaf0af -
Branch / Tag:
refs/tags/v0.1.1 - Owner: https://github.com/jdhouseholder
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
python-publish.yml@dcefc38f03a26e218c20e5bbff25b9853bdaf0af -
Trigger Event:
release
-
Statement type:
File details
Details for the file seedall-0.2.0-py3-none-any.whl.
File metadata
- Download URL: seedall-0.2.0-py3-none-any.whl
- Upload date:
- Size: 5.8 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
7246c5f8687b60ea9d9232eae5bcddc6c9206ad5ed0fb1d2d80a2b9c5abaea4c
|
|
| MD5 |
dccdb03b04dee389e5a82123b476e2bf
|
|
| BLAKE2b-256 |
bc820fc25223b336c51f03215a7050ba7a1b29a6bacbdaf955ff9c4b79af3136
|
Provenance
The following attestation bundles were made for seedall-0.2.0-py3-none-any.whl:
Publisher:
python-publish.yml on jdhouseholder/seedall
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
seedall-0.2.0-py3-none-any.whl -
Subject digest:
7246c5f8687b60ea9d9232eae5bcddc6c9206ad5ed0fb1d2d80a2b9c5abaea4c - Sigstore transparency entry: 1197117733
- Sigstore integration time:
-
Permalink:
jdhouseholder/seedall@dcefc38f03a26e218c20e5bbff25b9853bdaf0af -
Branch / Tag:
refs/tags/v0.1.1 - Owner: https://github.com/jdhouseholder
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
python-publish.yml@dcefc38f03a26e218c20e5bbff25b9853bdaf0af -
Trigger Event:
release
-
Statement type: