|
| 1 | +from collections.abc import Callable |
| 2 | +from typing import Final, Literal, TypeVar, TypedDict, overload, type_check_only |
| 3 | + |
| 4 | +from numpy.random._generator import Generator |
| 5 | +from numpy.random._mt19937 import MT19937 |
| 6 | +from numpy.random._pcg64 import PCG64, PCG64DXSM |
| 7 | +from numpy.random._philox import Philox |
| 8 | +from numpy.random._sfc64 import SFC64 |
| 9 | +from numpy.random.bit_generator import BitGenerator |
| 10 | +from numpy.random.mtrand import RandomState |
| 11 | + |
| 12 | +_T = TypeVar("_T", bound=BitGenerator) |
| 13 | + |
| 14 | +@type_check_only |
| 15 | +class _BitGenerators(TypedDict): |
| 16 | + MT19937: type[MT19937] |
| 17 | + PCG64: type[PCG64] |
| 18 | + PCG64DXSM: type[PCG64DXSM] |
| 19 | + Philox: type[Philox] |
| 20 | + SFC64: type[SFC64] |
| 21 | + |
| 22 | +BitGenerators: Final[_BitGenerators] = ... |
| 23 | + |
| 24 | +@overload |
| 25 | +def __bit_generator_ctor(bit_generator: Literal["MT19937"] = "MT19937") -> MT19937: ... |
| 26 | +@overload |
| 27 | +def __bit_generator_ctor(bit_generator: Literal["PCG64"]) -> PCG64: ... |
| 28 | +@overload |
| 29 | +def __bit_generator_ctor(bit_generator: Literal["PCG64DXSM"]) -> PCG64DXSM: ... |
| 30 | +@overload |
| 31 | +def __bit_generator_ctor(bit_generator: Literal["Philox"]) -> Philox: ... |
| 32 | +@overload |
| 33 | +def __bit_generator_ctor(bit_generator: Literal["SFC64"]) -> SFC64: ... |
| 34 | +@overload |
| 35 | +def __bit_generator_ctor(bit_generator: type[_T]) -> _T: ... |
| 36 | +def __generator_ctor( |
| 37 | + bit_generator_name: str | type[BitGenerator] | BitGenerator = "MT19937", |
| 38 | + bit_generator_ctor: Callable[[str | type[BitGenerator]], BitGenerator] = ..., |
| 39 | +) -> Generator: ... |
| 40 | +def __randomstate_ctor( |
| 41 | + bit_generator_name: str | type[BitGenerator] | BitGenerator = "MT19937", |
| 42 | + bit_generator_ctor: Callable[[str | type[BitGenerator]], BitGenerator] = ..., |
| 43 | +) -> RandomState: ... |
0 commit comments