stablerandom
stablerandom provides a stable and repeatable implementation of the NumPy random number generator (numpy.random). With this package, you can generate the same sequence of random numbers across different platforms and Python environments, ensuring reproducibility in scientific computing, machine learning, and unit testing.
stablerandom can decorate any function or method and provide a call-stack scoped seeded random generator. stablerandom can also be used as a Context. It is thread safe and supports nested scopes.
Example decorator
Using the @stablerandom decorator to get a stable output for numpy.random.triangular
import numpy.random
from stablerandom import stablerandom
@stablerandom
def random_triangular(samples):
return numpy.random.triangular(1, 5, 10, samples)
print(random_triangular(3))
>>> [5.1017943 2.64970963 8.6996913 ]
print(random_triangular(3))
>>> [5.1017943 2.64970963 8.6996913 ]
Example context
Using the with stablerandom context to get a stable output:
import numpy.random
from stablerandom import stablerandom
with stablerandom:
print(numpy.random.triangular(1, 5, 10, 3))
print(numpy.random.triangular(1, 5, 10, 3))
>>> [5.1017943 2.64970963 8.6996913 ]
>>> [3.30538708 2.39427919 3.57653224]
with stablerandom:
print(numpy.random.triangular(1, 5, 10, 3))
>>> [5.1017943 2.64970963 8.6996913 ]
Installing
$ pip install stablerandom
The source code is currently hosted on GitHub at https://github.com/GistLabs/stablerandom and published in PyPI at https://pypi.org/project/stablerandom/
The versioning scheme currently used is {major}.{minor}.{auto build number}
from git rev-list --count HEAD.
We recommend picking a version like:
stablerandom = "^0.5"
Dependencies
This library has been tested with NumPy back to version 1.22
Community guidelines
We welcome contributions and questions. Please head over to github and send us pull requests or create issues!
Metadata
Release files for stablerandom 0.10.46
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| stablerandom-0.10.46.tar.gz | 7.4 kB | Without provenance | Details for stablerandom-0.10.46.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| stablerandom-0.10.46-py3-none-any.whl | Python 3 | none | any | Details for stablerandom-0.10.46-py3-none-any.whl |
Total release size: 16.3 kB
Release files / stablerandom-0.10.46.tar.gz
| Download URL | stablerandom-0.10.46.tar.gz |
|---|---|
| Size | 7.4 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
5f684b03ec6642f5f8594b24b35885fb172af2630f59e9a0f00d7925501af3bb
|
|
BLAKE2b-256 checksum How to use checksums |
7fd51eb56c66543e9a102c82f1142e743aa3fd32a0c075e7fc7ad592aa09d241
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
poetry/2.1.2 CPython/3.13.2 Linux/6.8.0-1021-azure
|
Release files / stablerandom-0.10.46-py3-none-any.whl
| Download URL | stablerandom-0.10.46-py3-none-any.whl |
|---|---|
| Size | 8.9 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
c45671914a89f86e35db1285781e8fabd672e9e01e406963c428c7913ad47b2f
|
|
BLAKE2b-256 checksum How to use checksums |
d123254dc901cc5cf38be9c048dbccdf798205b8b96365749e788e34114f8df4
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
poetry/2.1.2 CPython/3.13.2 Linux/6.8.0-1021-azure
|
Security for stablerandom 0.10.46
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.