Mixin Classes#
This module provides access to multiple Mixin classes useful to provide optional functionality to objects which repeatedly uses that functionality.
- class RandomNumberGenerationMixin(random_seed=None)[source]#
Bases:
object
Mixin class that provides a unified interface to random number generation functionality through Numpy Random Number Generator.
This Mixin introduces the following to the object inheriting this Mixin class:
- Attributes:
_RNG: a random number generator created by calling
numpy.random.default_rng()
.
- Properties:
random_number_generator: a reference to the underlying random number generator _RNG.
- Methods:
- update_random_number_generator: reset/Update the underlying random_number generator
by resetting it’s random_seed
Note
When you use this Mixin, make sure you put it as the last class in the inheritance tuple.
- update_random_number_generator(random_seed)[source]#
Reset/Update the underlying random_number generator by resetting it’s random_seed. This actually replaces the current random number generator with a new one created from the given seed
- Parameters:
random_seed (int|None) – an integer (or None) to be used to reset the random sequence
- Remarks:
In the future we may provide an argument to enable changing the generator/algorithm
- property random_number_generator#
Return a handle to the underlying random number generator