uvex_transients.utils.get_rng#
- uvex_transients.utils.get_rng(rng: Generator | int | None = None) Generator[source]#
Return a NumPy random-number generator.
This function accepts either an existing random-number generator, an integer seed, or
None. It provides a consistent mechanism for constructing reproducible random-number generators throughout the package.- Parameters:
rng (
numpy.random.Generator,int, orNone, optional) –Random-number source.
If a
numpy.random.Generatoris provided, it is returned unchanged.If an integer is provided, a new generator is initialized using that value as the random seed.
If
Noneis provided, a new generator is initialized using NumPy’s default entropy source.
- Returns:
Random-number generator suitable for stochastic operations.
- Return type:
- Raises:
TypeError – If
rngis not anumpy.random.Generator, an integer seed, orNone.
Notes
Passing an existing generator is recommended when several stochastic operations should share the same reproducible random stream.