fatf.setup_random_seed(seed: Optional[int] = None) → None[source]

Sets up Python’s and numpy’s random seed.

Fixture for the tests to assure globally controllable seeding of random number generators in both Python (random.seed) and numpy (numpy.random.seed). The seed is taken either from FATF_SEED system variable or from the seed input parameter; if neither of the two is given, it is sampled uniformly from 0–2147483647 range.


If both FATF_SEED system variable and seed input parameter are given, the seed parameter takes the precedence.

This function loggs (info) the origin of the random seed and its value.

seedinteger, optional (default=None)

New in version 0.0.2.

An integer in 0–2147483647 range used to seed Python’s and numpy’s random number generator.


The seed input parameter is not an integer.


The seed input parameter is outside of the allowed 0–2147483647 range. The random seed retrieved from the FATF_SEED system variable is either outside of the allowed range or cannot be parsed as an integer.

Examples using fatf.setup_random_seed