API reference

andrey.seed_all#

andrey.seed_all(seed=None)[source]#

Seed Python’s random, NumPy’s global generator, and torch from one number.

Use it to make random draws outside Andrey repeatable, like data simulated with np.random. Andrey’s methods with a seed or random_state argument seed their own generator from it (else ANDREY_SEED, else 0), so seed_all does not change their results. torch is seeded only when installed, on the CPU and on every CUDA device.

Parameters:

seed (int | None) – The seed. None reads ANDREY_SEED, and uses 0 when it is unset. Any integer is accepted; NumPy receives its lowest 32 bits.

Returns:

The seed used.

Return type:

int

Raises:

ValueError – If seed is None and ANDREY_SEED is not an integer from 0 to 2**32 - 1.