From 749ecb2407a9d4d3daec4b0e15f28e6341f2d1a0 Mon Sep 17 00:00:00 2001 From: jorenham Date: Mon, 16 Dec 2024 16:55:52 +0100 Subject: [PATCH] =?UTF-8?q?=F0=9F=8F=B7=EF=B8=8F=20SPEC-7=20compliant=20`s?= =?UTF-8?q?cipy.=5Ftyping.ToRNG`=20type=20alias=20(previously=20`Seed`)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- scipy-stubs/_typing.pyi | 54 ++++--- scipy-stubs/cluster/vq.pyi | 2 +- scipy-stubs/interpolate/_polyint.pyi | 4 +- scipy-stubs/linalg/_sketches.pyi | 8 +- scipy-stubs/optimize/_basinhopping.pyi | 4 +- .../optimize/_differentialevolution.pyi | 4 +- scipy-stubs/optimize/_dual_annealing.pyi | 4 +- scipy-stubs/optimize/_optimize.pyi | 4 +- scipy-stubs/sparse/_construct.pyi | 42 ++--- scipy-stubs/sparse/linalg/_eigen/_svds.pyi | 4 +- scipy-stubs/spatial/transform/_rotation.pyi | 4 +- scipy-stubs/stats/_continuous_distns.pyi | 6 +- scipy-stubs/stats/_distn_infrastructure.pyi | 28 ++-- scipy-stubs/stats/_fit.pyi | 4 +- scipy-stubs/stats/_kde.pyi | 4 +- scipy-stubs/stats/_mgc.pyi | 4 +- scipy-stubs/stats/_multicomp.pyi | 6 +- scipy-stubs/stats/_multivariate.pyi | 148 +++++++++--------- scipy-stubs/stats/_qmc.pyi | 24 +-- scipy-stubs/stats/_resampling.pyi | 6 +- scipy-stubs/stats/_sampling.pyi | 10 +- scipy-stubs/stats/_sensitivity_analysis.pyi | 6 +- scipy-stubs/stats/_stats_py.pyi | 4 +- scipy-stubs/stats/_unuran/unuran_wrapper.pyi | 18 +-- 24 files changed, 206 insertions(+), 196 deletions(-) diff --git a/scipy-stubs/_typing.pyi b/scipy-stubs/_typing.pyi index f980d182..53022b22 100644 --- a/scipy-stubs/_typing.pyi +++ b/scipy-stubs/_typing.pyi @@ -1,4 +1,4 @@ -# NOTE(scipy-stubs): This ia a module only exists `if typing.TYPE_CHECKING: ...` +# NOTE: This private(!) module only exists in `if typing.TYPE_CHECKING: ...` and in `.pyi` stubs from os import PathLike from collections.abc import Callable, Sequence @@ -27,7 +27,7 @@ __all__ = [ "NanPolicy", "OrderCF", "OrderKACF", - "Seed", + "ToRNG", "Untyped", "UntypedArray", "UntypedCallable", @@ -48,6 +48,21 @@ class EnterNoneMixin: def __enter__(self, /) -> None: ... def __exit__(self, /, type: type[BaseException] | None, value: BaseException | None, tb: TracebackType | None) -> None: ... +# used in `scipy.linalg.blas` and `scipy.linalg.lapack` +@type_check_only +class _FortranFunction(Protocol): + @property + def dtype(self, /) -> np.dtype[np.number[Any]]: ... + @property + def int_dtype(self, /) -> np.dtype[np.integer[Any]]: ... + @property + def module_name(self, /) -> LiteralString: ... + @property + def prefix(self, /) -> LiteralString: ... + @property + def typecode(self, /) -> LiteralString: ... + def __call__(self, /, *args: object, **kwargs: object) -> object: ... + # placeholders for missing annotations Untyped: TypeAlias = Any UntypedTuple: TypeAlias = tuple[Untyped, ...] @@ -69,32 +84,27 @@ AnyBool: TypeAlias = bool | np.bool_ | Literal[0, 1] # equivalent to `numpy._typing._shape._ShapeLike` AnyShape: TypeAlias = op.CanIndex | Sequence[op.CanIndex] -# numpy types -RNG: TypeAlias = np.random.BitGenerator | np.random.Generator | np.random.RandomState -Seed: TypeAlias = RNG | np.random.SeedSequence | onp.ToJustInt | onp.ToJustIntND +RNG: TypeAlias = np.random.Generator | np.random.RandomState +# NOTE: This is less incorrect and more accurate than the current `np.random.default_rng` `seed` param annotation. +ToRNG: TypeAlias = ( + np.integer[Any] + | np.timedelta64 + | onp.ArrayND[np.integer[Any] | np.timedelta64 | np.flexible | np.object_] + | np.random.SeedSequence + | np.random.BitGenerator + | RNG + | None +) + +# numpy literals ByteOrder: TypeAlias = Literal["S", "<", "little", ">", "big", "=", "native", "|", "I"] OrderCF: TypeAlias = Literal["C", "F"] -OrderKACF: TypeAlias = Literal["K", "A", "C", "F"] +OrderKACF: TypeAlias = Literal["K", "A", OrderCF] Casting: TypeAlias = Literal["no", "equiv", "safe", "same_kind", "unsafe"] CorrelateMode: TypeAlias = Literal["valid", "same", "full"] # scipy literals NanPolicy: TypeAlias = Literal["raise", "propagate", "omit"] Alternative: TypeAlias = Literal["two-sided", "less", "greater"] -DCTType: TypeAlias = Literal[1, 2, 3, 4] NormalizationMode: TypeAlias = Literal["backward", "ortho", "forward"] - -# used in `scipy.linalg.blas` and `scipy.linalg.lapack` -@type_check_only -class _FortranFunction(Protocol): - @property - def dtype(self, /) -> np.dtype[np.number[Any]]: ... - @property - def int_dtype(self, /) -> np.dtype[np.integer[Any]]: ... - @property - def module_name(self, /) -> LiteralString: ... - @property - def prefix(self, /) -> LiteralString: ... - @property - def typecode(self, /) -> LiteralString: ... - def __call__(self, /, *args: object, **kwargs: object) -> object: ... +DCTType: TypeAlias = Literal[1, 2, 3, 4] diff --git a/scipy-stubs/cluster/vq.pyi b/scipy-stubs/cluster/vq.pyi index a50f96be..a9284187 100644 --- a/scipy-stubs/cluster/vq.pyi +++ b/scipy-stubs/cluster/vq.pyi @@ -3,7 +3,7 @@ from typing_extensions import TypeVar import numpy as np import optype.numpy as onp -from scipy._typing import Seed +from scipy._typing import ToRNG as Seed # TODO(jorenham) __all__ = ["kmeans", "kmeans2", "vq", "whiten"] diff --git a/scipy-stubs/interpolate/_polyint.pyi b/scipy-stubs/interpolate/_polyint.pyi index a54d4e8e..bee37902 100644 --- a/scipy-stubs/interpolate/_polyint.pyi +++ b/scipy-stubs/interpolate/_polyint.pyi @@ -3,7 +3,7 @@ from typing import ClassVar, TypeAlias, overload import numpy as np import optype.numpy as onp -from scipy._typing import Seed +from scipy._typing import ToRNG __all__ = [ "BarycentricInterpolator", @@ -62,7 +62,7 @@ class BarycentricInterpolator(_Interpolator1DWithDerivatives): axis: int = 0, *, wi: onp.ToFloatND | None = None, - random_state: Seed | None = None, + random_state: ToRNG = None, ) -> None: ... def set_yi(self, /, yi: onp.ToComplexND, axis: int | None = None) -> None: ... def add_xi(self, /, xi: onp.ToFloat1D, yi: onp.ToComplexND | None = None) -> None: ... diff --git a/scipy-stubs/linalg/_sketches.pyi b/scipy-stubs/linalg/_sketches.pyi index d73ce5aa..2c56b2b1 100644 --- a/scipy-stubs/linalg/_sketches.pyi +++ b/scipy-stubs/linalg/_sketches.pyi @@ -15,24 +15,24 @@ _ToJust2D: TypeAlias = onp.CanArrayND[_ST] | Sequence[onp.CanArrayND[_ST]] | Seq ### -def cwt_matrix(n_rows: onp.ToInt, n_columns: onp.ToInt, seed: spt.Seed | None = None) -> csc_matrix: ... +def cwt_matrix(n_rows: onp.ToInt, n_columns: onp.ToInt, seed: spt.ToRNG = None) -> csc_matrix: ... # @overload def clarkson_woodruff_transform( input_matrix: onp.ToInt2D, sketch_size: onp.ToInt, - seed: spt.Seed | None = None, + seed: spt.ToRNG = None, ) -> onp.Array2D[np.int_]: ... @overload def clarkson_woodruff_transform( input_matrix: _ToJust2D[np.floating[Any], float], sketch_size: onp.ToInt, - seed: spt.Seed | None = None, + seed: spt.ToRNG = None, ) -> onp.Array2D[np.float64 | np.longdouble]: ... @overload def clarkson_woodruff_transform( input_matrix: _ToJust2D[np.complexfloating[Any, Any], complex], sketch_size: onp.ToInt, - seed: spt.Seed | None = None, + seed: spt.ToRNG = None, ) -> onp.Array2D[np.complex64 | np.clongdouble]: ... diff --git a/scipy-stubs/optimize/_basinhopping.pyi b/scipy-stubs/optimize/_basinhopping.pyi index c7fa4462..23ced6de 100644 --- a/scipy-stubs/optimize/_basinhopping.pyi +++ b/scipy-stubs/optimize/_basinhopping.pyi @@ -3,7 +3,7 @@ from typing import Concatenate, Literal, Protocol, TypeAlias, TypeVar, type_chec import numpy as np import optype.numpy as onp -from scipy._typing import Seed +from scipy._typing import ToRNG from ._minimize import OptimizeResult as _MinimizeResult from ._optimize import OptimizeResult as _OptimizeResult from ._typing import MinimizerKwargs @@ -61,7 +61,7 @@ def basinhopping( interval: onp.ToJustInt = 50, disp: onp.ToBool = False, niter_success: onp.ToJustInt | None = None, - seed: Seed | None = None, + seed: ToRNG = None, *, target_accept_rate: onp.ToFloat = 0.5, stepwise_factor: onp.ToFloat = 0.9, diff --git a/scipy-stubs/optimize/_differentialevolution.pyi b/scipy-stubs/optimize/_differentialevolution.pyi index dd2c428b..2048e36c 100644 --- a/scipy-stubs/optimize/_differentialevolution.pyi +++ b/scipy-stubs/optimize/_differentialevolution.pyi @@ -3,7 +3,7 @@ from typing import Concatenate, Literal, TypeAlias, TypeVar import numpy as np import optype.numpy as onp -from scipy._typing import Seed +from scipy._typing import ToRNG from scipy.optimize import OptimizeResult as _OptimizeResult from ._constraints import Bounds, LinearConstraint, NonlinearConstraint @@ -54,7 +54,7 @@ def differential_evolution( tol: onp.ToFloat = 0.01, mutation: onp.ToFloat | tuple[onp.ToFloat, onp.ToFloat] = (0.5, 1), recombination: onp.ToFloat = 0.7, - seed: Seed | None = None, + seed: ToRNG = None, callback: Callable[[OptimizeResult], None] | Callable[[_Float1D, onp.ToFloat], None] | None = None, disp: onp.ToBool = False, polish: onp.ToBool = True, diff --git a/scipy-stubs/optimize/_dual_annealing.pyi b/scipy-stubs/optimize/_dual_annealing.pyi index 437461d0..2f6f70ab 100644 --- a/scipy-stubs/optimize/_dual_annealing.pyi +++ b/scipy-stubs/optimize/_dual_annealing.pyi @@ -3,7 +3,7 @@ from typing import Concatenate, Literal, TypeAlias import numpy as np import optype.numpy as onp -from scipy._typing import Seed +from scipy._typing import ToRNG from scipy.optimize import OptimizeResult as _OptimizeResult from ._constraints import Bounds from ._typing import MinimizerKwargs @@ -36,7 +36,7 @@ def dual_annealing( visit: onp.ToFloat = 2.62, accept: onp.ToFloat = -5.0, maxfun: onp.ToFloat = 10_000_000.0, - seed: Seed | None = None, + seed: ToRNG = None, no_local_search: onp.ToBool = False, callback: Callable[[_Float1D, float, Literal[0, 1, 2]], bool | None] | None = None, x0: onp.ToFloat1D | None = None, diff --git a/scipy-stubs/optimize/_optimize.pyi b/scipy-stubs/optimize/_optimize.pyi index f6e2f18c..55034b5f 100644 --- a/scipy-stubs/optimize/_optimize.pyi +++ b/scipy-stubs/optimize/_optimize.pyi @@ -5,7 +5,7 @@ from typing_extensions import TypeVar import numpy as np import optype.numpy as onp from scipy._lib._util import _RichResult -from scipy._typing import AnyBool, Seed +from scipy._typing import AnyBool, ToRNG from ._linesearch import line_search_wolfe2 as line_search from ._typing import Brack, MethodAll, Solver @@ -662,5 +662,5 @@ def check_grad( *args: object, epsilon: onp.ToFloat = ..., direction: Literal["all", "random"] = "all", - seed: Seed | None = None, + seed: ToRNG = None, ) -> _Float: ... diff --git a/scipy-stubs/sparse/_construct.pyi b/scipy-stubs/sparse/_construct.pyi index ab5903ab..b34301ac 100644 --- a/scipy-stubs/sparse/_construct.pyi +++ b/scipy-stubs/sparse/_construct.pyi @@ -5,7 +5,7 @@ import numpy as np import numpy.typing as npt import optype.numpy as onp import optype.typing as opt -from scipy._typing import Seed +from scipy._typing import ToRNG from ._base import _spbase, sparray from ._bsr import bsr_array, bsr_matrix from ._coo import coo_array, coo_matrix @@ -897,7 +897,7 @@ def random_array( density: float | Float = 0.01, format: SPFormat = "coo", dtype: ToDTypeFloat | None = None, - random_state: Seed | None = None, + random_state: ToRNG = None, data_sampler: _DataSampler | None = None, ) -> _SpArray1D[np.float64]: ... @overload # shape: 1d, dtype: @@ -907,7 +907,7 @@ def random_array( density: float | Float = 0.01, format: SPFormat = "coo", dtype: ToDType[_SCT], - random_state: Seed | None = None, + random_state: ToRNG = None, data_sampler: _DataSampler | None = None, ) -> _SpArray1D[_SCT]: ... @overload # shape: 1d, dtype: complex @@ -917,7 +917,7 @@ def random_array( density: float | Float = 0.01, format: SPFormat = "coo", dtype: ToDTypeComplex, - random_state: Seed | None = None, + random_state: ToRNG = None, data_sampler: _DataSampler | None = None, ) -> _SpArray1D[np.complex128]: ... @overload # shape: 1d, dtype: @@ -927,7 +927,7 @@ def random_array( density: float | Float = 0.01, format: SPFormat = "coo", dtype: npt.DTypeLike, - random_state: Seed | None = None, + random_state: ToRNG = None, data_sampler: _DataSampler | None = None, ) -> _SpArray1D: ... @overload # shape: 2d, dtype: @@ -937,7 +937,7 @@ def random_array( density: float | Float = 0.01, format: SPFormat = "coo", dtype: ToDTypeFloat | None = None, - random_state: Seed | None = None, + random_state: ToRNG = None, data_sampler: _DataSampler | None = None, ) -> _SpArray2D[np.float64]: ... @overload # shape: 2d, dtype: @@ -947,7 +947,7 @@ def random_array( density: float | Float = 0.01, format: SPFormat = "coo", dtype: ToDType[_SCT], - random_state: Seed | None = None, + random_state: ToRNG = None, data_sampler: _DataSampler | None = None, ) -> _SpArray2D[_SCT]: ... @overload # shape: 2d, dtype: complex @@ -957,7 +957,7 @@ def random_array( density: float | Float = 0.01, format: SPFormat = "coo", dtype: ToDTypeComplex, - random_state: Seed | None = None, + random_state: ToRNG = None, data_sampler: _DataSampler | None = None, ) -> _SpArray2D[np.complex128]: ... @overload # shape: 2d, dtype: @@ -967,7 +967,7 @@ def random_array( density: float | Float = 0.01, format: SPFormat = "coo", dtype: npt.DTypeLike, - random_state: Seed | None = None, + random_state: ToRNG = None, data_sampler: _DataSampler | None = None, ) -> _SpArray2D: ... @@ -979,7 +979,7 @@ def random( density: float | Float = 0.01, format: SPFormat = "coo", dtype: ToDTypeFloat | None = None, - random_state: Seed | None = None, + random_state: ToRNG = None, data_rvs: _DataRVS | None = None, ) -> _SpMatrix[np.float64]: ... @overload # dtype: (positional) @@ -989,7 +989,7 @@ def random( density: float | Float, format: SPFormat, dtype: ToDType[_SCT], - random_state: Seed | None = None, + random_state: ToRNG = None, data_rvs: _DataRVS | None = None, ) -> _SpMatrix[_SCT]: ... @overload # dtype: (keyword) @@ -1000,7 +1000,7 @@ def random( format: SPFormat = "coo", *, dtype: ToDType[_SCT], - random_state: Seed | None = None, + random_state: ToRNG = None, data_rvs: _DataRVS | None = None, ) -> _SpMatrix[_SCT]: ... @overload # dtype: complex (positional) @@ -1010,7 +1010,7 @@ def random( density: float | Float, format: SPFormat, dtype: ToDTypeComplex, - random_state: Seed | None = None, + random_state: ToRNG = None, data_rvs: _DataRVS | None = None, ) -> _SpMatrix[np.complex128]: ... @overload # dtype: complex (keyword) @@ -1021,7 +1021,7 @@ def random( format: SPFormat = "coo", *, dtype: ToDTypeComplex, - random_state: Seed | None = None, + random_state: ToRNG = None, data_rvs: _DataRVS | None = None, ) -> _SpMatrix[np.complex128]: ... @overload # dtype: @@ -1031,7 +1031,7 @@ def random( density: float | Float = 0.01, format: SPFormat = "coo", dtype: npt.DTypeLike | None = None, - random_state: Seed | None = None, + random_state: ToRNG = None, data_rvs: _DataRVS | None = None, ) -> _SpMatrix: ... @@ -1043,7 +1043,7 @@ def rand( density: float | Float = 0.01, format: SPFormat = "coo", dtype: ToDTypeFloat | None = None, - random_state: Seed | None = None, + random_state: ToRNG = None, ) -> _SpMatrix[np.float64]: ... @overload # dtype: (positional) def rand( @@ -1052,7 +1052,7 @@ def rand( density: float | Float, format: SPFormat, dtype: ToDType[_SCT], - random_state: Seed | None = None, + random_state: ToRNG = None, ) -> _SpMatrix[_SCT]: ... @overload # dtype: (keyword) def rand( @@ -1062,7 +1062,7 @@ def rand( format: SPFormat = "coo", *, dtype: ToDType[_SCT], - random_state: Seed | None = None, + random_state: ToRNG = None, ) -> _SpMatrix[_SCT]: ... @overload # dtype: complex (positional) def rand( @@ -1071,7 +1071,7 @@ def rand( density: float | Float, format: SPFormat, dtype: ToDTypeComplex, - random_state: Seed | None = None, + random_state: ToRNG = None, ) -> _SpMatrix[np.complex128]: ... @overload # dtype: complex (keyword) def rand( @@ -1081,7 +1081,7 @@ def rand( format: SPFormat = "coo", *, dtype: ToDTypeComplex, - random_state: Seed | None = None, + random_state: ToRNG = None, ) -> _SpMatrix[np.complex128]: ... @overload # dtype: def rand( @@ -1090,5 +1090,5 @@ def rand( density: float | Float = 0.01, format: SPFormat = "coo", dtype: npt.DTypeLike | None = None, - random_state: Seed | None = None, + random_state: ToRNG = None, ) -> _SpMatrix: ... diff --git a/scipy-stubs/sparse/linalg/_eigen/_svds.pyi b/scipy-stubs/sparse/linalg/_eigen/_svds.pyi index d4341a3c..1a6788c5 100644 --- a/scipy-stubs/sparse/linalg/_eigen/_svds.pyi +++ b/scipy-stubs/sparse/linalg/_eigen/_svds.pyi @@ -3,7 +3,7 @@ from typing import Literal, TypeAlias, TypeVar import numpy as np import optype.numpy as onp -from scipy._typing import Seed +from scipy._typing import ToRNG from scipy.sparse._base import _spbase from scipy.sparse.linalg import LinearOperator @@ -28,6 +28,6 @@ def svds( maxiter: int | None = None, return_singular_vectors: _ReturnSingularVectors = True, solver: _Solver = "arpack", - random_state: Seed | None = None, + random_state: ToRNG = None, options: Mapping[str, object] | None = None, ) -> tuple[onp.Array2D[_SCT], onp.ArrayND[np.float32 | np.float64], onp.ArrayND[_SCT]]: ... diff --git a/scipy-stubs/spatial/transform/_rotation.pyi b/scipy-stubs/spatial/transform/_rotation.pyi index ae6b9b86..1c301daa 100644 --- a/scipy-stubs/spatial/transform/_rotation.pyi +++ b/scipy-stubs/spatial/transform/_rotation.pyi @@ -2,7 +2,7 @@ from collections.abc import Sequence import numpy as np import optype.numpy as onp -from scipy._typing import Seed +from scipy._typing import ToRNG class Rotation: @property @@ -69,7 +69,7 @@ class Rotation: @classmethod def identity(cls, num: int | None = ...) -> Rotation: ... @classmethod - def random(cls, num: int | None = ..., random_state: Seed | None = ...) -> Rotation: ... + def random(cls, num: int | None = ..., random_state: ToRNG = ...) -> Rotation: ... @classmethod def align_vectors( cls, diff --git a/scipy-stubs/stats/_continuous_distns.pyi b/scipy-stubs/stats/_continuous_distns.pyi index 43afd8d1..29308239 100644 --- a/scipy-stubs/stats/_continuous_distns.pyi +++ b/scipy-stubs/stats/_continuous_distns.pyi @@ -4,7 +4,7 @@ from typing_extensions import LiteralString, deprecated, override import numpy as np import optype.numpy as onp -from scipy._typing import Seed +from scipy._typing import ToRNG from ._distn_infrastructure import _rv_continuous_0, rv_continuous __all__ = [ @@ -358,9 +358,9 @@ class rv_histogram(rv_continuous): self, /, histogram: tuple[onp.ArrayND[np.floating[Any]], onp.ArrayND[np.inexact[Any]]], - *args: float | LiteralString | Seed, + *args: float | LiteralString | ToRNG, density: bool | None = None, - **kwargs: float | LiteralString | Seed, + **kwargs: float | LiteralString | ToRNG, ) -> None: ... class studentized_range_gen(rv_continuous): ... diff --git a/scipy-stubs/stats/_distn_infrastructure.pyi b/scipy-stubs/stats/_distn_infrastructure.pyi index 85d35817..35a1ed8e 100644 --- a/scipy-stubs/stats/_distn_infrastructure.pyi +++ b/scipy-stubs/stats/_distn_infrastructure.pyi @@ -96,7 +96,7 @@ class rv_frozen(Generic[_RVT_co, _VT_f8_co]): @property def random_state(self, /) -> spt.RNG: ... @random_state.setter - def random_state(self, seed: spt.Seed, /) -> None: ... + def random_state(self, seed: spt.ToRNG, /) -> None: ... # @overload @@ -152,7 +152,7 @@ class rv_frozen(Generic[_RVT_co, _VT_f8_co]): def isf(self, /, q: _ArrLike_f8_co) -> _VT_f8_co | _Arr_f8: ... # - def rvs(self, /, size: spt.AnyShape | None = None, random_state: spt.Seed | None = None) -> _ArrLike_f8: ... + def rvs(self, /, size: spt.AnyShape | None = None, random_state: spt.ToRNG = None) -> _ArrLike_f8: ... # @overload @@ -223,11 +223,11 @@ class rv_discrete_frozen(rv_frozen[_RVT_d_co, _VT_f8_co], Generic[_RVT_d_co, _VT # NOTE: Because of the limitations of `ParamSpec`, there is no proper way to annotate specific "positional or keyword arguments". # Considering the Liskov Substitution Principle, the only remaining option is to annotate `*args, and `**kwargs` as `Any`. class rv_generic: - def __init__(self, /, seed: spt.Seed | None = None) -> None: ... + def __init__(self, /, seed: spt.ToRNG = None) -> None: ... @property def random_state(self, /) -> spt.RNG: ... @random_state.setter - def random_state(self, seed: spt.Seed, /) -> None: ... + def random_state(self, seed: spt.ToRNG, /) -> None: ... @abc.abstractmethod def _attach_methods(self, /) -> None: ... def _attach_argparser_methods(self, /) -> None: ... @@ -270,7 +270,7 @@ class rv_generic: def _get_support(self, /, *args: Any, **kwargs: Any) -> _Tuple2[_ArrLike_f8]: ... def _support_mask(self, /, x: _Arr_f8_co, *args: Any) -> _Arr_b1: ... def _open_support_mask(self, /, x: _Arr_f8_co, *args: Any) -> _ArrLike_b1: ... - def _rvs(self, /, *args: Any, size: spt.AnyShape | None = None, random_state: spt.Seed | None = None) -> _ArrLike_f8: ... + def _rvs(self, /, *args: Any, size: spt.AnyShape | None = None, random_state: spt.ToRNG = None) -> _ArrLike_f8: ... def _logcdf(self, /, x: _VT_f8, *args: Any) -> _VT_f8: ... def _sf(self, /, x: _VT_f8, *args: Any) -> _VT_f8: ... def _logsf(self, /, x: _VT_f8, *args: Any) -> _VT_f8: ... @@ -281,7 +281,7 @@ class rv_generic: self, /, *args: _Scalar_f8_co, - random_state: spt.Seed, + random_state: spt.ToRNG, discrete: Literal[True, 1], **kwds: _ArrLike_f8_co, ) -> _ArrLike_i8: ... @@ -290,7 +290,7 @@ class rv_generic: self, /, *args: _Scalar_f8_co, - random_state: spt.Seed, + random_state: spt.ToRNG, discrete: Literal[False, 0] | None = ..., **kwds: _ArrLike_f8_co, ) -> _ArrLike_f8: ... @@ -398,7 +398,7 @@ class rv_continuous(_rv_mixin, rv_generic): name: LiteralString | None = None, longname: LiteralString | None = None, shapes: LiteralString | None = None, - seed: spt.Seed | None = None, + seed: spt.ToRNG = None, ) -> None: ... @overload def __call__(self, /) -> rv_continuous_frozen[Self, _Scalar_f8]: ... @@ -753,7 +753,7 @@ class rv_continuous(_rv_mixin, rv_generic): loc: _Scalar_f8_co = 0, scale: _Scalar_f8_co = 1, size: spt.AnyShape = 1, - random_state: spt.Seed | None = None, + random_state: spt.ToRNG = None, **kwds: _ArrLike_f8_co, ) -> _ArrLike_f8: ... @@ -772,7 +772,7 @@ class rv_discrete(_rv_mixin, rv_generic): inc: int | np.int_ = 1, longname: LiteralString | None = None, shapes: LiteralString | None = None, - seed: spt.Seed | None = None, + seed: spt.ToRNG = None, ) -> Self: ... def __init__( # pyright: ignore[reportInconsistentConstructor] self, @@ -786,7 +786,7 @@ class rv_discrete(_rv_mixin, rv_generic): inc: int | np.int_ = 1, longname: LiteralString | None = None, shapes: LiteralString | None = None, - seed: spt.Seed | None = None, + seed: spt.ToRNG = None, ) -> None: ... # @@ -1012,7 +1012,7 @@ class rv_discrete(_rv_mixin, rv_generic): *args: _ArrLike_f8_co, loc: _ArrLike_f8_co = 0, size: spt.AnyShape = 1, - random_state: spt.Seed | None = None, + random_state: spt.ToRNG = None, **kwds: _ArrLike_f8_co, ) -> _ArrLike_i8: ... @@ -1035,7 +1035,7 @@ class rv_sample(rv_discrete, Generic[_XKT_co, _PKT_co]): inc: int = 1, longname: LiteralString | None = None, shapes: LiteralString | None = None, - seed: spt.Seed | None = None, + seed: spt.ToRNG = None, ) -> None: ... def _entropy(self, /) -> _Scalar_f8: ... vecentropy: Final = _entropy @@ -1227,5 +1227,5 @@ class _rv_continuous_0(rv_continuous): loc: _Scalar_f8_co = 0, scale: _Scalar_f8_co = 1, size: spt.AnyShape = 1, - random_state: spt.Seed | None = None, + random_state: spt.ToRNG = None, ) -> _ArrLike_f8: ... diff --git a/scipy-stubs/stats/_fit.pyi b/scipy-stubs/stats/_fit.pyi index 36788432..b9fc658c 100644 --- a/scipy-stubs/stats/_fit.pyi +++ b/scipy-stubs/stats/_fit.pyi @@ -4,7 +4,7 @@ from typing_extensions import TypeVarTuple, Unpack import numpy as np import optype.numpy as onp -from scipy._typing import Seed +from scipy._typing import ToRNG from scipy.optimize import OptimizeResult from ._distn_infrastructure import rv_continuous, rv_continuous_frozen, rv_discrete @@ -81,5 +81,5 @@ def goodness_of_fit( guessed_params: Mapping[str, onp.ToFloat] | None = None, statistic: _GOFStatName | _GOFStatFunc = "ad", n_mc_samples: int = 9999, - random_state: Seed | None = None, + random_state: ToRNG = None, ) -> GoodnessOfFitResult: ... diff --git a/scipy-stubs/stats/_kde.pyi b/scipy-stubs/stats/_kde.pyi index ce1d624f..2e80c1a4 100644 --- a/scipy-stubs/stats/_kde.pyi +++ b/scipy-stubs/stats/_kde.pyi @@ -4,7 +4,7 @@ from typing_extensions import Self import numpy as np import optype.numpy as onp -from scipy._typing import Seed +from scipy._typing import ToRNG __all__ = ["gaussian_kde"] @@ -48,7 +48,7 @@ class gaussian_kde: maxpts: int | None = None, ) -> np.float64 | np.float32: ... def integrate_kde(self, /, other: Self) -> np.float64 | np.float32: ... - def resample(self, /, size: int | None = None, seed: Seed | None = None) -> _Float2D: ... + def resample(self, /, size: int | None = None, seed: ToRNG = None) -> _Float2D: ... def scotts_factor(self, /) -> np.float64: ... def silverman_factor(self, /) -> np.float64: ... def covariance_factor(self, /) -> np.float64: ... diff --git a/scipy-stubs/stats/_mgc.pyi b/scipy-stubs/stats/_mgc.pyi index 31932e6f..8967beba 100644 --- a/scipy-stubs/stats/_mgc.pyi +++ b/scipy-stubs/stats/_mgc.pyi @@ -4,7 +4,7 @@ from typing_extensions import Self, TypeVar import numpy as np import optype.numpy as onp -from scipy._typing import Seed +from scipy._typing import ToRNG from ._typing import BaseBunch _T = TypeVar("_T") @@ -33,5 +33,5 @@ def multiscale_graphcorr( reps: int = 1000, workers: int | Callable[[Callable[[_T], _R], Iterable[_T]], Sequence[_R]] = 1, is_twosamp: bool = False, - random_state: Seed | None = None, + random_state: ToRNG = None, ) -> MGCResult: ... diff --git a/scipy-stubs/stats/_multicomp.pyi b/scipy-stubs/stats/_multicomp.pyi index d10b2f84..a95cf314 100644 --- a/scipy-stubs/stats/_multicomp.pyi +++ b/scipy-stubs/stats/_multicomp.pyi @@ -3,7 +3,7 @@ from typing import Any, Literal import numpy as np import optype.numpy as onp -from scipy._typing import Alternative, Seed +from scipy._typing import Alternative, ToRNG from ._common import ConfidenceInterval __all__ = ["dunnett"] @@ -20,7 +20,7 @@ class DunnettResult: _mean_control: onp.ArrayND[np.float64] _n_samples: onp.ArrayND[np.int_] _n_control: int - _rng: Seed + _rng: ToRNG _ci: ConfidenceInterval | None = None _ci_cl: float | np.floating[Any] | np.integer[Any] | None = None @@ -30,5 +30,5 @@ def dunnett( *samples: onp.ToFloat1D, control: onp.ToFloat1D, alternative: Alternative = "two-sided", - random_state: Seed | None = None, + random_state: ToRNG = None, ) -> DunnettResult: ... diff --git a/scipy-stubs/stats/_multivariate.pyi b/scipy-stubs/stats/_multivariate.pyi index 52645b0d..ed05b0ab 100644 --- a/scipy-stubs/stats/_multivariate.pyi +++ b/scipy-stubs/stats/_multivariate.pyi @@ -48,13 +48,13 @@ class rng_mixin: @property def random_state(self, /) -> spt.RNG: ... @random_state.setter - def random_state(self, /, seed: spt.Seed) -> None: ... + def random_state(self, /, seed: spt.ToRNG) -> None: ... ### class multi_rv_generic(rng_mixin): - def __init__(self, /, seed: spt.Seed | None = None) -> None: ... - def _get_random_state(self, /, random_state: spt.Seed) -> spt.RNG: ... + def __init__(self, /, seed: spt.ToRNG = None) -> None: ... + def _get_random_state(self, /, random_state: spt.ToRNG) -> spt.RNG: ... class multi_rv_frozen(rng_mixin, Generic[_RVG_co]): _dist: _RVG_co @@ -66,7 +66,7 @@ class multivariate_normal_gen(multi_rv_generic): mean: onp.ToFloat1D | None = None, cov: _AnyCov = 1, allow_singular: bool = False, - seed: spt.Seed | None = None, + seed: spt.ToRNG = None, ) -> multivariate_normal_frozen: ... def logpdf( self, @@ -116,7 +116,7 @@ class multivariate_normal_gen(multi_rv_generic): mean: onp.ToFloat1D | None = None, cov: _AnyCov = 1, size: onp.ToJustInt | tuple[int, ...] = 1, - random_state: spt.Seed | None = None, + random_state: spt.ToRNG = None, ) -> onp.ArrayND[np.float64]: ... def entropy(self, /, mean: onp.ToFloat1D | None = None, cov: _AnyCov = 1) -> np.float64: ... def fit( @@ -142,7 +142,7 @@ class multivariate_normal_frozen(multi_rv_frozen[multivariate_normal_gen]): mean: onp.ToFloat1D | None = None, cov: _AnyCov = 1, allow_singular: bool = False, - seed: spt.Seed | None = None, + seed: spt.ToRNG = None, maxpts: onp.ToJustInt | None = None, abseps: float = 1e-05, releps: float = 1e-05, @@ -153,7 +153,7 @@ class multivariate_normal_frozen(multi_rv_frozen[multivariate_normal_gen]): def pdf(self, /, x: onp.ToFloatND) -> _ScalarOrArray_f8: ... def logcdf(self, /, x: onp.ToFloatND, *, lower_limit: onp.ToFloat1D | None = None) -> _ScalarOrArray_f8: ... def cdf(self, /, x: onp.ToFloatND, *, lower_limit: onp.ToFloat1D | None = None) -> _ScalarOrArray_f8: ... - def rvs(self, /, size: spt.AnyShape = 1, random_state: spt.Seed | None = None) -> onp.ArrayND[np.float64]: ... + def rvs(self, /, size: spt.AnyShape = 1, random_state: spt.ToRNG = None) -> onp.ArrayND[np.float64]: ... def entropy(self, /) -> np.float64: ... class matrix_normal_gen(multi_rv_generic): @@ -163,7 +163,7 @@ class matrix_normal_gen(multi_rv_generic): mean: onp.ToFloat2D | None = None, rowcov: onp.ToFloat2D | onp.ToFloat = 1, colcov: onp.ToFloat2D | onp.ToFloat = 1, - seed: spt.Seed | None = None, + seed: spt.ToRNG = None, ) -> matrix_normal_frozen: ... def logpdf( self, @@ -188,7 +188,7 @@ class matrix_normal_gen(multi_rv_generic): rowcov: onp.ToFloat2D | onp.ToFloat = 1, colcov: onp.ToFloat2D | onp.ToFloat = 1, size: opt.AnyInt = 1, - random_state: spt.Seed | None = None, + random_state: spt.ToRNG = None, ) -> onp.Array3D[np.float64]: ... def entropy(self, /, rowcov: _AnyCov = 1, colcov: _AnyCov = 1) -> np.float64: ... @@ -201,15 +201,15 @@ class matrix_normal_frozen(multi_rv_frozen[matrix_normal_gen]): mean: onp.ToFloat2D | None = None, rowcov: onp.ToFloat | onp.ToFloat2D = 1, colcov: onp.ToFloat | onp.ToFloat2D = 1, - seed: spt.Seed | None = None, + seed: spt.ToRNG = None, ) -> None: ... def logpdf(self, /, X: onp.ToFloatND) -> _ScalarOrArray_f8: ... def pdf(self, /, X: onp.ToFloatND) -> _ScalarOrArray_f8: ... - def rvs(self, /, size: opt.AnyInt = 1, random_state: spt.Seed | None = None) -> onp.Array3D[np.float64]: ... + def rvs(self, /, size: opt.AnyInt = 1, random_state: spt.ToRNG = None) -> onp.Array3D[np.float64]: ... def entropy(self, /) -> np.float64: ... class dirichlet_gen(multi_rv_generic): - def __call__(self, /, alpha: onp.ToFloat1D, seed: spt.Seed | None = None) -> dirichlet_frozen: ... + def __call__(self, /, alpha: onp.ToFloat1D, seed: spt.ToRNG = None) -> dirichlet_frozen: ... def logpdf(self, /, x: onp.ToFloatND, alpha: onp.ToFloat1D) -> _ScalarOrArray_f8: ... def pdf(self, /, x: onp.ToFloatND, alpha: onp.ToFloat1D) -> _ScalarOrArray_f8: ... def mean(self, /, alpha: onp.ToFloat1D) -> onp.Array1D[np.float64]: ... @@ -217,14 +217,14 @@ class dirichlet_gen(multi_rv_generic): def cov(self, /, alpha: onp.ToFloat1D) -> onp.Array2D[np.float64]: ... def entropy(self, /, alpha: onp.ToFloat1D) -> np.float64: ... @overload - def rvs(self, /, alpha: onp.ToFloat1D, size: tuple[()], random_state: spt.Seed | None = None) -> onp.Array1D[np.float64]: ... + def rvs(self, /, alpha: onp.ToFloat1D, size: tuple[()], random_state: spt.ToRNG = None) -> onp.Array1D[np.float64]: ... @overload def rvs( self, /, alpha: onp.ToFloat1D, size: op.CanIndex | tuple[op.CanIndex] = 1, - random_state: spt.Seed | None = None, + random_state: spt.ToRNG = None, ) -> onp.Array2D[np.float64]: ... @overload def rvs( @@ -232,7 +232,7 @@ class dirichlet_gen(multi_rv_generic): /, alpha: onp.ToFloat1D, size: tuple[op.CanIndex, op.CanIndex], - random_state: spt.Seed | None = None, + random_state: spt.ToRNG = None, ) -> onp.Array3D[np.float64]: ... @overload def rvs( @@ -240,13 +240,13 @@ class dirichlet_gen(multi_rv_generic): /, alpha: onp.ToFloat1D, size: tuple[op.CanIndex, op.CanIndex, op.CanIndex, Unpack[tuple[op.CanIndex, ...]]], - random_state: spt.Seed | None = None, + random_state: spt.ToRNG = None, ) -> onp.Array[onp.AtLeast3D, np.float64]: ... class dirichlet_frozen(multi_rv_frozen[dirichlet_gen]): alpha: Final[onp.Array1D[_Scalar_uif]] - def __init__(self, /, alpha: onp.ToFloat1D, seed: spt.Seed | None = None) -> None: ... + def __init__(self, /, alpha: onp.ToFloat1D, seed: spt.ToRNG = None) -> None: ... def logpdf(self, /, x: onp.ToFloatND) -> _ScalarOrArray_f8: ... def pdf(self, /, x: onp.ToFloatND) -> _ScalarOrArray_f8: ... def mean(self, /) -> onp.Array1D[np.float64]: ... @@ -254,27 +254,27 @@ class dirichlet_frozen(multi_rv_frozen[dirichlet_gen]): def cov(self, /) -> onp.Array2D[np.float64]: ... def entropy(self, /) -> np.float64: ... @overload - def rvs(self, /, size: tuple[()], random_state: spt.Seed | None = None) -> onp.Array1D[np.float64]: ... + def rvs(self, /, size: tuple[()], random_state: spt.ToRNG = None) -> onp.Array1D[np.float64]: ... @overload def rvs( self, /, size: op.CanIndex | tuple[op.CanIndex] = 1, - random_state: spt.Seed | None = None, + random_state: spt.ToRNG = None, ) -> onp.Array2D[np.float64]: ... @overload def rvs( self, /, size: tuple[op.CanIndex, op.CanIndex], - random_state: spt.Seed | None = None, + random_state: spt.ToRNG = None, ) -> onp.Array3D[np.float64]: ... @overload def rvs( self, /, size: tuple[op.CanIndex, op.CanIndex, op.CanIndex, Unpack[tuple[op.CanIndex, ...]]], - random_state: spt.Seed | None = None, + random_state: spt.ToRNG = None, ) -> onp.Array[onp.AtLeast3D, np.float64]: ... class wishart_gen(multi_rv_generic): @@ -283,7 +283,7 @@ class wishart_gen(multi_rv_generic): /, df: onp.ToFloat | None = None, scale: _ToFloatMax2D | None = None, - seed: spt.Seed | None = None, + seed: spt.ToRNG = None, ) -> wishart_frozen: ... def logpdf(self, /, x: onp.ToFloatND, df: onp.ToFloat, scale: _ToFloatMax2D) -> _ScalarOrArray_f8: ... def pdf(self, /, x: onp.ToFloatND, df: onp.ToFloat, scale: _ToFloatMax2D) -> _ScalarOrArray_f8: ... @@ -296,7 +296,7 @@ class wishart_gen(multi_rv_generic): df: onp.ToFloat, scale: _ToFloatMax2D, size: onp.ToJustInt | tuple[int, ...] = 1, - random_state: spt.Seed | None = None, + random_state: spt.ToRNG = None, ) -> _ScalarOrArray_f8: ... def entropy(self, /, df: onp.ToFloat, scale: _ToFloatMax2D) -> np.float64: ... @@ -307,13 +307,13 @@ class wishart_frozen(multi_rv_frozen[wishart_gen]): C: Final[onp.Array2D[np.float64]] log_det_scale: Final[float] - def __init__(self, /, df: onp.ToFloat, scale: _ToFloatMax2D, seed: spt.Seed | None = None) -> None: ... + def __init__(self, /, df: onp.ToFloat, scale: _ToFloatMax2D, seed: spt.ToRNG = None) -> None: ... def logpdf(self, /, x: onp.ToFloatND) -> _ScalarOrArray_f8: ... def pdf(self, /, x: onp.ToFloatND) -> _ScalarOrArray_f8: ... def mean(self, /) -> np.float64 | onp.Array2D[np.float64]: ... def mode(self, /) -> np.float64 | None: ... def var(self, /) -> np.float64 | onp.Array2D[np.float64]: ... - def rvs(self, /, size: onp.ToJustInt | onp.AtLeast1D = 1, random_state: spt.Seed | None = None) -> _ScalarOrArray_f8: ... + def rvs(self, /, size: onp.ToJustInt | onp.AtLeast1D = 1, random_state: spt.ToRNG = None) -> _ScalarOrArray_f8: ... def entropy(self, /) -> np.float64: ... class invwishart_gen(wishart_gen): @@ -323,7 +323,7 @@ class invwishart_gen(wishart_gen): /, df: onp.ToFloat | None = None, scale: _ToFloatMax2D | None = None, - seed: spt.Seed | None = None, + seed: spt.ToRNG = None, ) -> invwishart_frozen: ... @override def mean(self, /, df: onp.ToFloat, scale: _ToFloatMax2D) -> np.float64 | None: ... # type: ignore[override] # pyright: ignore[reportIncompatibleMethodOverride] @@ -333,7 +333,7 @@ class invwishart_gen(wishart_gen): def var(self, /, df: onp.ToFloat, scale: _ToFloatMax2D) -> np.float64 | None: ... # type: ignore[override] # pyright: ignore[reportIncompatibleMethodOverride] class invwishart_frozen(multi_rv_frozen[invwishart_gen]): - def __init__(self, /, df: onp.ToFloat, scale: _ToFloatMax2D, seed: spt.Seed | None = None) -> None: ... + def __init__(self, /, df: onp.ToFloat, scale: _ToFloatMax2D, seed: spt.ToRNG = None) -> None: ... def logpdf(self, /, x: onp.ToFloatND) -> _ScalarOrArray_f8: ... def pdf(self, /, x: onp.ToFloatND) -> _ScalarOrArray_f8: ... def mean(self, /) -> np.float64 | onp.Array2D[np.float64]: ... @@ -343,13 +343,13 @@ class invwishart_frozen(multi_rv_frozen[invwishart_gen]): self, /, size: spt.AnyShape = 1, - random_state: spt.Seed | None = None, + random_state: spt.ToRNG = None, ) -> onp.ArrayND[np.float64]: ... def entropy(self, /) -> np.float64: ... # NOTE: `n` and `p` are broadcast-able (although this breaks `.rvs()` at runtime...) class multinomial_gen(multi_rv_generic): - def __call__(self, /, n: onp.ToJustIntND, p: _ToJustFloatND, seed: spt.Seed | None = None) -> multinomial_frozen: ... + def __call__(self, /, n: onp.ToJustIntND, p: _ToJustFloatND, seed: spt.ToRNG = None) -> multinomial_frozen: ... def logpmf(self, /, x: onp.ToFloatND, n: onp.ToJustIntND, p: _ToJustFloatND) -> _ScalarOrArray_f8: ... def pmf(self, /, x: onp.ToFloatND, n: onp.ToJustIntND, p: _ToJustFloatND) -> _ScalarOrArray_f8: ... def mean(self, /, n: onp.ToJustIntND, p: _ToJustFloatND) -> onp.Array[onp.AtLeast1D, np.float64]: ... @@ -362,7 +362,7 @@ class multinomial_gen(multi_rv_generic): n: onp.ToJustIntND, p: _ToJustFloatND, size: tuple[()], - random_state: spt.Seed | None = None, + random_state: spt.ToRNG = None, ) -> onp.Array[onp.AtLeast1D, np.float64]: ... @overload def rvs( @@ -371,43 +371,43 @@ class multinomial_gen(multi_rv_generic): n: onp.ToJustIntND, p: _ToJustFloatND, size: onp.ToJustInt | onp.AtLeast1D | None = None, - random_state: spt.Seed | None = None, + random_state: spt.ToRNG = None, ) -> onp.Array[onp.AtLeast2D, np.float64]: ... # TODO: make generic on the (output) shape-type, i.e. to capture the broadcasting effects (use `TypeVar` with default) class multinomial_frozen(multi_rv_frozen[multinomial_gen]): - def __init__(self, /, n: onp.ToJustIntND, p: _ToJustFloatND, seed: spt.Seed | None = None) -> None: ... + def __init__(self, /, n: onp.ToJustIntND, p: _ToJustFloatND, seed: spt.ToRNG = None) -> None: ... def logpmf(self, /, x: onp.ToFloatND) -> _ScalarOrArray_f8: ... def pmf(self, /, x: onp.ToFloatND) -> _ScalarOrArray_f8: ... def mean(self, /) -> onp.Array[onp.AtLeast1D, np.float64]: ... def cov(self, /) -> onp.Array[onp.AtLeast2D, np.float64]: ... def entropy(self, /) -> _ScalarOrArray_f8: ... @overload - def rvs(self, /, size: tuple[()], random_state: spt.Seed | None = None) -> onp.Array[onp.AtLeast1D, np.float64]: ... + def rvs(self, /, size: tuple[()], random_state: spt.ToRNG = None) -> onp.Array[onp.AtLeast1D, np.float64]: ... @overload def rvs( self, /, size: onp.AtLeast1D | int = 1, - random_state: spt.Seed | None = None, + random_state: spt.ToRNG = None, ) -> onp.Array[onp.AtLeast2D, np.float64]: ... @type_check_only class _group_rv_gen_mixin(Generic[_RVF_co]): - def __call__(self, /, dim: onp.ToJustInt | None = None, seed: spt.Seed | None = None) -> _RVF_co: ... + def __call__(self, /, dim: onp.ToJustInt | None = None, seed: spt.ToRNG = None) -> _RVF_co: ... def rvs( self, /, dim: onp.ToJustInt, size: onp.ToJustInt | None = 1, - random_state: spt.Seed | None = None, + random_state: spt.ToRNG = None, ) -> onp.Array3D[np.float64]: ... @type_check_only class _group_rv_frozen_mixin: dim: onp.ToJustInt - def __init__(self, /, dim: onp.ToJustInt | None = None, seed: spt.Seed | None = None) -> None: ... - def rvs(self, /, size: onp.ToJustInt | None = 1, random_state: spt.Seed | None = None) -> onp.Array3D[np.float64]: ... + def __init__(self, /, dim: onp.ToJustInt | None = None, seed: spt.ToRNG = None) -> None: ... + def rvs(self, /, size: onp.ToJustInt | None = 1, random_state: spt.ToRNG = None) -> onp.Array3D[np.float64]: ... class special_ortho_group_gen(_group_rv_gen_mixin[special_ortho_group_frozen], multi_rv_generic): ... class special_ortho_group_frozen(_group_rv_frozen_mixin, multi_rv_frozen[special_ortho_group_gen]): ... @@ -418,23 +418,23 @@ class unitary_group_frozen(_group_rv_frozen_mixin, multi_rv_frozen[unitary_group # TODO(jorenham): `uniform_direction` is vector-valued, so make generic on the shape-type, default to `tuple[int, int, int]` class uniform_direction_gen(multi_rv_generic): - def __call__(self, /, dim: onp.ToJustInt | None = None, seed: spt.Seed | None = None) -> uniform_direction_frozen: ... + def __call__(self, /, dim: onp.ToJustInt | None = None, seed: spt.ToRNG = None) -> uniform_direction_frozen: ... def rvs( self, /, dim: onp.ToJustInt, size: onp.ToJustInt | None = None, - random_state: spt.Seed | None = None, + random_state: spt.ToRNG = None, ) -> onp.Array3D[np.float64]: ... class uniform_direction_frozen(multi_rv_frozen[uniform_direction_gen]): dim: onp.ToJustInt - def __init__(self, /, dim: onp.ToJustInt | None = None, seed: spt.Seed | None = None) -> None: ... + def __init__(self, /, dim: onp.ToJustInt | None = None, seed: spt.ToRNG = None) -> None: ... def rvs( self, /, size: onp.ToJustInt | None = None, - random_state: spt.Seed | None = None, + random_state: spt.ToRNG = None, ) -> onp.Array3D[np.float64]: ... class random_correlation_gen(multi_rv_generic): @@ -442,7 +442,7 @@ class random_correlation_gen(multi_rv_generic): self, /, eigs: onp.ToFloat1D, - seed: spt.Seed | None = None, + seed: spt.ToRNG = None, tol: _ToJustFloat = 1e-13, diag_tol: _ToJustFloat = 1e-07, ) -> random_correlation_frozen: ... @@ -450,7 +450,7 @@ class random_correlation_gen(multi_rv_generic): self, /, eigs: onp.ToFloat1D, - random_state: spt.Seed | None = None, + random_state: spt.ToRNG = None, tol: _ToJustFloat = 1e-13, diag_tol: _ToJustFloat = 1e-07, ) -> onp.ArrayND[np.float64]: ... @@ -464,11 +464,11 @@ class random_correlation_frozen(multi_rv_frozen[random_correlation_gen]): self, /, eigs: onp.ToFloat1D, - seed: spt.Seed | None = None, + seed: spt.ToRNG = None, tol: _ToJustFloat = 1e-13, diag_tol: _ToJustFloat = 1e-07, ) -> None: ... - def rvs(self, /, random_state: spt.Seed | None = None) -> onp.ArrayND[np.float64]: ... + def rvs(self, /, random_state: spt.ToRNG = None) -> onp.ArrayND[np.float64]: ... class multivariate_t_gen(multi_rv_generic): def __call__( @@ -478,7 +478,7 @@ class multivariate_t_gen(multi_rv_generic): shape: onp.ToFloat | onp.ToFloat2D = 1, df: onp.ToJustInt = 1, allow_singular: bool = False, - seed: spt.Seed | None = None, + seed: spt.ToRNG = None, ) -> multivariate_t_frozen: ... def pdf( self, @@ -508,7 +508,7 @@ class multivariate_t_gen(multi_rv_generic): *, maxpts: onp.ToJustInt | None = None, lower_limit: onp.ToFloat1D | None = None, - random_state: spt.Seed | None = None, + random_state: spt.ToRNG = None, ) -> _ScalarOrArray_f8: ... def entropy( self, @@ -526,7 +526,7 @@ class multivariate_t_gen(multi_rv_generic): df: onp.ToJustInt = 1, *, size: tuple[()], - random_state: spt.Seed | None = None, + random_state: spt.ToRNG = None, ) -> onp.Array1D[np.float64]: ... @overload def rvs( @@ -536,7 +536,7 @@ class multivariate_t_gen(multi_rv_generic): shape: onp.ToFloat | onp.ToFloat2D, df: onp.ToJustInt, size: tuple[()], - random_state: spt.Seed | None = None, + random_state: spt.ToRNG = None, ) -> onp.Array1D[np.float64]: ... @overload def rvs( @@ -546,7 +546,7 @@ class multivariate_t_gen(multi_rv_generic): shape: onp.ToFloat | onp.ToFloat2D = 1, df: onp.ToJustInt = 1, size: onp.ToJustInt | tuple[int] = 1, - random_state: spt.Seed | None = None, + random_state: spt.ToRNG = None, ) -> onp.Array2D[np.float64]: ... @overload def rvs( @@ -557,7 +557,7 @@ class multivariate_t_gen(multi_rv_generic): df: onp.ToJustInt = 1, *, size: onp.AtLeast2D, - random_state: spt.Seed | None = None, + random_state: spt.ToRNG = None, ) -> onp.Array[onp.AtLeast3D, np.float64]: ... @overload def rvs( @@ -567,7 +567,7 @@ class multivariate_t_gen(multi_rv_generic): shape: onp.ToFloat | onp.ToFloat2D, df: onp.ToJustInt, size: onp.AtLeast2D, - random_state: spt.Seed | None = None, + random_state: spt.ToRNG = None, ) -> onp.Array[onp.AtLeast3D, np.float64]: ... class multivariate_t_frozen(multi_rv_frozen[multivariate_t_gen]): @@ -584,7 +584,7 @@ class multivariate_t_frozen(multi_rv_frozen[multivariate_t_gen]): shape: onp.ToFloat | onp.ToFloat2D = 1, df: onp.ToJustInt = 1, allow_singular: bool = False, - seed: spt.Seed | None = None, + seed: spt.ToRNG = None, ) -> None: ... def logpdf(self, /, x: onp.ToFloatND) -> _ScalarOrArray_f8: ... def pdf(self, /, x: onp.ToFloatND) -> _ScalarOrArray_f8: ... @@ -595,15 +595,15 @@ class multivariate_t_frozen(multi_rv_frozen[multivariate_t_gen]): *, maxpts: onp.ToJustInt | None = None, lower_limit: onp.ToFloat1D | None = None, - random_state: spt.Seed | None = None, + random_state: spt.ToRNG = None, ) -> _ScalarOrArray_f8: ... def entropy(self, /) -> np.float64: ... @overload - def rvs(self, /, size: tuple[()], random_state: spt.Seed | None = None) -> onp.Array1D[np.float64]: ... + def rvs(self, /, size: tuple[()], random_state: spt.ToRNG = None) -> onp.Array1D[np.float64]: ... @overload - def rvs(self, /, size: onp.ToJustInt | tuple[int] = 1, random_state: spt.Seed | None = None) -> onp.Array2D[np.float64]: ... + def rvs(self, /, size: onp.ToJustInt | tuple[int] = 1, random_state: spt.ToRNG = None) -> onp.Array2D[np.float64]: ... @overload - def rvs(self, /, size: onp.AtLeast2D, random_state: spt.Seed | None = None) -> onp.Array[onp.AtLeast3D, np.float64]: ... + def rvs(self, /, size: onp.AtLeast2D, random_state: spt.ToRNG = None) -> onp.Array[onp.AtLeast3D, np.float64]: ... # NOTE: `m` and `n` are broadcastable (but doing so will break `.rvs()` at runtime...) class multivariate_hypergeom_gen(multi_rv_generic): @@ -612,7 +612,7 @@ class multivariate_hypergeom_gen(multi_rv_generic): /, m: onp.ToJustIntND, n: onp.ToJustInt | onp.ToJustIntND, - seed: spt.Seed | None = None, + seed: spt.ToRNG = None, ) -> multivariate_hypergeom_frozen: ... def logpmf(self, /, x: onp.ToFloatND, m: onp.ToJustIntND, n: onp.ToJustInt | onp.ToJustIntND) -> _ScalarOrArray_f8: ... def pmf(self, /, x: onp.ToFloatND, m: onp.ToIntND, n: onp.ToJustInt | onp.ToJustIntND) -> _ScalarOrArray_f8: ... @@ -626,7 +626,7 @@ class multivariate_hypergeom_gen(multi_rv_generic): m: onp.ToIntND, n: onp.ToJustInt | onp.ToJustIntND, size: tuple[()], - random_state: spt.Seed | None = None, + random_state: spt.ToRNG = None, ) -> onp.Array[onp.AtLeast1D, np.float64]: ... @overload def rvs( @@ -635,31 +635,31 @@ class multivariate_hypergeom_gen(multi_rv_generic): m: onp.ToIntND, n: onp.ToJustInt | onp.ToJustIntND, size: op.CanIndex | tuple[op.CanIndex, Unpack[tuple[op.CanIndex, ...]]] | None = None, - random_state: spt.Seed | None = None, + random_state: spt.ToRNG = None, ) -> onp.Array[onp.AtLeast2D, np.float64]: ... # TODO: make generic with a shape type-param (with default) to capture the broadcasting effects class multivariate_hypergeom_frozen(multi_rv_frozen[multivariate_hypergeom_gen]): - def __init__(self, /, m: onp.ToIntND, n: onp.ToJustInt | onp.ToJustIntND, seed: spt.Seed | None = None) -> None: ... + def __init__(self, /, m: onp.ToIntND, n: onp.ToJustInt | onp.ToJustIntND, seed: spt.ToRNG = None) -> None: ... def logpmf(self, /, x: onp.ToFloatND) -> _ScalarOrArray_f8: ... def pmf(self, /, x: onp.ToFloatND) -> _ScalarOrArray_f8: ... def mean(self, /) -> onp.Array[onp.AtLeast1D, np.float64]: ... def var(self, /) -> onp.Array[onp.AtLeast1D, np.float64]: ... def cov(self, /) -> onp.Array[onp.AtLeast2D, np.float64]: ... @overload - def rvs(self, /, size: tuple[()], random_state: spt.Seed | None = None) -> onp.Array[onp.AtLeast1D, np.float64]: ... + def rvs(self, /, size: tuple[()], random_state: spt.ToRNG = None) -> onp.Array[onp.AtLeast1D, np.float64]: ... @overload def rvs( self, /, size: op.CanIndex | tuple[op.CanIndex, Unpack[tuple[op.CanIndex, ...]]] = 1, - random_state: spt.Seed | None = None, + random_state: spt.ToRNG = None, ) -> onp.Array[onp.AtLeast2D, np.float64]: ... _RandomTableRVSMethod: TypeAlias = Literal["boyett", "patefield"] class random_table_gen(multi_rv_generic): - def __call__(self, /, row: onp.ToJustIntND, col: onp.ToJustIntND, *, seed: spt.Seed | None = None) -> random_table_frozen: ... + def __call__(self, /, row: onp.ToJustIntND, col: onp.ToJustIntND, *, seed: spt.ToRNG = None) -> random_table_frozen: ... def logpmf(self, /, x: onp.ToFloatND, row: onp.ToJustIntND, col: onp.ToJustIntND) -> _ScalarOrArray_f8: ... def pmf(self, /, x: onp.ToFloatND, row: onp.ToJustIntND, col: onp.ToJustIntND) -> _ScalarOrArray_f8: ... def mean(self, /, row: onp.ToJustIntND, col: onp.ToJustIntND) -> onp.Array2D[np.float64]: ... @@ -671,11 +671,11 @@ class random_table_gen(multi_rv_generic): *, size: onp.ToJustInt | onp.ToJustInt1D | None = None, method: _RandomTableRVSMethod | None = None, - random_state: spt.Seed | None = None, + random_state: spt.ToRNG = None, ) -> onp.Array3D[np.float64]: ... class random_table_frozen(multi_rv_frozen[random_table_gen]): - def __init__(self, /, row: onp.ToJustIntND, col: onp.ToJustIntND, *, seed: spt.Seed | None = None) -> None: ... + def __init__(self, /, row: onp.ToJustIntND, col: onp.ToJustIntND, *, seed: spt.ToRNG = None) -> None: ... def logpmf(self, /, x: onp.ToFloatND) -> _ScalarOrArray_f8: ... def pmf(self, /, x: onp.ToFloatND) -> _ScalarOrArray_f8: ... def mean(self, /) -> onp.Array2D[np.float64]: ... @@ -684,7 +684,7 @@ class random_table_frozen(multi_rv_frozen[random_table_gen]): /, size: onp.ToJustInt | onp.ToJustInt1D | None = None, method: _RandomTableRVSMethod | None = None, - random_state: spt.Seed | None = None, + random_state: spt.ToRNG = None, ) -> onp.Array3D[np.float64]: ... class dirichlet_multinomial_gen(multi_rv_generic): @@ -693,7 +693,7 @@ class dirichlet_multinomial_gen(multi_rv_generic): /, alpha: onp.ToFloatND, n: onp.ToJustIntND, - seed: spt.Seed | None = None, + seed: spt.ToRNG = None, ) -> dirichlet_multinomial_frozen: ... def logpmf(self, /, x: onp.ToIntND, alpha: onp.ToFloatND, n: onp.ToJustIntND) -> _ScalarOrArray_f8: ... def pmf(self, /, x: onp.ToIntND, alpha: onp.ToFloatND, n: onp.ToJustIntND) -> _ScalarOrArray_f8: ... @@ -706,7 +706,7 @@ class dirichlet_multinomial_frozen(multi_rv_frozen[dirichlet_multinomial_gen]): alpha: onp.Array[onp.AtLeast1D, np.float64] n: onp.Array[onp.AtLeast1D, np.int_] # broadcasted against alpha - def __init__(self, /, alpha: onp.ToFloatND, n: onp.ToJustIntND, seed: spt.Seed | None = None) -> None: ... + def __init__(self, /, alpha: onp.ToFloatND, n: onp.ToJustIntND, seed: spt.ToRNG = None) -> None: ... def logpmf(self, /, x: onp.ToIntND) -> _ScalarOrArray_f8: ... def pmf(self, /, x: onp.ToIntND) -> _ScalarOrArray_f8: ... def mean(self, /) -> onp.Array[onp.AtLeast1D, np.float64]: ... @@ -719,7 +719,7 @@ class vonmises_fisher_gen(multi_rv_generic): /, mu: onp.ToFloat1D | None = None, kappa: opt.JustInt = 1, - seed: spt.Seed | None = None, + seed: spt.ToRNG = None, ) -> vonmises_fisher_frozen: ... def logpdf(self, /, x: onp.ToFloatND, mu: onp.ToFloat1D | None = None, kappa: opt.JustInt = 1) -> _ScalarOrArray_f8: ... def pdf(self, /, x: onp.ToFloatND, mu: onp.ToFloat1D | None = None, kappa: opt.JustInt = 1) -> _ScalarOrArray_f8: ... @@ -730,12 +730,12 @@ class vonmises_fisher_gen(multi_rv_generic): mu: onp.ToFloat1D | None = None, kappa: opt.JustInt = 1, size: op.CanIndex | tuple[op.CanIndex, Unpack[tuple[op.CanIndex, ...]]] = 1, - random_state: spt.Seed | None = None, + random_state: spt.ToRNG = None, ) -> onp.Array[onp.AtLeast2D, np.float64]: ... def fit(self, /, x: onp.ToFloatND) -> tuple[onp.Array1D[np.float64], float]: ... class vonmises_fisher_frozen(multi_rv_frozen[vonmises_fisher_gen]): - def __init__(self, /, mu: onp.ToFloat1D | None = None, kappa: opt.JustInt = 1, seed: spt.Seed | None = None) -> None: ... + def __init__(self, /, mu: onp.ToFloat1D | None = None, kappa: opt.JustInt = 1, seed: spt.ToRNG = None) -> None: ... def logpdf(self, /, x: onp.ToFloatND) -> _ScalarOrArray_f8: ... def pdf(self, /, x: onp.ToFloatND) -> _ScalarOrArray_f8: ... def entropy(self, /) -> np.float64: ... @@ -743,7 +743,7 @@ class vonmises_fisher_frozen(multi_rv_frozen[vonmises_fisher_gen]): self, /, size: op.CanIndex | tuple[op.CanIndex, Unpack[tuple[op.CanIndex, ...]]] = 1, - random_state: spt.Seed | None = None, + random_state: spt.ToRNG = None, ) -> onp.Array[onp.AtLeast2D, np.float64]: ... multivariate_normal: Final[multivariate_normal_gen] = ... diff --git a/scipy-stubs/stats/_qmc.pyi b/scipy-stubs/stats/_qmc.pyi index 47fc4427..ddd5f409 100644 --- a/scipy-stubs/stats/_qmc.pyi +++ b/scipy-stubs/stats/_qmc.pyi @@ -8,7 +8,7 @@ import numpy as np import optype as op import optype.numpy as onp import optype.typing as opt -from scipy._typing import RNG, Seed +from scipy._typing import RNG, ToRNG from scipy.spatial.distance import _MetricCallback, _MetricKind __all__ = [ @@ -67,7 +67,7 @@ class QMCEngine(abc.ABC): num_generated: int @abc.abstractmethod - def __init__(self, /, d: onp.ToInt, *, optimization: _MethodQMC | None = None, seed: Seed | None = None) -> None: ... + def __init__(self, /, d: onp.ToInt, *, optimization: _MethodQMC | None = None, seed: ToRNG = None) -> None: ... def random(self, /, n: opt.AnyInt = 1, *, workers: onp.ToInt = 1) -> _Array2D: ... def integers( self, @@ -93,7 +93,7 @@ class Halton(QMCEngine): *, scramble: bool = True, optimization: _MethodQMC | None = None, - seed: Seed | None = None, + seed: ToRNG = None, ) -> None: ... class LatinHypercube(QMCEngine): @@ -108,7 +108,7 @@ class LatinHypercube(QMCEngine): scramble: bool = True, strength: int = 1, optimization: _MethodQMC | None = None, - seed: Seed | None = None, + seed: ToRNG = None, ) -> None: ... class Sobol(QMCEngine): @@ -126,7 +126,7 @@ class Sobol(QMCEngine): scramble: op.CanBool = True, bits: onp.ToInt | None = None, optimization: _MethodQMC | None = None, - seed: Seed | None = None, + seed: ToRNG = None, ) -> None: ... def random_base2(self, /, m: onp.ToInt) -> _Array2D: ... @@ -161,14 +161,14 @@ class PoissonDisk(QMCEngine): hypersphere: Literal["volume", "surface"] = "volume", ncandidates: onp.ToInt = 30, optimization: _MethodQMC | None = None, - seed: Seed | None = None, + seed: ToRNG = None, ) -> None: ... def fill_space(self, /) -> _Array2D: ... @type_check_only class _QMCDistribution: engine: Final[QMCEngine] # defaults to `Sobol` - def __init__(self, /, *, engine: QMCEngine | None = None, seed: Seed | None = None) -> None: ... + def __init__(self, /, *, engine: QMCEngine | None = None, seed: ToRNG = None) -> None: ... def random(self, /, n: onp.ToInt = 1) -> _Array2D: ... class MultivariateNormalQMC(_QMCDistribution): @@ -182,7 +182,7 @@ class MultivariateNormalQMC(_QMCDistribution): cov_root: _Any2D_f_co | None = None, inv_transform: op.CanBool = True, engine: QMCEngine | None = None, - seed: Seed | None = None, + seed: ToRNG = None, ) -> None: ... class MultinomialQMC(_QMCDistribution): @@ -197,7 +197,7 @@ class MultinomialQMC(_QMCDistribution): n_trials: onp.ToInt, *, engine: QMCEngine | None = None, - seed: Seed | None = None, + seed: ToRNG = None, ) -> None: ... # @@ -268,9 +268,9 @@ def _perturb_discrepancy( # @overload -def _van_der_corput_permutation(base: op.CanIndex, *, random_state: Seed | None = None) -> _Array2D[np.int_]: ... +def _van_der_corput_permutation(base: op.CanIndex, *, random_state: ToRNG = None) -> _Array2D[np.int_]: ... @overload -def _van_der_corput_permutation(base: op.CanFloat, *, random_state: Seed | None = None) -> _Array2D: ... +def _van_der_corput_permutation(base: op.CanFloat, *, random_state: ToRNG = None) -> _Array2D: ... # def van_der_corput( @@ -280,7 +280,7 @@ def van_der_corput( start_index: onp.ToInt = 0, scramble: op.CanBool = False, permutations: onp.ToInt | onp.ToIntND | None = None, - seed: Seed | None = None, + seed: ToRNG = None, workers: opt.AnyInt = 1, ) -> _Array1D: ... diff --git a/scipy-stubs/stats/_resampling.pyi b/scipy-stubs/stats/_resampling.pyi index 92f19dbd..5a056ec2 100644 --- a/scipy-stubs/stats/_resampling.pyi +++ b/scipy-stubs/stats/_resampling.pyi @@ -4,7 +4,7 @@ from typing import Any, Literal, Protocol, TypeAlias, type_check_only import numpy as np import optype.numpy as onp -from scipy._typing import Alternative, Seed +from scipy._typing import Alternative, ToRNG from ._common import ConfidenceInterval __all__ = ["bootstrap", "monte_carlo_test", "permutation_test"] @@ -71,7 +71,7 @@ def bootstrap( alternative: Alternative = "two-sided", method: _BootstrapMethod = "BCa", bootstrap_result: BootstrapResult | None = None, - random_state: Seed | None = None, + random_state: ToRNG = None, ) -> BootstrapResult: ... def monte_carlo_test( data: onp.ToFloatND, @@ -105,5 +105,5 @@ def permutation_test( batch: int | None = None, alternative: Alternative = "two-sided", axis: int = 0, - random_state: Seed | None = None, + random_state: ToRNG = None, ) -> PermutationTestResult: ... diff --git a/scipy-stubs/stats/_sampling.pyi b/scipy-stubs/stats/_sampling.pyi index f13229a2..2ca96943 100644 --- a/scipy-stubs/stats/_sampling.pyi +++ b/scipy-stubs/stats/_sampling.pyi @@ -5,7 +5,7 @@ from typing_extensions import TypeVar import numpy as np import optype as op import optype.numpy as onp -from scipy._typing import AnyShape, Seed +from scipy._typing import AnyShape, ToRNG from ._distn_infrastructure import rv_frozen from .qmc import QMCEngine @@ -31,7 +31,7 @@ class RatioUniforms: vmin: onp.ToFloat, vmax: onp.ToFloat, c: onp.ToFloat = 0, - random_state: Seed | None = None, + random_state: ToRNG = None, ) -> None: ... def rvs(self, /, size: AnyShape = 1) -> np.float64 | onp.ArrayND[np.float64]: ... @@ -43,12 +43,12 @@ class FastGeneratorInversion: *, domain: tuple[onp.ToFloat, onp.ToFloat] | None = None, ignore_shape_range: bool = False, - random_state: Seed | None = None, + random_state: ToRNG = None, ) -> None: ... @property def random_state(self, /) -> np.random.Generator: ... @random_state.setter - def random_state(self, random_state: Seed, /) -> None: ... + def random_state(self, random_state: ToRNG, /) -> None: ... @property def loc(self, /) -> float | np.float64: ... @loc.setter @@ -85,7 +85,7 @@ class FastGeneratorInversion: self, /, size: int = 100_000, - random_state: Seed | None = None, + random_state: ToRNG = None, x_error: bool = False, ) -> tuple[np.float64, np.float64]: ... def support(self, /) -> tuple[float, float] | tuple[np.float64, np.float64]: ... diff --git a/scipy-stubs/stats/_sensitivity_analysis.pyi b/scipy-stubs/stats/_sensitivity_analysis.pyi index 8705bfef..e5964121 100644 --- a/scipy-stubs/stats/_sensitivity_analysis.pyi +++ b/scipy-stubs/stats/_sensitivity_analysis.pyi @@ -4,7 +4,7 @@ from typing import Any, Literal, Protocol, TypeAlias import numpy as np import optype.numpy as onp -from scipy._typing import Seed +from scipy._typing import ToRNG from ._resampling import BootstrapResult __all__ = ["sobol_indices"] @@ -46,7 +46,7 @@ class SobolResult: def f_ishigami(x: onp.ToFloat2D) -> onp.Array1D[np.floating[Any]]: ... # -def sample_A_B(n: onp.ToInt, dists: Sequence[PPFDist], random_state: Seed | None = None) -> onp.ArrayND[np.float64]: ... +def sample_A_B(n: onp.ToInt, dists: Sequence[PPFDist], random_state: ToRNG = None) -> onp.ArrayND[np.float64]: ... def sample_AB(A: onp.ArrayND[np.float64], B: onp.ArrayND[np.float64]) -> onp.ArrayND[np.float64]: ... # @@ -63,5 +63,5 @@ def sobol_indices( n: onp.ToInt, dists: Sequence[PPFDist] | None = None, method: _SobolMethod | Literal["saltelli_2010"] = "saltelli_2010", - random_state: Seed | None = None, + random_state: ToRNG = None, ) -> SobolResult: ... diff --git a/scipy-stubs/stats/_stats_py.pyi b/scipy-stubs/stats/_stats_py.pyi index 189bd966..151b77d5 100644 --- a/scipy-stubs/stats/_stats_py.pyi +++ b/scipy-stubs/stats/_stats_py.pyi @@ -8,7 +8,7 @@ import numpy as np import numpy.typing as npt import optype.numpy as onp import optype.typing as opt -from scipy._typing import Alternative, NanPolicy, Seed +from scipy._typing import Alternative, NanPolicy, ToRNG from ._resampling import BootstrapMethod, ResamplingMethod from ._stats_mstats_common import siegelslopes, theilslopes from ._typing import BaseBunch, PowerDivergenceStatistic @@ -690,7 +690,7 @@ def ttest_ind( equal_var: bool = True, nan_policy: NanPolicy = "propagate", permutations: float | None = None, - random_state: Seed | None = None, + random_state: ToRNG = None, alternative: Alternative = "two-sided", trim: float = 0, *, diff --git a/scipy-stubs/stats/_unuran/unuran_wrapper.pyi b/scipy-stubs/stats/_unuran/unuran_wrapper.pyi index e9fc4a4a..d076f5c9 100644 --- a/scipy-stubs/stats/_unuran/unuran_wrapper.pyi +++ b/scipy-stubs/stats/_unuran/unuran_wrapper.pyi @@ -4,7 +4,7 @@ from typing import NamedTuple, Protocol, overload, type_check_only import numpy as np import optype.numpy as onp import scipy.stats as stats -from scipy._typing import Seed +from scipy._typing import ToRNG __all__ = ["DiscreteAliasUrn", "NumericalInversePolynomial", "TransformedDensityRejection", "UNURANError"] @@ -53,10 +53,10 @@ class UError(NamedTuple): class Method: @overload - def rvs(self, /, size: None = None, random_state: Seed | None = None) -> float | int: ... + def rvs(self, /, size: None = None, random_state: ToRNG = None) -> float | int: ... @overload def rvs(self, /, size: int | tuple[int, ...]) -> onp.ArrayND[np.float64 | np.int_]: ... - def set_random_state(self, /, random_state: Seed | None = None) -> None: ... + def set_random_state(self, /, random_state: ToRNG = None) -> None: ... class TransformedDensityRejection(Method): def __init__( @@ -71,7 +71,7 @@ class TransformedDensityRejection(Method): construction_points: onp.ToFloatND = ..., use_dars: bool = ..., max_squeeze_hat_ratio: float = ..., - random_state: Seed | None = ..., + random_state: ToRNG = ..., ) -> None: ... @property def hat_area(self, /) -> float: ... @@ -94,7 +94,7 @@ class SimpleRatioUniforms(Method): pdf_area: float = ..., domain: tuple[float, float] | None = ..., cdf_at_mode: float = ..., - random_state: Seed | None = ..., + random_state: ToRNG = ..., ) -> None: ... class NumericalInversePolynomial(_PPFMethodMixin, Method): @@ -108,7 +108,7 @@ class NumericalInversePolynomial(_PPFMethodMixin, Method): domain: tuple[float, float] | None = ..., order: int = ..., u_resolution: float = ..., - random_state: Seed | None = ..., + random_state: ToRNG = ..., ) -> None: ... @property def intervals(self, /) -> int: ... @@ -136,7 +136,7 @@ class NumericalInverseHermite(_PPFMethodMixin, Method): u_resolution: float = ..., construction_points: onp.ToFloatND | None = ..., max_intervals: int = ..., - random_state: Seed | None = ..., + random_state: ToRNG = ..., ) -> None: ... @property def intervals(self, /) -> int: ... @@ -159,7 +159,7 @@ class DiscreteAliasUrn(Method): *, domain: tuple[float, float] | None = ..., urn_factor: float = ..., - random_state: Seed | None = ..., + random_state: ToRNG = ..., ) -> None: ... class DiscreteGuideTable(_PPFMethodMixin, Method): @@ -170,5 +170,5 @@ class DiscreteGuideTable(_PPFMethodMixin, Method): *, domain: tuple[float, float] | None = ..., guide_factor: float = ..., - random_state: Seed | None = ..., + random_state: ToRNG = ..., ) -> None: ...