random_generator_from_seed¶
-
utilipy.decorators.func_io.
random_generator_from_seed
(function: Optional[Callable] = None, seed_names: Union[str, Sequence[str]] = ('random', 'random_seed'), generator: Callable = <class 'numpy.random.mtrand.RandomState'>, raise_if_not_int: bool = False)[source]¶ Function decorator to convert random seed to random number generator.
- Parameters
- functiontypes.FunctionType or None (optional)
the function to be decoratored if None, then returns decorator to apply.
- seed_nameslist (optional)
possible parameter names for the random seed
- generatorClassType (optional)
ex
numpy.random.default_rng
,numpy.random.RandomState
- raise_if_not_intbool (optional, keyword-only)
raise TypeError if seed argument is not an int.
- Returns
- wrappertypes.FunctionType
wrapper for function converts random seeds to random number generators before calling. includes the original function in a method
__wrapped__
- Raises
- TypeError
If
raise_if_not_int
is True and seed argument is not an int.