Randomness
Utilities for dealing with randomness.
def as_rng(seed=None)
#
Converts a valid seed arg into a numpy.random.Generator instance.
PARAMETER | DESCRIPTION |
---|---|
seed |
The seed to use
TYPE:
|
RETURNS | DESCRIPTION |
---|---|
Generator
|
A valid np.random.Generator object to use |
Source code in src/amltk/randomness.py
def as_randomstate(seed=None)
#
Converts a valid seed arg into a numpy.random.RandomState instance.
PARAMETER | DESCRIPTION |
---|---|
seed |
The seed to use
TYPE:
|
RETURNS | DESCRIPTION |
---|---|
RandomState
|
A valid np.random.RandomSTate object to use |
Source code in src/amltk/randomness.py
def as_int(seed=None)
#
Converts a valid seed arg into an integer.
PARAMETER | DESCRIPTION |
---|---|
seed |
The seed to use
TYPE:
|
RETURNS | DESCRIPTION |
---|---|
int
|
A valid integer to use as a seed |
Source code in src/amltk/randomness.py
def randuid(k=8, *, charset=ALPHABET, seed=None)
#
Generate a random alpha-numeric uuid of a specified length.
See: stackoverflow.com/a/56398787/5332072
PARAMETER | DESCRIPTION |
---|---|
k |
The length of the uuid to generate
TYPE:
|
charset |
The charset to use |
seed |
The seed to use
TYPE:
|
RETURNS | DESCRIPTION |
---|---|
str
|
A random uid |