Debian Codegraph @

jedi/third_party/typeshed/stdlib/math.pyi

raw symbols SCIP
1 import sys
2 from _typeshed import SupportsMul, SupportsRMul
3 from collections.abc import Iterable
4 from typing import Any, Final, Literal, Protocol, SupportsFloat, SupportsIndex, TypeVar, overload, type_check_only
5 from typing_extensions import TypeAlias
6
7 _T = TypeVar("_T")
8 _T_co = TypeVar("_T_co", covariant=True)
9
10 _SupportsFloatOrIndex: TypeAlias = SupportsFloat | SupportsIndex
11
12 e: Final[float]
13 pi: Final[float]
14 inf: Final[float]
15 nan: Final[float]
16 tau: Final[float]
17
18 def acos(x: _SupportsFloatOrIndex, /) -> float: ...
19 def acosh(x: _SupportsFloatOrIndex, /) -> float: ...
20 def asin(x: _SupportsFloatOrIndex, /) -> float: ...
21 def asinh(x: _SupportsFloatOrIndex, /) -> float: ...
22 def atan(x: _SupportsFloatOrIndex, /) -> float: ...
23 def atan2(y: _SupportsFloatOrIndex, x: _SupportsFloatOrIndex, /) -> float: ...
24 def atanh(x: _SupportsFloatOrIndex, /) -> float: ...
25
26 if sys.version_info >= (3, 11):
27 def cbrt(x: _SupportsFloatOrIndex, /) -> float: ...
28
29 @type_check_only
30 class _SupportsCeil(Protocol[_T_co]):
31 def __ceil__(self) -> _T_co: ...
32
33 @overload
34 def ceil(x: _SupportsCeil[_T], /) -> _T: ...
35 @overload
36 def ceil(x: _SupportsFloatOrIndex, /) -> int: ...
37 def comb(n: SupportsIndex, k: SupportsIndex, /) -> int: ...
38 def copysign(x: _SupportsFloatOrIndex, y: _SupportsFloatOrIndex, /) -> float: ...
39 def cos(x: _SupportsFloatOrIndex, /) -> float: ...
40 def cosh(x: _SupportsFloatOrIndex, /) -> float: ...
41 def degrees(x: _SupportsFloatOrIndex, /) -> float: ...
42 def dist(p: Iterable[_SupportsFloatOrIndex], q: Iterable[_SupportsFloatOrIndex], /) -> float: ...
43 def erf(x: _SupportsFloatOrIndex, /) -> float: ...
44 def erfc(x: _SupportsFloatOrIndex, /) -> float: ...
45 def exp(x: _SupportsFloatOrIndex, /) -> float: ...
46
47 if sys.version_info >= (3, 11):
48 def exp2(x: _SupportsFloatOrIndex, /) -> float: ...
49
50 def expm1(x: _SupportsFloatOrIndex, /) -> float: ...
51 def fabs(x: _SupportsFloatOrIndex, /) -> float: ...
52 def factorial(x: SupportsIndex, /) -> int: ...
53 @type_check_only
54 class _SupportsFloor(Protocol[_T_co]):
55 def __floor__(self) -> _T_co: ...
56
57 @overload
58 def floor(x: _SupportsFloor[_T], /) -> _T: ...
59 @overload
60 def floor(x: _SupportsFloatOrIndex, /) -> int: ...
61 def fmod(x: _SupportsFloatOrIndex, y: _SupportsFloatOrIndex, /) -> float: ...
62 def frexp(x: _SupportsFloatOrIndex, /) -> tuple[float, int]: ...
63 def fsum(seq: Iterable[_SupportsFloatOrIndex], /) -> float: ...
64 def gamma(x: _SupportsFloatOrIndex, /) -> float: ...
65 def gcd(*integers: SupportsIndex) -> int: ...
66 def hypot(*coordinates: _SupportsFloatOrIndex) -> float: ...
67 def isclose(
68 a: _SupportsFloatOrIndex,
69 b: _SupportsFloatOrIndex,
70 *,
71 rel_tol: _SupportsFloatOrIndex = 1e-09,
72 abs_tol: _SupportsFloatOrIndex = 0.0,
73 ) -> bool: ...
74 def isinf(x: _SupportsFloatOrIndex, /) -> bool: ...
75 def isfinite(x: _SupportsFloatOrIndex, /) -> bool: ...
76 def isnan(x: _SupportsFloatOrIndex, /) -> bool: ...
77 def isqrt(n: SupportsIndex, /) -> int: ...
78 def lcm(*integers: SupportsIndex) -> int: ...
79 def ldexp(x: _SupportsFloatOrIndex, i: int, /) -> float: ...
80 def lgamma(x: _SupportsFloatOrIndex, /) -> float: ...
81 def log(x: _SupportsFloatOrIndex, base: _SupportsFloatOrIndex = ...) -> float: ...
82 def log10(x: _SupportsFloatOrIndex, /) -> float: ...
83 def log1p(x: _SupportsFloatOrIndex, /) -> float: ...
84 def log2(x: _SupportsFloatOrIndex, /) -> float: ...
85 def modf(x: _SupportsFloatOrIndex, /) -> tuple[float, float]: ...
86
87 if sys.version_info >= (3, 12):
88 def nextafter(x: _SupportsFloatOrIndex, y: _SupportsFloatOrIndex, /, *, steps: SupportsIndex | None = None) -> float: ...
89
90 else:
91 def nextafter(x: _SupportsFloatOrIndex, y: _SupportsFloatOrIndex, /) -> float: ...
92
93 def perm(n: SupportsIndex, k: SupportsIndex | None = None, /) -> int: ...
94 def pow(x: _SupportsFloatOrIndex, y: _SupportsFloatOrIndex, /) -> float: ...
95
96 _PositiveInteger: TypeAlias = Literal[1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25]
97 _NegativeInteger: TypeAlias = Literal[-1, -2, -3, -4, -5, -6, -7, -8, -9, -10, -11, -12, -13, -14, -15, -16, -17, -18, -19, -20]
98 _LiteralInteger = _PositiveInteger | _NegativeInteger | Literal[0] # noqa: Y026 # TODO: Use TypeAlias once mypy bugs are fixed
99
100 _MultiplicableT1 = TypeVar("_MultiplicableT1", bound=SupportsMul[Any, Any])
101 _MultiplicableT2 = TypeVar("_MultiplicableT2", bound=SupportsMul[Any, Any])
102
103 @type_check_only
104 class _SupportsProdWithNoDefaultGiven(SupportsMul[Any, Any], SupportsRMul[int, Any], Protocol): ...
105
106 _SupportsProdNoDefaultT = TypeVar("_SupportsProdNoDefaultT", bound=_SupportsProdWithNoDefaultGiven)
107
108 # This stub is based on the type stub for `builtins.sum`.
109 # Like `builtins.sum`, it cannot be precisely represented in a type stub
110 # without introducing many false positives.
111 # For more details on its limitations and false positives, see #13572.
112 # Instead, just like `builtins.sum`, we explicitly handle several useful cases.
113 @overload
114 def prod(iterable: Iterable[bool | _LiteralInteger], /, *, start: int = 1) -> int: ... # type: ignore[overload-overlap]
115 @overload
116 def prod(iterable: Iterable[_SupportsProdNoDefaultT], /) -> _SupportsProdNoDefaultT | Literal[1]: ...
117 @overload
118 def prod(iterable: Iterable[_MultiplicableT1], /, *, start: _MultiplicableT2) -> _MultiplicableT1 | _MultiplicableT2: ...
119 def radians(x: _SupportsFloatOrIndex, /) -> float: ...
120 def remainder(x: _SupportsFloatOrIndex, y: _SupportsFloatOrIndex, /) -> float: ...
121 def sin(x: _SupportsFloatOrIndex, /) -> float: ...
122 def sinh(x: _SupportsFloatOrIndex, /) -> float: ...
123
124 if sys.version_info >= (3, 12):
125 def sumprod(p: Iterable[float], q: Iterable[float], /) -> float: ...
126
127 def sqrt(x: _SupportsFloatOrIndex, /) -> float: ...
128 def tan(x: _SupportsFloatOrIndex, /) -> float: ...
129 def tanh(x: _SupportsFloatOrIndex, /) -> float: ...
130
131 # Is different from `_typeshed.SupportsTrunc`, which is not generic
132 @type_check_only
133 class _SupportsTrunc(Protocol[_T_co]):
134 def __trunc__(self) -> _T_co: ...
135
136 def trunc(x: _SupportsTrunc[_T], /) -> _T: ...
137 def ulp(x: _SupportsFloatOrIndex, /) -> float: ...
138
139 if sys.version_info >= (3, 13):
140 def fma(x: _SupportsFloatOrIndex, y: _SupportsFloatOrIndex, z: _SupportsFloatOrIndex, /) -> float: ...