Skip to main content

Create stable/repeatable numpy.random applications

Project description

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. It is thread safe and supports nested scopes.

Example

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))
>>> [1.99882862 7.95097645 7.68974243]
print(random_triangular(3))
>>> [1.99882862 7.95097645 7.68974243]

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.3"

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!

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

stablerandom-0.4.27.tar.gz (7.0 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

stablerandom-0.4.27-py3-none-any.whl (7.8 kB view details)

Uploaded Python 3

File details

Details for the file stablerandom-0.4.27.tar.gz.

File metadata

  • Download URL: stablerandom-0.4.27.tar.gz
  • Upload date:
  • Size: 7.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.3.2 CPython/3.11.2 Linux/5.15.0-1033-azure

File hashes

Hashes for stablerandom-0.4.27.tar.gz
Algorithm Hash digest
SHA256 21b3ca7e7255492d8e380d6e868a680b1d45303c572f46ace034a1e4ade5bdc7
MD5 d8dd3498c6073b48fd4c62112df5b486
BLAKE2b-256 13a59306fed0017f53b8f3ccc41efee04b5a0ebba4cab8a91adfc557f643ca85

See more details on using hashes here.

File details

Details for the file stablerandom-0.4.27-py3-none-any.whl.

File metadata

  • Download URL: stablerandom-0.4.27-py3-none-any.whl
  • Upload date:
  • Size: 7.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.3.2 CPython/3.11.2 Linux/5.15.0-1033-azure

File hashes

Hashes for stablerandom-0.4.27-py3-none-any.whl
Algorithm Hash digest
SHA256 23da60d258e29020868ea7747e0c69be42092f57b8167dfc8b8796e9833330d1
MD5 8d77f15a9fb640f157d375d16011c3ed
BLAKE2b-256 6ea3e2038602146f03e4e7c1e185db36578775f487e6ca3d6618f7544f58c9ab

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page