diff --git a/scipy-stubs/_lib/_elementwise_iterative_method.pyi b/scipy-stubs/_lib/_elementwise_iterative_method.pyi index 9e68e1c3..ce8c72d3 100644 --- a/scipy-stubs/_lib/_elementwise_iterative_method.pyi +++ b/scipy-stubs/_lib/_elementwise_iterative_method.pyi @@ -1,11 +1,12 @@ from collections.abc import Callable, Iterable, Mapping, Sequence from types import ModuleType -from typing import Any, Concatenate, Final, Literal, TypeAlias +from typing import Any, Concatenate, Final, TypeAlias from typing_extensions import TypeVar import numpy as np import optype as op import optype.numpy as onp +from scipy._typing import Falsy from ._util import _RichResult ### @@ -35,7 +36,7 @@ def _initialize( func: _FuncRealT, xs: Sequence[onp.ToFloat1D], args: tuple[onp.ToFloat1D, ...], - complex_ok: Literal[False] = False, + complex_ok: Falsy = False, preserve_shape: bool | None = None, xp: _ModuleT | None = None, ) -> tuple[ diff --git a/scipy-stubs/cluster/hierarchy.pyi b/scipy-stubs/cluster/hierarchy.pyi index 931ddfef..63d0ac80 100644 --- a/scipy-stubs/cluster/hierarchy.pyi +++ b/scipy-stubs/cluster/hierarchy.pyi @@ -7,6 +7,7 @@ import numpy as np import optype.numpy as onp import optype.typing as opt from scipy._lib._disjoint_set import DisjointSet +from scipy._typing import Falsy, Truthy from scipy.spatial.distance import _Metric __all__ = [ @@ -141,9 +142,9 @@ def cut_tree( # @overload -def to_tree(Z: onp.ToArray2D, rd: Literal[False] = False) -> ClusterNode: ... +def to_tree(Z: onp.ToArray2D, rd: Falsy = False) -> ClusterNode: ... @overload -def to_tree(Z: onp.ToArray2D, rd: Literal[True]) -> tuple[ClusterNode, list[ClusterNode]]: ... +def to_tree(Z: onp.ToArray2D, rd: Truthy) -> tuple[ClusterNode, list[ClusterNode]]: ... # def optimal_leaf_ordering(Z: onp.ToArray2D, y: onp.ToArrayND, metric: _Metric = "euclidean") -> _LinkageArray: ... diff --git a/scipy-stubs/integrate/_bvp.pyi b/scipy-stubs/integrate/_bvp.pyi index b21c8c3b..8491f0e7 100644 --- a/scipy-stubs/integrate/_bvp.pyi +++ b/scipy-stubs/integrate/_bvp.pyi @@ -4,9 +4,12 @@ from typing_extensions import TypeVar import numpy as np import optype.numpy as onp +from scipy._typing import Falsy, Truthy from scipy.interpolate import PPoly from scipy.sparse import csc_matrix +### + _SCT_fc = TypeVar("_SCT_fc", bound=np.inexact[Any], default=np.float64 | np.complex128) _FunRHS: TypeAlias = Callable[[onp.Array1D, onp.Array2D[_SCT_fc]], onp.ArrayND[_SCT_fc]] @@ -225,7 +228,7 @@ def wrap_functions( bc: _FunBCR[_SCT_fc], fun_jac: _FunRHS_jac[_SCT_fc] | None, bc_jac: _FunBCR_jac[_SCT_fc] | None, - k: Literal[False, 0], + k: Falsy, a: onp.ToFloat, S: onp.Array2D[np.float64] | None, D: onp.Array2D[np.float64] | None, @@ -237,7 +240,7 @@ def wrap_functions( bc: _FunBCR_p[_SCT_fc], fun_jac: _FunRHS_jac_p[_SCT_fc] | None, bc_jac: _FunBCR_jac_p[_SCT_fc] | None, - k: Literal[True, 1], + k: Truthy, a: onp.ToFloat, S: onp.Array2D[np.float64] | None, D: onp.Array2D[np.float64] | None, diff --git a/scipy-stubs/integrate/_ivp/base.pyi b/scipy-stubs/integrate/_ivp/base.pyi index 52e24318..ed1a70a6 100644 --- a/scipy-stubs/integrate/_ivp/base.pyi +++ b/scipy-stubs/integrate/_ivp/base.pyi @@ -3,6 +3,7 @@ from typing import Any, ClassVar, Final, Generic, Literal, TypeVar, overload import numpy as np import optype.numpy as onp +from scipy._typing import Truthy _VT = TypeVar("_VT", bound=onp.ArrayND[np.inexact[Any]], default=onp.ArrayND[np.inexact[Any]]) @@ -32,7 +33,7 @@ class OdeSolver: y0: onp.ToFloatND, t_bound: onp.ToFloat, vectorized: bool, - support_complex: bool = False, + support_complex: onp.ToBool = False, ) -> None: ... @overload def __init__( @@ -43,7 +44,7 @@ class OdeSolver: y0: onp.ToComplexND, t_bound: onp.ToFloat, vectorized: bool, - support_complex: Literal[True], + support_complex: Truthy, ) -> None: ... @property def step_size(self, /) -> float | None: ... diff --git a/scipy-stubs/integrate/_ivp/ivp.pyi b/scipy-stubs/integrate/_ivp/ivp.pyi index a498e820..986f620d 100644 --- a/scipy-stubs/integrate/_ivp/ivp.pyi +++ b/scipy-stubs/integrate/_ivp/ivp.pyi @@ -5,6 +5,7 @@ from typing_extensions import TypedDict, TypeVar, Unpack import numpy as np import optype.numpy as onp from scipy._lib._util import _RichResult +from scipy._typing import Falsy, Truthy from scipy.sparse import sparray, spmatrix from .base import DenseOutput, OdeSolver from .common import OdeSolution @@ -78,7 +79,7 @@ def solve_ivp( t_eval: onp.ToFloat1D | None = None, dense_output: bool = False, events: _Events[_SCT_cf] | None = None, - vectorized: Literal[False, 0] = False, + vectorized: Falsy = False, args: tuple[object, ...] | None = None, **options: Unpack[_SolverOptions], ) -> OdeResult[_SCT_cf]: ... @@ -92,7 +93,7 @@ def solve_ivp( dense_output: bool = False, events: _Events[_SCT_cf] | None = None, *, - vectorized: Literal[True, 1], + vectorized: Truthy, args: tuple[object, ...] | None = None, **options: Unpack[_SolverOptions], ) -> OdeResult[_SCT_cf]: ... diff --git a/scipy-stubs/integrate/_odepack_py.pyi b/scipy-stubs/integrate/_odepack_py.pyi index 29ec4593..df48d992 100644 --- a/scipy-stubs/integrate/_odepack_py.pyi +++ b/scipy-stubs/integrate/_odepack_py.pyi @@ -3,6 +3,7 @@ from typing_extensions import TypeVar, TypeVarTuple, Unpack import numpy as np import optype.numpy as onp +from scipy._typing import Falsy, Truthy from ._typing import ODEInfoDict __all__ = ["ODEintWarning", "odeint"] @@ -31,7 +32,7 @@ def odeint( args: tuple[()] = (), Dfun: _ODEFunc[_YT] | None = None, col_deriv: Literal[0, 1] | bool = 0, - full_output: Literal[False, 0] = 0, + full_output: Falsy = 0, ml: int | None = None, mu: int | None = None, rtol: float | None = None, @@ -46,7 +47,7 @@ def odeint( mxordn: int = 12, mxords: int = 5, printmessg: Literal[0, 1] | bool = 0, - tfirst: Literal[False, 0] = False, + tfirst: Falsy = False, ) -> onp.Array2D[np.floating[Any]]: ... @overload def odeint( @@ -56,7 +57,7 @@ def odeint( args: tuple[()] = (), Dfun: _ODEFunc[_YT] | None = None, col_deriv: Literal[0, 1] | bool = 0, - full_output: Literal[False, 0] = 0, + full_output: Falsy = 0, ml: int | None = None, mu: int | None = None, rtol: float | None = None, @@ -72,7 +73,7 @@ def odeint( mxords: int = 5, printmessg: Literal[0, 1] | bool = 0, *, - tfirst: Literal[True, 1], + tfirst: Truthy, ) -> onp.Array2D[np.floating[Any]]: ... @overload def odeint( @@ -83,7 +84,7 @@ def odeint( Dfun: _ODEFunc[_YT] | None = None, col_deriv: Literal[0, 1] | bool = 0, *, - full_output: Literal[True, 1], + full_output: Truthy, ml: int | None = None, mu: int | None = None, rtol: float | None = None, @@ -98,7 +99,7 @@ def odeint( mxordn: int = 12, mxords: int = 5, printmessg: Literal[0, 1] | bool = 0, - tfirst: Literal[False, 0] = False, + tfirst: Falsy = False, ) -> tuple[onp.Array2D[np.floating[Any]], ODEInfoDict]: ... @overload def odeint( @@ -109,7 +110,7 @@ def odeint( Dfun: _ODEFunc[_YT] | None = None, col_deriv: Literal[0, 1] | bool = 0, *, - full_output: Literal[True, 1], + full_output: Truthy, ml: int | None = None, mu: int | None = None, rtol: float | None = None, @@ -124,7 +125,7 @@ def odeint( mxordn: int = 12, mxords: int = 5, printmessg: Literal[0, 1] | bool = 0, - tfirst: Literal[True, 1], + tfirst: Truthy, ) -> tuple[onp.Array2D[np.floating[Any]], ODEInfoDict]: ... # specified args @@ -136,7 +137,7 @@ def odeint( args: tuple[Unpack[_Ts]] = ..., Dfun: _ODEFunc[_YT, Unpack[_Ts]] | None = None, col_deriv: Literal[0, 1] | bool = 0, - full_output: Literal[False, 0] = 0, + full_output: Falsy = 0, ml: int | None = None, mu: int | None = None, rtol: float | None = None, @@ -151,7 +152,7 @@ def odeint( mxordn: int = 12, mxords: int = 5, printmessg: Literal[0, 1] | bool = 0, - tfirst: Literal[False, 0] = False, + tfirst: Falsy = False, ) -> onp.Array2D[np.floating[Any]]: ... @overload def odeint( @@ -161,7 +162,7 @@ def odeint( args: tuple[Unpack[_Ts]] = ..., Dfun: _ODEFuncInv[_YT, Unpack[_Ts]] | None = None, col_deriv: Literal[0, 1] | bool = 0, - full_output: Literal[False, 0] = 0, + full_output: Falsy = 0, ml: int | None = None, mu: int | None = None, rtol: float | None = None, @@ -177,7 +178,7 @@ def odeint( mxords: int = 5, printmessg: Literal[0, 1] | bool = 0, *, - tfirst: Literal[True, 1], + tfirst: Truthy, ) -> onp.Array2D[np.floating[Any]]: ... @overload def odeint( @@ -188,7 +189,7 @@ def odeint( Dfun: _ODEFunc[_YT, Unpack[_Ts]] | None = None, col_deriv: Literal[0, 1] | bool = 0, *, - full_output: Literal[True, 1], + full_output: Truthy, ml: int | None = None, mu: int | None = None, rtol: float | None = None, @@ -203,7 +204,7 @@ def odeint( mxordn: int = 12, mxords: int = 5, printmessg: Literal[0, 1] | bool = 0, - tfirst: Literal[False, 0] = False, + tfirst: Falsy = False, ) -> tuple[onp.Array2D[np.floating[Any]], ODEInfoDict]: ... @overload def odeint( @@ -214,7 +215,7 @@ def odeint( Dfun: _ODEFuncInv[_YT, Unpack[_Ts]] | None = None, col_deriv: Literal[0, 1] | bool = 0, *, - full_output: Literal[True, 1], + full_output: Truthy, ml: int | None = None, mu: int | None = None, rtol: float | None = None, @@ -229,5 +230,5 @@ def odeint( mxordn: int = 12, mxords: int = 5, printmessg: Literal[0, 1] | bool = 0, - tfirst: Literal[True, 1], + tfirst: Truthy, ) -> tuple[onp.Array2D[np.floating[Any]], ODEInfoDict]: ... diff --git a/scipy-stubs/linalg/_expm_frechet.pyi b/scipy-stubs/linalg/_expm_frechet.pyi index 7cf53d0b..70d80a94 100644 --- a/scipy-stubs/linalg/_expm_frechet.pyi +++ b/scipy-stubs/linalg/_expm_frechet.pyi @@ -2,6 +2,7 @@ from typing import Literal, TypeAlias, overload import numpy as np import optype.numpy as onp +from scipy._typing import Falsy, Truthy __all__ = ["expm_cond", "expm_frechet"] @@ -16,7 +17,7 @@ def expm_frechet( A: onp.ToComplex2D, E: onp.ToComplex2D, method: _Method | None = None, - compute_expm: Literal[True] = True, + compute_expm: Truthy = True, check_finite: bool = True, ) -> tuple[_Float2D, _Float2D] | tuple[_Float2D | _Complex2D, _Complex2D]: ... @overload @@ -24,7 +25,7 @@ def expm_frechet( A: onp.ToComplex2D, E: onp.ToComplex2D, method: _Method | None, - compute_expm: Literal[False], + compute_expm: Falsy, check_finite: bool = True, ) -> tuple[_Float2D, _Float2D] | tuple[_Float2D | _Complex2D, _Complex2D]: ... @overload @@ -33,7 +34,7 @@ def expm_frechet( E: onp.ToComplex2D, method: _Method | None = None, *, - compute_expm: Literal[False], + compute_expm: Falsy, check_finite: bool = True, ) -> tuple[_Float2D, _Float2D] | tuple[_Float2D | _Complex2D, _Complex2D]: ... diff --git a/scipy-stubs/odr/_odrpack.pyi b/scipy-stubs/odr/_odrpack.pyi index d1176449..f6aa4058 100644 --- a/scipy-stubs/odr/_odrpack.pyi +++ b/scipy-stubs/odr/_odrpack.pyi @@ -3,7 +3,7 @@ from typing import Any, Concatenate, Final, Literal, TypeAlias, TypedDict, overl import numpy as np import optype.numpy as onp -from scipy._typing import AnyBool +from scipy._typing import AnyBool, Falsy, Truthy __all__ = ["ODR", "Data", "Model", "OdrError", "OdrStop", "OdrWarning", "Output", "RealData", "odr", "odr_error", "odr_stop"] @@ -300,7 +300,7 @@ def odr( scld: onp.ToFloatND | None = None, work: onp.ArrayND[np.float64] | None = None, iwork: onp.ArrayND[np.int32 | np.int64] | None = None, - full_output: Literal[False, 0] = 0, + full_output: Falsy = 0, ) -> tuple[_Float1D, _Float1D, _Float2D]: ... @overload def odr( @@ -331,5 +331,5 @@ def odr( work: onp.ArrayND[np.float64] | None = None, iwork: onp.ArrayND[np.int32 | np.int64] | None = None, *, - full_output: Literal[True, 1], + full_output: Truthy, ) -> tuple[_Float1D, _Float1D, _Float2D, _FullOutput]: ... diff --git a/scipy-stubs/optimize/_numdiff.pyi b/scipy-stubs/optimize/_numdiff.pyi index 6dc3b8d9..0ec58f8f 100644 --- a/scipy-stubs/optimize/_numdiff.pyi +++ b/scipy-stubs/optimize/_numdiff.pyi @@ -3,6 +3,7 @@ from typing import Concatenate, Literal, TypeAlias, overload import numpy as np import optype.numpy as onp +from scipy._typing import Falsy, Truthy from scipy.sparse import csr_matrix, sparray, spmatrix from scipy.sparse.linalg import LinearOperator @@ -34,7 +35,7 @@ def approx_derivative( f0: _ToFloatOr1D | None = None, bounds: tuple[_ToFloatOr1D, _ToFloatOr1D] = ..., sparsity: None = None, - as_linear_operator: Literal[False, 0] = False, + as_linear_operator: Falsy = False, args: tuple[object, ...] = (), kwargs: Mapping[str, object] | None = None, ) -> _Float1D | onp.Array2D[np.float64]: ... @@ -49,7 +50,7 @@ def approx_derivative( bounds: tuple[_ToFloatOr1D, _ToFloatOr1D] = ..., *, sparsity: _Sparsity, - as_linear_operator: Literal[False, 0] = False, + as_linear_operator: Falsy = False, args: tuple[object, ...] = (), kwargs: Mapping[str, object] | None = None, ) -> csr_matrix: ... @@ -64,7 +65,7 @@ def approx_derivative( bounds: tuple[_ToFloatOr1D, _ToFloatOr1D] = ..., sparsity: _Sparsity | None = None, *, - as_linear_operator: Literal[True, 1], + as_linear_operator: Truthy, args: tuple[object, ...] = (), kwargs: Mapping[str, object] | None = None, ) -> LinearOperator: ... diff --git a/scipy-stubs/optimize/_root.pyi b/scipy-stubs/optimize/_root.pyi index 32452fc8..499496d0 100644 --- a/scipy-stubs/optimize/_root.pyi +++ b/scipy-stubs/optimize/_root.pyi @@ -3,6 +3,7 @@ from typing import Any, Concatenate, Generic, Literal, TypeAlias, TypedDict, Typ import numpy as np import optype.numpy as onp +from scipy._typing import Falsy, Truthy from scipy.sparse.linalg import LinearOperator from ._nonlin import InverseJacobian from ._optimize import OptimizeResult as _OptimizeResult @@ -132,7 +133,7 @@ def root( x0: onp.ToFloatND, args: tuple[object, ...] = (), method: _RootMethod = "hybr", - jac: Callable[Concatenate[onp.ArrayND[np.float64], ...], onp.ToFloatND] | Literal[False, 0] | None = None, + jac: Callable[Concatenate[onp.ArrayND[np.float64], ...], onp.ToFloatND] | Falsy | None = None, tol: onp.ToFloat | None = None, callback: Callable[[onp.ArrayND[np.float64], onp.ArrayND[np.float64]], None] | None = None, options: _RootOptions | None = None, @@ -143,7 +144,7 @@ def root( x0: onp.ToFloatND, args: tuple[object, ...], method: _RootMethod, - jac: Literal[True, 1], + jac: Truthy, tol: onp.ToFloat | None = None, callback: Callable[[onp.ArrayND[np.float64], onp.ArrayND[np.float64]], None] | None = None, options: _RootOptions | None = None, @@ -155,7 +156,7 @@ def root( args: tuple[object, ...] = (), method: _RootMethod = "hybr", *, - jac: Literal[True, 1], + jac: Truthy, tol: onp.ToFloat | None = None, callback: Callable[[onp.ArrayND[np.float64], onp.ArrayND[np.float64]], None] | None = None, options: _RootOptions | None = None, diff --git a/scipy-stubs/optimize/_slsqp_py.pyi b/scipy-stubs/optimize/_slsqp_py.pyi index 5a47f9ee..d8d1ce6a 100644 --- a/scipy-stubs/optimize/_slsqp_py.pyi +++ b/scipy-stubs/optimize/_slsqp_py.pyi @@ -3,9 +3,12 @@ from typing import Concatenate, Final, Literal, TypeAlias, TypeVar, overload import numpy as np import optype.numpy as onp +from scipy._typing import Falsy, Truthy __all__ = ["approx_jacobian", "fmin_slsqp"] +### + _FT = TypeVar("_FT", bound=onp.ToFloat | onp.ToFloatND) _Fun: TypeAlias = Callable[Concatenate[onp.Array1D[np.float64], ...], _FT] _Fun0D: TypeAlias = _Fun[onp.ToFloat] @@ -54,7 +57,7 @@ def fmin_slsqp( acc: onp.ToFloat = 1e-06, iprint: onp.ToJustInt = 1, disp: onp.ToInt | None = None, - full_output: Literal[False, 0] = 0, + full_output: Falsy = 0, epsilon: onp.ToFloat = ..., # = np.sqrt(np.finfo(float).eps) callback: Callable[[onp.Array1D[np.float64]], _Ignored] | None = None, ) -> onp.Array1D[np.float64]: ... @@ -76,7 +79,7 @@ def fmin_slsqp( iprint: onp.ToJustInt = 1, disp: onp.ToInt | None = None, *, - full_output: Literal[True, 1], + full_output: Truthy, epsilon: onp.ToFloat = ..., # = np.sqrt(np.finfo(float).eps) callback: Callable[[onp.Array1D[np.float64]], _Ignored] | None = None, ) -> tuple[onp.Array1D[np.float64], float | np.float64, int, _ExitMode, _ExitDesc]: ... diff --git a/scipy-stubs/optimize/_trustregion_constr/qp_subproblem.pyi b/scipy-stubs/optimize/_trustregion_constr/qp_subproblem.pyi index ded46cd7..1056f367 100644 --- a/scipy-stubs/optimize/_trustregion_constr/qp_subproblem.pyi +++ b/scipy-stubs/optimize/_trustregion_constr/qp_subproblem.pyi @@ -4,6 +4,7 @@ from typing_extensions import NotRequired, TypeVar import numpy as np import optype.numpy as onp +from scipy._typing import Falsy, Truthy from scipy.sparse import sparray, spmatrix from scipy.sparse.linalg import LinearOperator @@ -71,7 +72,7 @@ def box_sphere_intersections( ub: _VectorLikeFloat_co, trust_radius: _ScalarLikeFloat_co, entire_line: _ScalarB1 = False, - extra_info: Literal[False, 0] | None = False, + extra_info: Falsy | None = False, ) -> tuple[_ScalarF8, _ScalarF8, _ScalarB1]: ... @overload def box_sphere_intersections( @@ -81,7 +82,7 @@ def box_sphere_intersections( ub: _VectorLikeFloat_co, trust_radius: _ScalarLikeFloat_co, entire_line: _ScalarB1, - extra_info: Literal[True, 1], + extra_info: Truthy, ) -> tuple[_ScalarF8, _ScalarF8, _ScalarB1, _SphereInfoDict, _SphereInfoDict]: ... @overload def box_sphere_intersections( @@ -92,7 +93,7 @@ def box_sphere_intersections( trust_radius: _ScalarLikeFloat_co, entire_line: _ScalarB1 = False, *, - extra_info: Literal[True, 1], + extra_info: Truthy, ) -> tuple[_ScalarF8, _ScalarF8, _ScalarB1, _SphereInfoDict, _SphereInfoDict]: ... def inside_box_boundaries( x: onp.Array[_ShapeT, _ScalarFloat_co], diff --git a/scipy-stubs/signal/_spectral_py.pyi b/scipy-stubs/signal/_spectral_py.pyi index 7f1b405d..6622e41f 100644 --- a/scipy-stubs/signal/_spectral_py.pyi +++ b/scipy-stubs/signal/_spectral_py.pyi @@ -4,6 +4,7 @@ from typing import Literal, TypeAlias, overload import numpy as np import optype as op import optype.numpy as onp +from scipy._typing import Falsy, Truthy from .windows._windows import _ToWindow __all__ = ["check_COLA", "check_NOLA", "coherence", "csd", "istft", "lombscargle", "periodogram", "spectrogram", "stft", "welch"] @@ -149,7 +150,7 @@ def istft( nperseg: onp.ToInt | None = None, noverlap: onp.ToInt | None = None, nfft: onp.ToInt | None = None, - input_onesided: Literal[True, 1] = True, + input_onesided: Truthy = True, boundary: op.CanBool = True, time_axis: op.CanIndex = -1, freq_axis: op.CanIndex = -2, @@ -163,7 +164,7 @@ def istft( nperseg: onp.ToInt | None, noverlap: onp.ToInt | None, nfft: onp.ToInt | None, - input_onesided: Literal[False, 0], + input_onesided: Falsy, boundary: op.CanBool = True, time_axis: op.CanIndex = -1, freq_axis: op.CanIndex = -2, @@ -178,7 +179,7 @@ def istft( noverlap: onp.ToInt | None = None, nfft: onp.ToInt | None = None, *, - input_onesided: Literal[False, 0], + input_onesided: Falsy, boundary: op.CanBool = True, time_axis: op.CanIndex = -1, freq_axis: op.CanIndex = -2, diff --git a/scipy-stubs/signal/windows/_windows.pyi b/scipy-stubs/signal/windows/_windows.pyi index 67c3d492..e059f54f 100644 --- a/scipy-stubs/signal/windows/_windows.pyi +++ b/scipy-stubs/signal/windows/_windows.pyi @@ -4,6 +4,7 @@ from typing_extensions import TypeAliasType import numpy as np import optype as op import optype.numpy as onp +from scipy._typing import Falsy, Truthy __all__ = [ "barthann", @@ -34,6 +35,8 @@ __all__ = [ "tukey", ] +### + _Float1D: TypeAlias = onp.Array1D[np.float64] _Float2D: TypeAlias = onp.Array2D[np.float64] @@ -129,7 +132,7 @@ def dpss( Kmax: op.CanIndex, sym: op.CanBool = True, norm: _Norm | None = None, - return_ratios: Literal[False] = False, + return_ratios: Falsy = False, ) -> _Float2D: ... @overload # `return_ratios` is `False`. def dpss( @@ -138,7 +141,7 @@ def dpss( Kmax: None = None, sym: op.CanBool = True, norm: _Norm | None = None, - return_ratios: Literal[False] = False, + return_ratios: Falsy = False, ) -> _Float1D: ... @overload # `return_ratios` is `True`, `return_ratios` as a positional argument def dpss( @@ -147,7 +150,7 @@ def dpss( Kmax: op.CanIndex, sym: op.CanBool, norm: _Norm | None, - return_ratios: Literal[True], + return_ratios: Truthy, ) -> tuple[_Float2D, _Float1D]: ... @overload # `return_ratios` as a keyword argument def dpss( @@ -157,7 +160,7 @@ def dpss( sym: op.CanBool = True, norm: _Norm | None = None, *, - return_ratios: Literal[True], + return_ratios: Truthy, ) -> tuple[_Float2D, _Float1D]: ... @overload # `return_ratios` as a positional argument def dpss( @@ -166,7 +169,7 @@ def dpss( Kmax: None, sym: op.CanBool, norm: _Norm | None, - return_ratios: Literal[True], + return_ratios: Truthy, ) -> tuple[_Float1D, np.float64]: ... @overload # `return_ratios` as a keyword argument def dpss( @@ -176,5 +179,5 @@ def dpss( sym: op.CanBool = True, norm: _Norm | None = None, *, - return_ratios: Literal[True], + return_ratios: Truthy, ) -> tuple[_Float1D, np.float64]: ... diff --git a/scipy-stubs/sparse/_base.pyi b/scipy-stubs/sparse/_base.pyi index 1e0d04cb..0a6cac74 100644 --- a/scipy-stubs/sparse/_base.pyi +++ b/scipy-stubs/sparse/_base.pyi @@ -11,7 +11,7 @@ import numpy.typing as npt import optype as op import optype.numpy as onp import optype.typing as opt -from scipy._typing import Casting, OrderCF +from scipy._typing import Casting, Falsy, OrderCF from ._bsr import bsr_array, bsr_matrix from ._coo import coo_array, coo_matrix from ._csc import csc_array, csc_matrix @@ -263,7 +263,7 @@ class _spbase(Generic[_SCT_co, _ShapeT_co]): # NOTE: only `lil_{array,matrix}` supports non-zero scalar addition (but not subtraction), but upcasts bool + 0 to int_ @overload # `0` or sparse of same dtype - def __add__(self, other: Literal[False, 0] | _spbase[_SCT_co], /) -> Self: ... + def __add__(self, other: Falsy | _spbase[_SCT_co], /) -> Self: ... @overload # sparse[-Int], sparse[+Int8] def __add__(self: _SpFromIntT, other: _spbase[_ToInt8], /) -> _SpFromIntT: ... @overload # sparse[-Float], sparse[+Float32] diff --git a/scipy-stubs/sparse/csgraph/_laplacian.pyi b/scipy-stubs/sparse/csgraph/_laplacian.pyi index 489a239f..c50b8c34 100644 --- a/scipy-stubs/sparse/csgraph/_laplacian.pyi +++ b/scipy-stubs/sparse/csgraph/_laplacian.pyi @@ -3,6 +3,7 @@ from typing import Any, Literal, TypeAlias, overload import numpy as np import numpy.typing as npt import optype.numpy as onp +from scipy._typing import Falsy, Truthy from scipy.sparse._base import _spbase from scipy.sparse.linalg import LinearOperator @@ -17,7 +18,7 @@ _Form: TypeAlias = Literal["array", "function", "lo"] def laplacian( csgraph: _ToCSGraph, normed: bool = False, - return_diag: Literal[False] = False, + return_diag: Falsy = False, use_out_degree: bool = False, *, copy: bool = True, @@ -29,7 +30,7 @@ def laplacian( def laplacian( csgraph: _ToCSGraph, normed: bool, - return_diag: Literal[True], + return_diag: Truthy, use_out_degree: bool = False, *, copy: bool = True, @@ -42,7 +43,7 @@ def laplacian( csgraph: _ToCSGraph, normed: bool = False, *, - return_diag: Literal[True], + return_diag: Truthy, use_out_degree: bool = False, copy: bool = True, form: _Form = "array", diff --git a/scipy-stubs/spatial/distance.pyi b/scipy-stubs/spatial/distance.pyi index 2abc22c6..46b95425 100644 --- a/scipy-stubs/spatial/distance.pyi +++ b/scipy-stubs/spatial/distance.pyi @@ -5,7 +5,7 @@ from typing_extensions import TypeVar, deprecated import numpy as np import optype.numpy as onp -from scipy._typing import ToRNG +from scipy._typing import Falsy, ToRNG, Truthy __all__ = [ "braycurtis", @@ -262,7 +262,7 @@ def jensenshannon( base: onp.ToFloat | None = None, *, axis: int = 0, - keepdims: Literal[False] = False, + keepdims: Falsy = False, ) -> np.float32 | np.float64: ... @overload def jensenshannon( @@ -271,7 +271,7 @@ def jensenshannon( base: onp.ToFloat | None = None, *, axis: int = 0, - keepdims: Literal[True], + keepdims: Truthy, ) -> onp.Array1D[np.float32 | np.float64]: ... @overload def jensenshannon( diff --git a/scipy-stubs/special/_orthogonal.pyi b/scipy-stubs/special/_orthogonal.pyi index 47104811..32b89886 100644 --- a/scipy-stubs/special/_orthogonal.pyi +++ b/scipy-stubs/special/_orthogonal.pyi @@ -1,8 +1,9 @@ from collections.abc import Callable -from typing import Any, Literal, TypeAlias, overload +from typing import Any, TypeAlias, overload import numpy as np import optype.numpy as onp +from scipy._typing import Falsy, Truthy _PointsWeights: TypeAlias = tuple[onp.ArrayND[np.float64], onp.ArrayND[np.float64]] _PointsWeightsMu: TypeAlias = tuple[onp.ArrayND[np.float64], onp.ArrayND[np.float64], np.float64] @@ -85,65 +86,67 @@ class orthopoly1d(np.poly1d): def __call__(self, /, v: onp.ToComplexND) -> onp.ArrayND[np.inexact[Any]]: ... # pyright: ignore[reportIncompatibleMethodOverride] @overload -def roots_jacobi(n: onp.ToInt, alpha: onp.ToFloat, beta: onp.ToFloat, mu: Literal[False] = ...) -> _PointsWeights: ... +def roots_jacobi(n: onp.ToInt, alpha: onp.ToFloat, beta: onp.ToFloat, mu: Falsy = False) -> _PointsWeights: ... @overload -def roots_jacobi(n: onp.ToInt, alpha: onp.ToFloat, beta: onp.ToFloat, mu: Literal[True]) -> _PointsWeightsMu: ... +def roots_jacobi(n: onp.ToInt, alpha: onp.ToFloat, beta: onp.ToFloat, mu: Truthy) -> _PointsWeightsMu: ... @overload -def roots_sh_jacobi(n: onp.ToInt, p1: onp.ToFloat, q1: onp.ToFloat, mu: Literal[False] = ...) -> _PointsWeights: ... +def roots_sh_jacobi(n: onp.ToInt, p1: onp.ToFloat, q1: onp.ToFloat, mu: Falsy = False) -> _PointsWeights: ... @overload -def roots_sh_jacobi(n: onp.ToInt, p1: onp.ToFloat, q1: onp.ToFloat, mu: Literal[True]) -> _PointsWeightsMu: ... +def roots_sh_jacobi(n: onp.ToInt, p1: onp.ToFloat, q1: onp.ToFloat, mu: Truthy) -> _PointsWeightsMu: ... @overload -def roots_genlaguerre(n: onp.ToInt, alpha: onp.ToFloat, mu: Literal[False] = ...) -> _PointsWeights: ... +def roots_genlaguerre(n: onp.ToInt, alpha: onp.ToFloat, mu: Falsy = False) -> _PointsWeights: ... @overload -def roots_genlaguerre(n: onp.ToInt, alpha: onp.ToFloat, mu: Literal[True]) -> _PointsWeightsMu: ... +def roots_genlaguerre(n: onp.ToInt, alpha: onp.ToFloat, mu: Truthy) -> _PointsWeightsMu: ... @overload -def roots_laguerre(n: onp.ToInt, mu: Literal[False] = ...) -> _PointsWeights: ... +def roots_laguerre(n: onp.ToInt, mu: Falsy = False) -> _PointsWeights: ... @overload -def roots_laguerre(n: onp.ToInt, mu: Literal[True]) -> _PointsWeightsMu: ... +def roots_laguerre(n: onp.ToInt, mu: Truthy) -> _PointsWeightsMu: ... @overload -def roots_hermite(n: onp.ToInt, mu: Literal[False] = ...) -> _PointsWeights: ... +def roots_hermite(n: onp.ToInt, mu: Falsy = False) -> _PointsWeights: ... @overload -def roots_hermite(n: onp.ToInt, mu: Literal[True]) -> _PointsWeightsMu: ... +def roots_hermite(n: onp.ToInt, mu: Truthy) -> _PointsWeightsMu: ... @overload -def roots_hermitenorm(n: onp.ToInt, mu: Literal[False] = ...) -> _PointsWeights: ... +def roots_hermitenorm(n: onp.ToInt, mu: Falsy = False) -> _PointsWeights: ... @overload -def roots_hermitenorm(n: onp.ToInt, mu: Literal[True]) -> _PointsWeightsMu: ... +def roots_hermitenorm(n: onp.ToInt, mu: Truthy) -> _PointsWeightsMu: ... @overload -def roots_gegenbauer(n: onp.ToInt, alpha: onp.ToFloat, mu: Literal[False] = ...) -> _PointsWeights: ... +def roots_gegenbauer(n: onp.ToInt, alpha: onp.ToFloat, mu: Falsy = False) -> _PointsWeights: ... @overload -def roots_gegenbauer(n: onp.ToInt, alpha: onp.ToFloat, mu: Literal[True]) -> _PointsWeightsMu: ... +def roots_gegenbauer(n: onp.ToInt, alpha: onp.ToFloat, mu: Truthy) -> _PointsWeightsMu: ... @overload -def roots_chebyt(n: onp.ToInt, mu: Literal[False] = ...) -> _PointsWeights: ... +def roots_chebyt(n: onp.ToInt, mu: Falsy = False) -> _PointsWeights: ... @overload -def roots_chebyt(n: onp.ToInt, mu: Literal[True]) -> _PointsWeightsMu: ... +def roots_chebyt(n: onp.ToInt, mu: Truthy) -> _PointsWeightsMu: ... @overload -def roots_chebyu(n: onp.ToInt, mu: Literal[False] = ...) -> _PointsWeights: ... +def roots_chebyu(n: onp.ToInt, mu: Falsy = False) -> _PointsWeights: ... @overload -def roots_chebyu(n: onp.ToInt, mu: Literal[True]) -> _PointsWeightsMu: ... +def roots_chebyu(n: onp.ToInt, mu: Truthy) -> _PointsWeightsMu: ... @overload -def roots_chebyc(n: onp.ToInt, mu: Literal[False] = ...) -> _PointsWeights: ... +def roots_chebyc(n: onp.ToInt, mu: Falsy = False) -> _PointsWeights: ... @overload -def roots_chebyc(n: onp.ToInt, mu: Literal[True]) -> _PointsWeightsMu: ... +def roots_chebyc(n: onp.ToInt, mu: Truthy) -> _PointsWeightsMu: ... @overload -def roots_chebys(n: onp.ToInt, mu: Literal[False] = ...) -> _PointsWeights: ... +def roots_chebys(n: onp.ToInt, mu: Falsy = False) -> _PointsWeights: ... @overload -def roots_chebys(n: onp.ToInt, mu: Literal[True]) -> _PointsWeightsMu: ... +def roots_chebys(n: onp.ToInt, mu: Truthy) -> _PointsWeightsMu: ... @overload -def roots_sh_chebyt(n: onp.ToInt, mu: Literal[False] = ...) -> _PointsWeights: ... +def roots_sh_chebyt(n: onp.ToInt, mu: Falsy = False) -> _PointsWeights: ... @overload -def roots_sh_chebyt(n: onp.ToInt, mu: Literal[True]) -> _PointsWeightsMu: ... +def roots_sh_chebyt(n: onp.ToInt, mu: Truthy) -> _PointsWeightsMu: ... @overload -def roots_sh_chebyu(n: onp.ToInt, mu: Literal[False] = ...) -> _PointsWeights: ... +def roots_sh_chebyu(n: onp.ToInt, mu: Falsy = False) -> _PointsWeights: ... @overload -def roots_sh_chebyu(n: onp.ToInt, mu: Literal[True]) -> _PointsWeightsMu: ... +def roots_sh_chebyu(n: onp.ToInt, mu: Truthy) -> _PointsWeightsMu: ... @overload -def roots_legendre(n: onp.ToInt, mu: Literal[False] = ...) -> _PointsWeights: ... +def roots_legendre(n: onp.ToInt, mu: Falsy = False) -> _PointsWeights: ... @overload -def roots_legendre(n: onp.ToInt, mu: Literal[True]) -> _PointsWeightsMu: ... +def roots_legendre(n: onp.ToInt, mu: Truthy) -> _PointsWeightsMu: ... @overload -def roots_sh_legendre(n: onp.ToInt, mu: Literal[False] = ...) -> _PointsWeights: ... +def roots_sh_legendre(n: onp.ToInt, mu: Falsy = False) -> _PointsWeights: ... @overload -def roots_sh_legendre(n: onp.ToInt, mu: Literal[True]) -> _PointsWeightsMu: ... +def roots_sh_legendre(n: onp.ToInt, mu: Truthy) -> _PointsWeightsMu: ... + +# def legendre(n: onp.ToInt, monic: bool = ...) -> orthopoly1d: ... def chebyt(n: onp.ToInt, monic: bool = ...) -> orthopoly1d: ... def chebyu(n: onp.ToInt, monic: bool = ...) -> orthopoly1d: ... diff --git a/scipy-stubs/stats/_morestats.pyi b/scipy-stubs/stats/_morestats.pyi index 7a48072e..ace8b58c 100644 --- a/scipy-stubs/stats/_morestats.pyi +++ b/scipy-stubs/stats/_morestats.pyi @@ -322,7 +322,7 @@ def probplot( x: onp.ToFloat | onp.ToFloatND, sparams: tuple[()] = (), dist: _RVC0 | _CanPPF = "norm", - fit: Literal[True] = True, + fit: Truthy = True, plot: _CanPlotText | ModuleType | None = None, rvalue: AnyBool = False, ) -> tuple[_Tuple2[onp.ArrayND[np.float64]], _Tuple3[np.float64]]: ... @@ -332,7 +332,7 @@ def probplot( sparams: tuple[()] = (), dist: _RVC0 | _CanPPF = "norm", *, - fit: Literal[False], + fit: Falsy, plot: _CanPlotText | ModuleType | None = None, rvalue: AnyBool = False, ) -> _Tuple2[onp.ArrayND[np.float64]]: ... @@ -341,7 +341,7 @@ def probplot( x: onp.ToFloat | onp.ToFloatND, sparams: tuple[onp.ToFloat, ...], dist: str | _CanPPF = "norm", - fit: Literal[True] = True, + fit: Truthy = True, plot: _CanPlotText | ModuleType | None = None, rvalue: AnyBool = False, ) -> tuple[_Tuple2[onp.ArrayND[np.float64]], _Tuple3[np.float64]]: ... @@ -351,7 +351,7 @@ def probplot( sparams: tuple[onp.ToFloat], dist: str | _CanPPF = "norm", *, - fit: Literal[False], + fit: Falsy, plot: _CanPlotText | ModuleType | None = None, rvalue: AnyBool = False, ) -> _Tuple2[onp.ArrayND[np.float64]]: ... diff --git a/scipy-stubs/stats/_variation.pyi b/scipy-stubs/stats/_variation.pyi index 2b1933b7..d4cce1fb 100644 --- a/scipy-stubs/stats/_variation.pyi +++ b/scipy-stubs/stats/_variation.pyi @@ -1,12 +1,12 @@ from collections.abc import Sequence -from typing import Any, Literal, overload +from typing import Any, overload from typing_extensions import TypeVar import numpy as np import optype as op import optype.numpy as onp from numpy._typing import _ArrayLike, _NestedSequence -from scipy._typing import AnyBool, NanPolicy +from scipy._typing import AnyBool, Falsy, NanPolicy, Truthy _SCT_fc = TypeVar("_SCT_fc", bound=np.inexact[Any]) @@ -23,7 +23,7 @@ def variation( nan_policy: NanPolicy = "propagate", ddof: onp.ToInt = 0, *, - keepdims: Literal[0, False] = False, + keepdims: Falsy = False, ) -> np.float64: ... @overload def variation( @@ -32,7 +32,7 @@ def variation( nan_policy: NanPolicy = "propagate", ddof: onp.ToInt = 0, *, - keepdims: Literal[0, False] = False, + keepdims: Falsy = False, ) -> np.float64: ... @overload def variation( @@ -41,7 +41,7 @@ def variation( nan_policy: NanPolicy = "propagate", ddof: onp.ToInt = 0, *, - keepdims: Literal[1, True], + keepdims: Truthy, ) -> onp.ArrayND[np.float64]: ... @overload def variation( @@ -61,7 +61,7 @@ def variation( nan_policy: NanPolicy = "propagate", ddof: onp.ToInt = 0, *, - keepdims: Literal[0, False] = False, + keepdims: Falsy = False, ) -> _SCT_fc: ... @overload def variation( @@ -70,7 +70,7 @@ def variation( nan_policy: NanPolicy = "propagate", ddof: onp.ToInt = 0, *, - keepdims: Literal[1, True], + keepdims: Truthy, ) -> onp.ArrayND[_SCT_fc]: ... @overload def variation( @@ -91,7 +91,7 @@ def variation( nan_policy: NanPolicy = "propagate", ddof: onp.ToInt = 0, *, - keepdims: Literal[0, False] = False, + keepdims: Falsy = False, ) -> np.complex128 | np.float64: ... @overload def variation( @@ -100,7 +100,7 @@ def variation( nan_policy: NanPolicy = "propagate", ddof: onp.ToInt = 0, *, - keepdims: Literal[0, False] = False, + keepdims: Falsy = False, ) -> np.complex128 | np.float64: ... @overload def variation( @@ -109,7 +109,7 @@ def variation( nan_policy: NanPolicy = "propagate", ddof: onp.ToInt = 0, *, - keepdims: Literal[1, True], + keepdims: Truthy, ) -> onp.ArrayND[np.complex128 | np.float64]: ... @overload def variation(