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.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!

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.5.40.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.5.40-py3-none-any.whl (8.3 kB view details)

Uploaded Python 3

File details

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

File metadata

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

File hashes

Hashes for stablerandom-0.5.40.tar.gz
Algorithm Hash digest
SHA256 3e22d25bf20ebcdced45ebf841d5681502d009f1cbc3fd8f636abc1ba228baff
MD5 55d69af0a26bbd62a4477ea4e6905a3d
BLAKE2b-256 151cc9e232c84fd51225e37af4b8ab5ccf5a728d8142853f6ef1739d03fe5360

See more details on using hashes here.

File details

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

File metadata

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

File hashes

Hashes for stablerandom-0.5.40-py3-none-any.whl
Algorithm Hash digest
SHA256 a72255a6a0aafd1a2c17b98704f5c51d1a605185a94842fc0945f637b5e8a3b2
MD5 b35a7cb37d7c36fb2478877c6ff72534
BLAKE2b-256 005e39211ff6d21d9eea4f1673867ba9b4bd1b258ec5e260a3606242ad4aa281

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