basedpyright 1.13.1 → 1.13.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/pyright-langserver.js +1 -1
- package/dist/pyright-langserver.js.map +1 -1
- package/dist/pyright.js +1 -1
- package/dist/pyright.js.map +1 -1
- package/dist/typeshed-fallback/commit.txt +1 -1
- package/dist/typeshed-fallback/stdlib/VERSIONS +3 -1
- package/dist/typeshed-fallback/stdlib/_ast.pyi +1 -1
- package/dist/typeshed-fallback/stdlib/_bisect.pyi +221 -221
- package/dist/typeshed-fallback/stdlib/_csv.pyi +213 -213
- package/dist/typeshed-fallback/stdlib/_curses.pyi +1 -2
- package/dist/typeshed-fallback/stdlib/_heapq.pyi +67 -67
- package/dist/typeshed-fallback/stdlib/_interpchannels.pyi +84 -0
- package/dist/typeshed-fallback/stdlib/_json.pyi +92 -92
- package/dist/typeshed-fallback/stdlib/_lsprof.pyi +92 -92
- package/dist/typeshed-fallback/stdlib/_random.pyi +30 -30
- package/dist/typeshed-fallback/stdlib/_tkinter.pyi +7 -0
- package/dist/typeshed-fallback/stdlib/_weakref.pyi +3 -2
- package/dist/typeshed-fallback/stdlib/argparse.pyi +6 -2
- package/dist/typeshed-fallback/stdlib/array.pyi +281 -281
- package/dist/typeshed-fallback/stdlib/asyncio/events.pyi +56 -37
- package/dist/typeshed-fallback/stdlib/asyncio/tasks.pyi +4 -1
- package/dist/typeshed-fallback/stdlib/asyncio/unix_events.pyi +156 -134
- package/dist/typeshed-fallback/stdlib/asyncio/windows_events.pyi +3 -2
- package/dist/typeshed-fallback/stdlib/audioop.pyi +95 -95
- package/dist/typeshed-fallback/stdlib/binascii.pyi +123 -123
- package/dist/typeshed-fallback/stdlib/cmath.pyi +112 -112
- package/dist/typeshed-fallback/stdlib/dataclasses.pyi +1 -1
- package/dist/typeshed-fallback/stdlib/logging/__init__.pyi +2 -5
- package/dist/typeshed-fallback/stdlib/math.pyi +424 -424
- package/dist/typeshed-fallback/stdlib/mmap.pyi +160 -154
- package/dist/typeshed-fallback/stdlib/multiprocessing/context.pyi +10 -6
- package/dist/typeshed-fallback/stdlib/multiprocessing/sharedctypes.pyi +33 -12
- package/dist/typeshed-fallback/stdlib/os/__init__.pyi +10 -10
- package/dist/typeshed-fallback/stdlib/posixpath.pyi +3 -13
- package/dist/typeshed-fallback/stdlib/spwd.pyi +9 -0
- package/dist/typeshed-fallback/stdlib/subprocess.pyi +8 -0
- package/dist/typeshed-fallback/stdlib/tarfile.pyi +23 -1
- package/dist/typeshed-fallback/stdlib/telnetlib.pyi +1 -0
- package/dist/typeshed-fallback/stdlib/typing.pyi +21 -2
- package/dist/typeshed-fallback/stdlib/weakref.pyi +4 -1
- package/dist/typeshed-fallback/stdlib/xml/sax/handler.pyi +1 -1
- package/dist/typeshed-fallback/stdlib/zlib.pyi +157 -157
- package/dist/typeshed-fallback/stubs/Flask-SocketIO/flask_socketio/__init__.pyi +4 -4
- package/dist/typeshed-fallback/stubs/aiofiles/METADATA.toml +1 -1
- package/dist/typeshed-fallback/stubs/aiofiles/aiofiles/base.pyi +6 -20
- package/dist/typeshed-fallback/stubs/aiofiles/aiofiles/os.pyi +2 -0
- package/dist/typeshed-fallback/stubs/aiofiles/aiofiles/ospath.pyi +5 -3
- package/dist/typeshed-fallback/stubs/aiofiles/aiofiles/tempfile/__init__.pyi +143 -79
- package/dist/typeshed-fallback/stubs/aiofiles/aiofiles/threadpool/__init__.pyi +5 -5
- package/dist/typeshed-fallback/stubs/assertpy/assertpy/extracting.pyi +7 -1
- package/dist/typeshed-fallback/stubs/docker/docker/_types.pyi +8 -0
- package/dist/typeshed-fallback/stubs/docker/docker/api/container.pyi +2 -2
- package/dist/typeshed-fallback/stubs/docker/docker/api/image.pyi +3 -2
- package/dist/typeshed-fallback/stubs/docker/docker/api/network.pyi +32 -15
- package/dist/typeshed-fallback/stubs/docker/docker/models/containers.pyi +36 -7
- package/dist/typeshed-fallback/stubs/docker/docker/models/images.pyi +67 -5
- package/dist/typeshed-fallback/stubs/docker/docker/models/networks.pyi +20 -3
- package/dist/typeshed-fallback/stubs/docker/docker/types/containers.pyi +78 -70
- package/dist/typeshed-fallback/stubs/docker/docker/utils/json_stream.pyi +4 -7
- package/dist/typeshed-fallback/stubs/flake8/METADATA.toml +1 -1
- package/dist/typeshed-fallback/stubs/fpdf2/fpdf/fpdf.pyi +16 -5
- package/dist/typeshed-fallback/stubs/fpdf2/fpdf/image_datastructures.pyi +2 -1
- package/dist/typeshed-fallback/stubs/fpdf2/fpdf/table.pyi +4 -2
- package/dist/typeshed-fallback/stubs/fpdf2/fpdf/text_region.pyi +7 -7
- package/dist/typeshed-fallback/stubs/hdbcli/METADATA.toml +1 -1
- package/dist/typeshed-fallback/stubs/hdbcli/hdbcli/dbapi.pyi +1 -0
- package/dist/typeshed-fallback/stubs/hvac/METADATA.toml +1 -1
- package/dist/typeshed-fallback/stubs/hvac/hvac/api/system_backend/raft.pyi +9 -0
- package/dist/typeshed-fallback/stubs/hvac/hvac/api/system_backend/wrapping.pyi +1 -0
- package/dist/typeshed-fallback/stubs/influxdb-client/METADATA.toml +1 -1
- package/dist/typeshed-fallback/stubs/influxdb-client/influxdb_client/client/_pages.pyi +37 -0
- package/dist/typeshed-fallback/stubs/influxdb-client/influxdb_client/client/bucket_api.pyi +5 -1
- package/dist/typeshed-fallback/stubs/influxdb-client/influxdb_client/client/tasks_api.pyi +4 -3
- package/dist/typeshed-fallback/stubs/influxdb-client/influxdb_client/domain/bucket.pyi +6 -6
- package/dist/typeshed-fallback/stubs/influxdb-client/influxdb_client/domain/task.pyi +6 -6
- package/dist/typeshed-fallback/stubs/networkx/METADATA.toml +3 -1
- package/dist/typeshed-fallback/stubs/olefile/olefile/olefile.pyi +41 -31
- package/dist/typeshed-fallback/stubs/openpyxl/METADATA.toml +1 -1
- package/dist/typeshed-fallback/stubs/openpyxl/openpyxl/cell/rich_text.pyi +3 -0
- package/dist/typeshed-fallback/stubs/openpyxl/openpyxl/chart/trendline.pyi +1 -2
- package/dist/typeshed-fallback/stubs/openpyxl/openpyxl/descriptors/base.pyi +1 -1
- package/dist/typeshed-fallback/stubs/openpyxl/openpyxl/descriptors/container.pyi +18 -0
- package/dist/typeshed-fallback/stubs/openpyxl/openpyxl/descriptors/sequence.pyi +20 -12
- package/dist/typeshed-fallback/stubs/openpyxl/openpyxl/packaging/custom.pyi +1 -1
- package/dist/typeshed-fallback/stubs/openpyxl/openpyxl/packaging/extended.pyi +2 -2
- package/dist/typeshed-fallback/stubs/openpyxl/openpyxl/packaging/relationship.pyi +6 -11
- package/dist/typeshed-fallback/stubs/openpyxl/openpyxl/pivot/cache.pyi +66 -135
- package/dist/typeshed-fallback/stubs/openpyxl/openpyxl/pivot/fields.pyi +2 -2
- package/dist/typeshed-fallback/stubs/openpyxl/openpyxl/styles/alignment.pyi +0 -1
- package/dist/typeshed-fallback/stubs/openpyxl/openpyxl/styles/borders.pyi +0 -2
- package/dist/typeshed-fallback/stubs/openpyxl/openpyxl/styles/fills.pyi +3 -3
- package/dist/typeshed-fallback/stubs/openpyxl/openpyxl/styles/named_styles.pyi +5 -10
- package/dist/typeshed-fallback/stubs/openpyxl/openpyxl/utils/cell.pyi +2 -2
- package/dist/typeshed-fallback/stubs/openpyxl/openpyxl/utils/indexed_list.pyi +2 -2
- package/dist/typeshed-fallback/stubs/openpyxl/openpyxl/workbook/defined_name.pyi +2 -2
- package/dist/typeshed-fallback/stubs/openpyxl/openpyxl/worksheet/_read_only.pyi +11 -3
- package/dist/typeshed-fallback/stubs/openpyxl/openpyxl/worksheet/datavalidation.pyi +2 -2
- package/dist/typeshed-fallback/stubs/openpyxl/openpyxl/worksheet/dimensions.pyi +6 -3
- package/dist/typeshed-fallback/stubs/openpyxl/openpyxl/worksheet/filters.pyi +26 -22
- package/dist/typeshed-fallback/stubs/openpyxl/openpyxl/worksheet/hyperlink.pyi +3 -5
- package/dist/typeshed-fallback/stubs/openpyxl/openpyxl/worksheet/views.pyi +5 -2
- package/dist/typeshed-fallback/stubs/openpyxl/openpyxl/worksheet/worksheet.pyi +4 -2
- package/dist/typeshed-fallback/stubs/peewee/METADATA.toml +1 -1
- package/dist/typeshed-fallback/stubs/peewee/peewee.pyi +6 -1
- package/dist/typeshed-fallback/stubs/protobuf/METADATA.toml +2 -2
- package/dist/typeshed-fallback/stubs/protobuf/google/protobuf/descriptor_pb2.pyi +84 -15
- package/dist/typeshed-fallback/stubs/psutil/METADATA.toml +1 -1
- package/dist/typeshed-fallback/stubs/psutil/psutil/__init__.pyi +3 -1
- package/dist/typeshed-fallback/stubs/psutil/psutil/_common.pyi +0 -2
- package/dist/typeshed-fallback/stubs/psutil/psutil/_compat.pyi +0 -1
- package/dist/typeshed-fallback/stubs/psutil/psutil/_psaix.pyi +1 -1
- package/dist/typeshed-fallback/stubs/psutil/psutil/_psbsd.pyi +1 -1
- package/dist/typeshed-fallback/stubs/psutil/psutil/_pslinux.pyi +2 -2
- package/dist/typeshed-fallback/stubs/psutil/psutil/_psosx.pyi +1 -1
- package/dist/typeshed-fallback/stubs/psutil/psutil/_pssunos.pyi +1 -1
- package/dist/typeshed-fallback/stubs/psutil/psutil/_psutil_osx.pyi +1 -1
- package/dist/typeshed-fallback/stubs/psutil/psutil/_pswindows.pyi +1 -1
- package/dist/typeshed-fallback/stubs/pyinstaller/METADATA.toml +1 -1
- package/dist/typeshed-fallback/stubs/pyinstaller/PyInstaller/__main__.pyi +1 -0
- package/dist/typeshed-fallback/stubs/pyinstaller/PyInstaller/building/splash.pyi +0 -2
- package/dist/typeshed-fallback/stubs/pyinstaller/PyInstaller/compat.pyi +2 -3
- package/dist/typeshed-fallback/stubs/reportlab/METADATA.toml +3 -2
- package/dist/typeshed-fallback/stubs/requests/requests/models.pyi +2 -2
- package/dist/typeshed-fallback/stubs/seaborn/METADATA.toml +2 -1
- package/dist/typeshed-fallback/stubs/setuptools/METADATA.toml +1 -1
- package/dist/typeshed-fallback/stubs/setuptools/pkg_resources/__init__.pyi +80 -50
- package/dist/typeshed-fallback/stubs/setuptools/setuptools/__init__.pyi +2 -4
- package/dist/typeshed-fallback/stubs/setuptools/setuptools/build_meta.pyi +6 -3
- package/dist/typeshed-fallback/stubs/setuptools/setuptools/command/bdist_egg.pyi +3 -9
- package/dist/typeshed-fallback/stubs/setuptools/setuptools/command/bdist_wheel.pyi +61 -0
- package/dist/typeshed-fallback/stubs/setuptools/setuptools/command/build_ext.pyi +2 -2
- package/dist/typeshed-fallback/stubs/setuptools/setuptools/command/build_py.pyi +12 -1
- package/dist/typeshed-fallback/stubs/setuptools/setuptools/command/easy_install.pyi +1 -1
- package/dist/typeshed-fallback/stubs/setuptools/setuptools/command/egg_info.pyi +4 -4
- package/dist/typeshed-fallback/stubs/setuptools/setuptools/command/install_lib.pyi +3 -4
- package/dist/typeshed-fallback/stubs/setuptools/setuptools/compat/py311.pyi +1 -1
- package/dist/typeshed-fallback/stubs/setuptools/setuptools/config/expand.pyi +0 -1
- package/dist/typeshed-fallback/stubs/shapely/METADATA.toml +2 -1
- package/dist/typeshed-fallback/stubs/shapely/shapely/_geometry.pyi +3 -3
- package/dist/typeshed-fallback/stubs/shapely/shapely/constructive.pyi +6 -6
- package/dist/typeshed-fallback/stubs/shapely/shapely/geometry/base.pyi +3 -3
- package/dist/typeshed-fallback/stubs/shapely/shapely/io.pyi +2 -2
- package/dist/typeshed-fallback/stubs/shapely/shapely/strtree.pyi +9 -9
- package/dist/typeshed-fallback/stubs/tree-sitter-languages/METADATA.toml +1 -1
- package/package.json +1 -1
- package/dist/typeshed-fallback/stubs/tree-sitter/METADATA.toml +0 -7
- package/dist/typeshed-fallback/stubs/tree-sitter/tree_sitter/__init__.pyi +0 -17
- package/dist/typeshed-fallback/stubs/tree-sitter/tree_sitter/binding.pyi +0 -115
|
@@ -1,424 +1,424 @@
|
|
|
1
|
-
"""
|
|
2
|
-
This module provides access to the mathematical functions
|
|
3
|
-
defined by the C standard.
|
|
4
|
-
"""
|
|
5
|
-
|
|
6
|
-
import sys
|
|
7
|
-
from collections.abc import Iterable
|
|
8
|
-
from typing import Protocol, SupportsFloat, SupportsIndex, TypeVar, overload
|
|
9
|
-
from typing_extensions import TypeAlias
|
|
10
|
-
|
|
11
|
-
_T = TypeVar("_T")
|
|
12
|
-
_T_co = TypeVar("_T_co", covariant=True)
|
|
13
|
-
|
|
14
|
-
_SupportsFloatOrIndex: TypeAlias = SupportsFloat | SupportsIndex
|
|
15
|
-
|
|
16
|
-
e: float
|
|
17
|
-
pi: float
|
|
18
|
-
inf: float
|
|
19
|
-
nan: float
|
|
20
|
-
tau: float
|
|
21
|
-
|
|
22
|
-
def acos(x: _SupportsFloatOrIndex, /) -> float:
|
|
23
|
-
"""Return the arc cosine (measured in radians) of x."""
|
|
24
|
-
...
|
|
25
|
-
def acosh(x: _SupportsFloatOrIndex, /) -> float:
|
|
26
|
-
"""Return the inverse hyperbolic cosine of x."""
|
|
27
|
-
...
|
|
28
|
-
def asin(x: _SupportsFloatOrIndex, /) -> float:
|
|
29
|
-
"""Return the arc sine (measured in radians) of x."""
|
|
30
|
-
...
|
|
31
|
-
def asinh(x: _SupportsFloatOrIndex, /) -> float:
|
|
32
|
-
"""Return the inverse hyperbolic sine of x."""
|
|
33
|
-
...
|
|
34
|
-
def atan(x: _SupportsFloatOrIndex, /) -> float:
|
|
35
|
-
"""Return the arc tangent (measured in radians) of x."""
|
|
36
|
-
...
|
|
37
|
-
def atan2(y: _SupportsFloatOrIndex, x: _SupportsFloatOrIndex, /) -> float:
|
|
38
|
-
"""
|
|
39
|
-
Return the arc tangent (measured in radians) of y/x.
|
|
40
|
-
|
|
41
|
-
Unlike atan(y/x), the signs of both x and y are considered.
|
|
42
|
-
"""
|
|
43
|
-
...
|
|
44
|
-
def atanh(x: _SupportsFloatOrIndex, /) -> float:
|
|
45
|
-
"""Return the inverse hyperbolic tangent of x."""
|
|
46
|
-
...
|
|
47
|
-
|
|
48
|
-
if sys.version_info >= (3, 11):
|
|
49
|
-
def cbrt(x: _SupportsFloatOrIndex, /) -> float:
|
|
50
|
-
"""Return the cube root of x."""
|
|
51
|
-
...
|
|
52
|
-
|
|
53
|
-
class _SupportsCeil(Protocol[_T_co]):
|
|
54
|
-
def __ceil__(self) -> _T_co: ...
|
|
55
|
-
|
|
56
|
-
@overload
|
|
57
|
-
def ceil(x: _SupportsCeil[_T], /) -> _T:
|
|
58
|
-
"""
|
|
59
|
-
Return the ceiling of x as an Integral.
|
|
60
|
-
|
|
61
|
-
This is the smallest integer >= x.
|
|
62
|
-
"""
|
|
63
|
-
...
|
|
64
|
-
@overload
|
|
65
|
-
def ceil(x: _SupportsFloatOrIndex, /) -> int:
|
|
66
|
-
"""
|
|
67
|
-
Return the ceiling of x as an Integral.
|
|
68
|
-
|
|
69
|
-
This is the smallest integer >= x.
|
|
70
|
-
"""
|
|
71
|
-
...
|
|
72
|
-
def comb(n: SupportsIndex, k: SupportsIndex, /) -> int:
|
|
73
|
-
"""
|
|
74
|
-
Number of ways to choose k items from n items without repetition and without order.
|
|
75
|
-
|
|
76
|
-
Evaluates to n! / (k! * (n - k)!) when k <= n and evaluates
|
|
77
|
-
to zero when k > n.
|
|
78
|
-
|
|
79
|
-
Also called the binomial coefficient because it is equivalent
|
|
80
|
-
to the coefficient of k-th term in polynomial expansion of the
|
|
81
|
-
expression (1 + x)**n.
|
|
82
|
-
|
|
83
|
-
Raises TypeError if either of the arguments are not integers.
|
|
84
|
-
Raises ValueError if either of the arguments are negative.
|
|
85
|
-
"""
|
|
86
|
-
...
|
|
87
|
-
def copysign(x: _SupportsFloatOrIndex, y: _SupportsFloatOrIndex, /) -> float:
|
|
88
|
-
"""
|
|
89
|
-
Return a float with the magnitude (absolute value) of x but the sign of y.
|
|
90
|
-
|
|
91
|
-
On platforms that support signed zeros, copysign(1.0, -0.0)
|
|
92
|
-
returns -1.0.
|
|
93
|
-
"""
|
|
94
|
-
...
|
|
95
|
-
def cos(x: _SupportsFloatOrIndex, /) -> float:
|
|
96
|
-
"""Return the cosine of x (measured in radians)."""
|
|
97
|
-
...
|
|
98
|
-
def cosh(x: _SupportsFloatOrIndex, /) -> float:
|
|
99
|
-
"""Return the hyperbolic cosine of x."""
|
|
100
|
-
...
|
|
101
|
-
def degrees(x: _SupportsFloatOrIndex, /) -> float:
|
|
102
|
-
"""Convert angle x from radians to degrees."""
|
|
103
|
-
...
|
|
104
|
-
def dist(p: Iterable[_SupportsFloatOrIndex], q: Iterable[_SupportsFloatOrIndex], /) -> float:
|
|
105
|
-
"""
|
|
106
|
-
Return the Euclidean distance between two points p and q.
|
|
107
|
-
|
|
108
|
-
The points should be specified as sequences (or iterables) of
|
|
109
|
-
coordinates. Both inputs must have the same dimension.
|
|
110
|
-
|
|
111
|
-
Roughly equivalent to:
|
|
112
|
-
sqrt(sum((px - qx) ** 2.0 for px, qx in zip(p, q)))
|
|
113
|
-
"""
|
|
114
|
-
...
|
|
115
|
-
def erf(x: _SupportsFloatOrIndex, /) -> float:
|
|
116
|
-
"""Error function at x."""
|
|
117
|
-
...
|
|
118
|
-
def erfc(x: _SupportsFloatOrIndex, /) -> float:
|
|
119
|
-
"""Complementary error function at x."""
|
|
120
|
-
...
|
|
121
|
-
def exp(x: _SupportsFloatOrIndex, /) -> float:
|
|
122
|
-
"""Return e raised to the power of x."""
|
|
123
|
-
...
|
|
124
|
-
|
|
125
|
-
if sys.version_info >= (3, 11):
|
|
126
|
-
def exp2(x: _SupportsFloatOrIndex, /) -> float:
|
|
127
|
-
"""Return 2 raised to the power of x."""
|
|
128
|
-
...
|
|
129
|
-
|
|
130
|
-
def expm1(x: _SupportsFloatOrIndex, /) -> float:
|
|
131
|
-
"""
|
|
132
|
-
Return exp(x)-1.
|
|
133
|
-
|
|
134
|
-
This function avoids the loss of precision involved in the direct evaluation of exp(x)-1 for small x.
|
|
135
|
-
"""
|
|
136
|
-
...
|
|
137
|
-
def fabs(x: _SupportsFloatOrIndex, /) -> float:
|
|
138
|
-
"""Return the absolute value of the float x."""
|
|
139
|
-
...
|
|
140
|
-
def factorial(x: SupportsIndex, /) -> int:
|
|
141
|
-
"""
|
|
142
|
-
Find x!.
|
|
143
|
-
|
|
144
|
-
Raise a ValueError if x is negative or non-integral.
|
|
145
|
-
"""
|
|
146
|
-
...
|
|
147
|
-
|
|
148
|
-
class _SupportsFloor(Protocol[_T_co]):
|
|
149
|
-
def __floor__(self) -> _T_co: ...
|
|
150
|
-
|
|
151
|
-
@overload
|
|
152
|
-
def floor(x: _SupportsFloor[_T], /) -> _T:
|
|
153
|
-
"""
|
|
154
|
-
Return the floor of x as an Integral.
|
|
155
|
-
|
|
156
|
-
This is the largest integer <= x.
|
|
157
|
-
"""
|
|
158
|
-
...
|
|
159
|
-
@overload
|
|
160
|
-
def floor(x: _SupportsFloatOrIndex, /) -> int:
|
|
161
|
-
"""
|
|
162
|
-
Return the floor of x as an Integral.
|
|
163
|
-
|
|
164
|
-
This is the largest integer <= x.
|
|
165
|
-
"""
|
|
166
|
-
...
|
|
167
|
-
def fmod(x: _SupportsFloatOrIndex, y: _SupportsFloatOrIndex, /) -> float:
|
|
168
|
-
"""
|
|
169
|
-
Return fmod(x, y), according to platform C.
|
|
170
|
-
|
|
171
|
-
x % y may differ.
|
|
172
|
-
"""
|
|
173
|
-
...
|
|
174
|
-
def frexp(x: _SupportsFloatOrIndex, /) -> tuple[float, int]:
|
|
175
|
-
"""
|
|
176
|
-
Return the mantissa and exponent of x, as pair (m, e).
|
|
177
|
-
|
|
178
|
-
m is a float and e is an int, such that x = m * 2.**e.
|
|
179
|
-
If x is 0, m and e are both 0. Else 0.5 <= abs(m) < 1.0.
|
|
180
|
-
"""
|
|
181
|
-
...
|
|
182
|
-
def fsum(seq: Iterable[_SupportsFloatOrIndex], /) -> float:
|
|
183
|
-
"""
|
|
184
|
-
Return an accurate floating point sum of values in the iterable seq.
|
|
185
|
-
|
|
186
|
-
Assumes IEEE-754 floating point arithmetic.
|
|
187
|
-
"""
|
|
188
|
-
...
|
|
189
|
-
def gamma(x: _SupportsFloatOrIndex, /) -> float:
|
|
190
|
-
"""Gamma function at x."""
|
|
191
|
-
...
|
|
192
|
-
|
|
193
|
-
if sys.version_info >= (3, 9):
|
|
194
|
-
def gcd(*integers: SupportsIndex) -> int:
|
|
195
|
-
"""Greatest Common Divisor."""
|
|
196
|
-
...
|
|
197
|
-
|
|
198
|
-
else:
|
|
199
|
-
def gcd(x: SupportsIndex, y: SupportsIndex, /) -> int:
|
|
200
|
-
"""greatest common divisor of x and y"""
|
|
201
|
-
...
|
|
202
|
-
|
|
203
|
-
def hypot(*coordinates: _SupportsFloatOrIndex) -> float:
|
|
204
|
-
"""
|
|
205
|
-
hypot(*coordinates) -> value
|
|
206
|
-
|
|
207
|
-
Multidimensional Euclidean distance from the origin to a point.
|
|
208
|
-
|
|
209
|
-
Roughly equivalent to:
|
|
210
|
-
sqrt(sum(x**2 for x in coordinates))
|
|
211
|
-
|
|
212
|
-
For a two dimensional point (x, y), gives the hypotenuse
|
|
213
|
-
using the Pythagorean theorem: sqrt(x*x + y*y).
|
|
214
|
-
|
|
215
|
-
For example, the hypotenuse of a 3/4/5 right triangle is:
|
|
216
|
-
|
|
217
|
-
>>> hypot(3.0, 4.0)
|
|
218
|
-
5.0
|
|
219
|
-
"""
|
|
220
|
-
...
|
|
221
|
-
def isclose(
|
|
222
|
-
a: _SupportsFloatOrIndex,
|
|
223
|
-
b: _SupportsFloatOrIndex,
|
|
224
|
-
*,
|
|
225
|
-
rel_tol: _SupportsFloatOrIndex = 1e-09,
|
|
226
|
-
abs_tol: _SupportsFloatOrIndex = 0.0,
|
|
227
|
-
) -> bool:
|
|
228
|
-
"""
|
|
229
|
-
Determine whether two floating point numbers are close in value.
|
|
230
|
-
|
|
231
|
-
rel_tol
|
|
232
|
-
maximum difference for being considered "close", relative to the
|
|
233
|
-
magnitude of the input values
|
|
234
|
-
abs_tol
|
|
235
|
-
maximum difference for being considered "close", regardless of the
|
|
236
|
-
magnitude of the input values
|
|
237
|
-
|
|
238
|
-
Return True if a is close in value to b, and False otherwise.
|
|
239
|
-
|
|
240
|
-
For the values to be considered close, the difference between them
|
|
241
|
-
must be smaller than at least one of the tolerances.
|
|
242
|
-
|
|
243
|
-
-inf, inf and NaN behave similarly to the IEEE 754 Standard. That
|
|
244
|
-
is, NaN is not close to anything, even itself. inf and -inf are
|
|
245
|
-
only close to themselves.
|
|
246
|
-
"""
|
|
247
|
-
...
|
|
248
|
-
def isinf(x: _SupportsFloatOrIndex, /) -> bool:
|
|
249
|
-
"""Return True if x is a positive or negative infinity, and False otherwise."""
|
|
250
|
-
...
|
|
251
|
-
def isfinite(x: _SupportsFloatOrIndex, /) -> bool:
|
|
252
|
-
"""Return True if x is neither an infinity nor a NaN, and False otherwise."""
|
|
253
|
-
...
|
|
254
|
-
def isnan(x: _SupportsFloatOrIndex, /) -> bool:
|
|
255
|
-
"""Return True if x is a NaN (not a number), and False otherwise."""
|
|
256
|
-
...
|
|
257
|
-
def isqrt(n: SupportsIndex, /) -> int:
|
|
258
|
-
"""Return the integer part of the square root of the input."""
|
|
259
|
-
...
|
|
260
|
-
|
|
261
|
-
if sys.version_info >= (3, 9):
|
|
262
|
-
def lcm(*integers: SupportsIndex) -> int:
|
|
263
|
-
"""Least Common Multiple."""
|
|
264
|
-
...
|
|
265
|
-
|
|
266
|
-
def ldexp(x: _SupportsFloatOrIndex, i: int, /) -> float:
|
|
267
|
-
"""
|
|
268
|
-
Return x * (2**i).
|
|
269
|
-
|
|
270
|
-
This is essentially the inverse of frexp().
|
|
271
|
-
"""
|
|
272
|
-
...
|
|
273
|
-
def lgamma(x: _SupportsFloatOrIndex, /) -> float:
|
|
274
|
-
"""Natural logarithm of absolute value of Gamma function at x."""
|
|
275
|
-
...
|
|
276
|
-
def log(x: _SupportsFloatOrIndex, base: _SupportsFloatOrIndex = ...) -> float:
|
|
277
|
-
"""
|
|
278
|
-
log(x, [base=math.e])
|
|
279
|
-
Return the logarithm of x to the given base.
|
|
280
|
-
|
|
281
|
-
If the base not specified, returns the natural logarithm (base e) of x.
|
|
282
|
-
"""
|
|
283
|
-
...
|
|
284
|
-
def log10(x: _SupportsFloatOrIndex, /) -> float:
|
|
285
|
-
"""Return the base 10 logarithm of x."""
|
|
286
|
-
...
|
|
287
|
-
def log1p(x: _SupportsFloatOrIndex, /) -> float:
|
|
288
|
-
"""
|
|
289
|
-
Return the natural logarithm of 1+x (base e).
|
|
290
|
-
|
|
291
|
-
The result is computed in a way which is accurate for x near zero.
|
|
292
|
-
"""
|
|
293
|
-
...
|
|
294
|
-
def log2(x: _SupportsFloatOrIndex, /) -> float:
|
|
295
|
-
"""Return the base 2 logarithm of x."""
|
|
296
|
-
...
|
|
297
|
-
def modf(x: _SupportsFloatOrIndex, /) -> tuple[float, float]:
|
|
298
|
-
"""
|
|
299
|
-
Return the fractional and integer parts of x.
|
|
300
|
-
|
|
301
|
-
Both results carry the sign of x and are floats.
|
|
302
|
-
"""
|
|
303
|
-
...
|
|
304
|
-
|
|
305
|
-
if sys.version_info >= (3, 12):
|
|
306
|
-
def nextafter(x: _SupportsFloatOrIndex, y: _SupportsFloatOrIndex, /, *, steps: SupportsIndex | None = None) -> float:
|
|
307
|
-
"""
|
|
308
|
-
Return the floating-point value the given number of steps after x towards y.
|
|
309
|
-
|
|
310
|
-
If steps is not specified or is None, it defaults to 1.
|
|
311
|
-
|
|
312
|
-
Raises a TypeError, if x or y is not a double, or if steps is not an integer.
|
|
313
|
-
Raises ValueError if steps is negative.
|
|
314
|
-
"""
|
|
315
|
-
...
|
|
316
|
-
|
|
317
|
-
elif sys.version_info >= (3, 9):
|
|
318
|
-
def nextafter(x: _SupportsFloatOrIndex, y: _SupportsFloatOrIndex, /) -> float:
|
|
319
|
-
"""Return the next floating-point value after x towards y."""
|
|
320
|
-
...
|
|
321
|
-
|
|
322
|
-
def perm(n: SupportsIndex, k: SupportsIndex | None = None, /) -> int:
|
|
323
|
-
"""
|
|
324
|
-
Number of ways to choose k items from n items without repetition and with order.
|
|
325
|
-
|
|
326
|
-
Evaluates to n! / (n - k)! when k <= n and evaluates
|
|
327
|
-
to zero when k > n.
|
|
328
|
-
|
|
329
|
-
If k is not specified or is None, then k defaults to n
|
|
330
|
-
and the function returns n!.
|
|
331
|
-
|
|
332
|
-
Raises TypeError if either of the arguments are not integers.
|
|
333
|
-
Raises ValueError if either of the arguments are negative.
|
|
334
|
-
"""
|
|
335
|
-
...
|
|
336
|
-
def pow(x: _SupportsFloatOrIndex, y: _SupportsFloatOrIndex, /) -> float:
|
|
337
|
-
"""Return x**y (x to the power of y)."""
|
|
338
|
-
...
|
|
339
|
-
@overload
|
|
340
|
-
def prod(iterable: Iterable[SupportsIndex], /, *, start: SupportsIndex = 1) -> int:
|
|
341
|
-
"""
|
|
342
|
-
Calculate the product of all the elements in the input iterable.
|
|
343
|
-
|
|
344
|
-
The default start value for the product is 1.
|
|
345
|
-
|
|
346
|
-
When the iterable is empty, return the start value. This function is
|
|
347
|
-
intended specifically for use with numeric values and may reject
|
|
348
|
-
non-numeric types.
|
|
349
|
-
"""
|
|
350
|
-
...
|
|
351
|
-
@overload
|
|
352
|
-
def prod(iterable: Iterable[_SupportsFloatOrIndex], /, *, start: _SupportsFloatOrIndex = 1) -> float:
|
|
353
|
-
"""
|
|
354
|
-
Calculate the product of all the elements in the input iterable.
|
|
355
|
-
|
|
356
|
-
The default start value for the product is 1.
|
|
357
|
-
|
|
358
|
-
When the iterable is empty, return the start value. This function is
|
|
359
|
-
intended specifically for use with numeric values and may reject
|
|
360
|
-
non-numeric types.
|
|
361
|
-
"""
|
|
362
|
-
...
|
|
363
|
-
def radians(x: _SupportsFloatOrIndex, /) -> float:
|
|
364
|
-
"""Convert angle x from degrees to radians."""
|
|
365
|
-
...
|
|
366
|
-
def remainder(x: _SupportsFloatOrIndex, y: _SupportsFloatOrIndex, /) -> float:
|
|
367
|
-
"""
|
|
368
|
-
Difference between x and the closest integer multiple of y.
|
|
369
|
-
|
|
370
|
-
Return x - n*y where n*y is the closest integer multiple of y.
|
|
371
|
-
In the case where x is exactly halfway between two multiples of
|
|
372
|
-
y, the nearest even value of n is used. The result is always exact.
|
|
373
|
-
"""
|
|
374
|
-
...
|
|
375
|
-
def sin(x: _SupportsFloatOrIndex, /) -> float:
|
|
376
|
-
"""Return the sine of x (measured in radians)."""
|
|
377
|
-
...
|
|
378
|
-
def sinh(x: _SupportsFloatOrIndex, /) -> float:
|
|
379
|
-
"""Return the hyperbolic sine of x."""
|
|
380
|
-
...
|
|
381
|
-
|
|
382
|
-
if sys.version_info >= (3, 12):
|
|
383
|
-
def sumprod(p: Iterable[float], q: Iterable[float], /) -> float:
|
|
384
|
-
"""
|
|
385
|
-
Return the sum of products of values from two iterables p and q.
|
|
386
|
-
|
|
387
|
-
Roughly equivalent to:
|
|
388
|
-
|
|
389
|
-
sum(itertools.starmap(operator.mul, zip(p, q, strict=True)))
|
|
390
|
-
|
|
391
|
-
For float and mixed int/float inputs, the intermediate products
|
|
392
|
-
and sums are computed with extended precision.
|
|
393
|
-
"""
|
|
394
|
-
...
|
|
395
|
-
|
|
396
|
-
def sqrt(x: _SupportsFloatOrIndex, /) -> float:
|
|
397
|
-
"""Return the square root of x."""
|
|
398
|
-
...
|
|
399
|
-
def tan(x: _SupportsFloatOrIndex, /) -> float:
|
|
400
|
-
"""Return the tangent of x (measured in radians)."""
|
|
401
|
-
...
|
|
402
|
-
def tanh(x: _SupportsFloatOrIndex, /) -> float:
|
|
403
|
-
"""Return the hyperbolic tangent of x."""
|
|
404
|
-
...
|
|
405
|
-
|
|
406
|
-
# Is different from `_typeshed.SupportsTrunc`, which is not generic
|
|
407
|
-
class _SupportsTrunc(Protocol[_T_co]):
|
|
408
|
-
def __trunc__(self) -> _T_co: ...
|
|
409
|
-
|
|
410
|
-
def trunc(x: _SupportsTrunc[_T], /) -> _T:
|
|
411
|
-
"""
|
|
412
|
-
Truncates the Real x to the nearest Integral toward 0.
|
|
413
|
-
|
|
414
|
-
Uses the __trunc__ magic method.
|
|
415
|
-
"""
|
|
416
|
-
...
|
|
417
|
-
|
|
418
|
-
if sys.version_info >= (3, 9):
|
|
419
|
-
def ulp(x: _SupportsFloatOrIndex, /) -> float:
|
|
420
|
-
"""Return the value of the least significant bit of the float x."""
|
|
421
|
-
...
|
|
422
|
-
|
|
423
|
-
if sys.version_info >= (3, 13):
|
|
424
|
-
def fma(x: _SupportsFloatOrIndex, y: _SupportsFloatOrIndex, z: _SupportsFloatOrIndex, /) -> float: ...
|
|
1
|
+
"""
|
|
2
|
+
This module provides access to the mathematical functions
|
|
3
|
+
defined by the C standard.
|
|
4
|
+
"""
|
|
5
|
+
|
|
6
|
+
import sys
|
|
7
|
+
from collections.abc import Iterable
|
|
8
|
+
from typing import Protocol, SupportsFloat, SupportsIndex, TypeVar, overload
|
|
9
|
+
from typing_extensions import TypeAlias
|
|
10
|
+
|
|
11
|
+
_T = TypeVar("_T")
|
|
12
|
+
_T_co = TypeVar("_T_co", covariant=True)
|
|
13
|
+
|
|
14
|
+
_SupportsFloatOrIndex: TypeAlias = SupportsFloat | SupportsIndex
|
|
15
|
+
|
|
16
|
+
e: float
|
|
17
|
+
pi: float
|
|
18
|
+
inf: float
|
|
19
|
+
nan: float
|
|
20
|
+
tau: float
|
|
21
|
+
|
|
22
|
+
def acos(x: _SupportsFloatOrIndex, /) -> float:
|
|
23
|
+
"""Return the arc cosine (measured in radians) of x."""
|
|
24
|
+
...
|
|
25
|
+
def acosh(x: _SupportsFloatOrIndex, /) -> float:
|
|
26
|
+
"""Return the inverse hyperbolic cosine of x."""
|
|
27
|
+
...
|
|
28
|
+
def asin(x: _SupportsFloatOrIndex, /) -> float:
|
|
29
|
+
"""Return the arc sine (measured in radians) of x."""
|
|
30
|
+
...
|
|
31
|
+
def asinh(x: _SupportsFloatOrIndex, /) -> float:
|
|
32
|
+
"""Return the inverse hyperbolic sine of x."""
|
|
33
|
+
...
|
|
34
|
+
def atan(x: _SupportsFloatOrIndex, /) -> float:
|
|
35
|
+
"""Return the arc tangent (measured in radians) of x."""
|
|
36
|
+
...
|
|
37
|
+
def atan2(y: _SupportsFloatOrIndex, x: _SupportsFloatOrIndex, /) -> float:
|
|
38
|
+
"""
|
|
39
|
+
Return the arc tangent (measured in radians) of y/x.
|
|
40
|
+
|
|
41
|
+
Unlike atan(y/x), the signs of both x and y are considered.
|
|
42
|
+
"""
|
|
43
|
+
...
|
|
44
|
+
def atanh(x: _SupportsFloatOrIndex, /) -> float:
|
|
45
|
+
"""Return the inverse hyperbolic tangent of x."""
|
|
46
|
+
...
|
|
47
|
+
|
|
48
|
+
if sys.version_info >= (3, 11):
|
|
49
|
+
def cbrt(x: _SupportsFloatOrIndex, /) -> float:
|
|
50
|
+
"""Return the cube root of x."""
|
|
51
|
+
...
|
|
52
|
+
|
|
53
|
+
class _SupportsCeil(Protocol[_T_co]):
|
|
54
|
+
def __ceil__(self) -> _T_co: ...
|
|
55
|
+
|
|
56
|
+
@overload
|
|
57
|
+
def ceil(x: _SupportsCeil[_T], /) -> _T:
|
|
58
|
+
"""
|
|
59
|
+
Return the ceiling of x as an Integral.
|
|
60
|
+
|
|
61
|
+
This is the smallest integer >= x.
|
|
62
|
+
"""
|
|
63
|
+
...
|
|
64
|
+
@overload
|
|
65
|
+
def ceil(x: _SupportsFloatOrIndex, /) -> int:
|
|
66
|
+
"""
|
|
67
|
+
Return the ceiling of x as an Integral.
|
|
68
|
+
|
|
69
|
+
This is the smallest integer >= x.
|
|
70
|
+
"""
|
|
71
|
+
...
|
|
72
|
+
def comb(n: SupportsIndex, k: SupportsIndex, /) -> int:
|
|
73
|
+
"""
|
|
74
|
+
Number of ways to choose k items from n items without repetition and without order.
|
|
75
|
+
|
|
76
|
+
Evaluates to n! / (k! * (n - k)!) when k <= n and evaluates
|
|
77
|
+
to zero when k > n.
|
|
78
|
+
|
|
79
|
+
Also called the binomial coefficient because it is equivalent
|
|
80
|
+
to the coefficient of k-th term in polynomial expansion of the
|
|
81
|
+
expression (1 + x)**n.
|
|
82
|
+
|
|
83
|
+
Raises TypeError if either of the arguments are not integers.
|
|
84
|
+
Raises ValueError if either of the arguments are negative.
|
|
85
|
+
"""
|
|
86
|
+
...
|
|
87
|
+
def copysign(x: _SupportsFloatOrIndex, y: _SupportsFloatOrIndex, /) -> float:
|
|
88
|
+
"""
|
|
89
|
+
Return a float with the magnitude (absolute value) of x but the sign of y.
|
|
90
|
+
|
|
91
|
+
On platforms that support signed zeros, copysign(1.0, -0.0)
|
|
92
|
+
returns -1.0.
|
|
93
|
+
"""
|
|
94
|
+
...
|
|
95
|
+
def cos(x: _SupportsFloatOrIndex, /) -> float:
|
|
96
|
+
"""Return the cosine of x (measured in radians)."""
|
|
97
|
+
...
|
|
98
|
+
def cosh(x: _SupportsFloatOrIndex, /) -> float:
|
|
99
|
+
"""Return the hyperbolic cosine of x."""
|
|
100
|
+
...
|
|
101
|
+
def degrees(x: _SupportsFloatOrIndex, /) -> float:
|
|
102
|
+
"""Convert angle x from radians to degrees."""
|
|
103
|
+
...
|
|
104
|
+
def dist(p: Iterable[_SupportsFloatOrIndex], q: Iterable[_SupportsFloatOrIndex], /) -> float:
|
|
105
|
+
"""
|
|
106
|
+
Return the Euclidean distance between two points p and q.
|
|
107
|
+
|
|
108
|
+
The points should be specified as sequences (or iterables) of
|
|
109
|
+
coordinates. Both inputs must have the same dimension.
|
|
110
|
+
|
|
111
|
+
Roughly equivalent to:
|
|
112
|
+
sqrt(sum((px - qx) ** 2.0 for px, qx in zip(p, q)))
|
|
113
|
+
"""
|
|
114
|
+
...
|
|
115
|
+
def erf(x: _SupportsFloatOrIndex, /) -> float:
|
|
116
|
+
"""Error function at x."""
|
|
117
|
+
...
|
|
118
|
+
def erfc(x: _SupportsFloatOrIndex, /) -> float:
|
|
119
|
+
"""Complementary error function at x."""
|
|
120
|
+
...
|
|
121
|
+
def exp(x: _SupportsFloatOrIndex, /) -> float:
|
|
122
|
+
"""Return e raised to the power of x."""
|
|
123
|
+
...
|
|
124
|
+
|
|
125
|
+
if sys.version_info >= (3, 11):
|
|
126
|
+
def exp2(x: _SupportsFloatOrIndex, /) -> float:
|
|
127
|
+
"""Return 2 raised to the power of x."""
|
|
128
|
+
...
|
|
129
|
+
|
|
130
|
+
def expm1(x: _SupportsFloatOrIndex, /) -> float:
|
|
131
|
+
"""
|
|
132
|
+
Return exp(x)-1.
|
|
133
|
+
|
|
134
|
+
This function avoids the loss of precision involved in the direct evaluation of exp(x)-1 for small x.
|
|
135
|
+
"""
|
|
136
|
+
...
|
|
137
|
+
def fabs(x: _SupportsFloatOrIndex, /) -> float:
|
|
138
|
+
"""Return the absolute value of the float x."""
|
|
139
|
+
...
|
|
140
|
+
def factorial(x: SupportsIndex, /) -> int:
|
|
141
|
+
"""
|
|
142
|
+
Find x!.
|
|
143
|
+
|
|
144
|
+
Raise a ValueError if x is negative or non-integral.
|
|
145
|
+
"""
|
|
146
|
+
...
|
|
147
|
+
|
|
148
|
+
class _SupportsFloor(Protocol[_T_co]):
|
|
149
|
+
def __floor__(self) -> _T_co: ...
|
|
150
|
+
|
|
151
|
+
@overload
|
|
152
|
+
def floor(x: _SupportsFloor[_T], /) -> _T:
|
|
153
|
+
"""
|
|
154
|
+
Return the floor of x as an Integral.
|
|
155
|
+
|
|
156
|
+
This is the largest integer <= x.
|
|
157
|
+
"""
|
|
158
|
+
...
|
|
159
|
+
@overload
|
|
160
|
+
def floor(x: _SupportsFloatOrIndex, /) -> int:
|
|
161
|
+
"""
|
|
162
|
+
Return the floor of x as an Integral.
|
|
163
|
+
|
|
164
|
+
This is the largest integer <= x.
|
|
165
|
+
"""
|
|
166
|
+
...
|
|
167
|
+
def fmod(x: _SupportsFloatOrIndex, y: _SupportsFloatOrIndex, /) -> float:
|
|
168
|
+
"""
|
|
169
|
+
Return fmod(x, y), according to platform C.
|
|
170
|
+
|
|
171
|
+
x % y may differ.
|
|
172
|
+
"""
|
|
173
|
+
...
|
|
174
|
+
def frexp(x: _SupportsFloatOrIndex, /) -> tuple[float, int]:
|
|
175
|
+
"""
|
|
176
|
+
Return the mantissa and exponent of x, as pair (m, e).
|
|
177
|
+
|
|
178
|
+
m is a float and e is an int, such that x = m * 2.**e.
|
|
179
|
+
If x is 0, m and e are both 0. Else 0.5 <= abs(m) < 1.0.
|
|
180
|
+
"""
|
|
181
|
+
...
|
|
182
|
+
def fsum(seq: Iterable[_SupportsFloatOrIndex], /) -> float:
|
|
183
|
+
"""
|
|
184
|
+
Return an accurate floating point sum of values in the iterable seq.
|
|
185
|
+
|
|
186
|
+
Assumes IEEE-754 floating point arithmetic.
|
|
187
|
+
"""
|
|
188
|
+
...
|
|
189
|
+
def gamma(x: _SupportsFloatOrIndex, /) -> float:
|
|
190
|
+
"""Gamma function at x."""
|
|
191
|
+
...
|
|
192
|
+
|
|
193
|
+
if sys.version_info >= (3, 9):
|
|
194
|
+
def gcd(*integers: SupportsIndex) -> int:
|
|
195
|
+
"""Greatest Common Divisor."""
|
|
196
|
+
...
|
|
197
|
+
|
|
198
|
+
else:
|
|
199
|
+
def gcd(x: SupportsIndex, y: SupportsIndex, /) -> int:
|
|
200
|
+
"""greatest common divisor of x and y"""
|
|
201
|
+
...
|
|
202
|
+
|
|
203
|
+
def hypot(*coordinates: _SupportsFloatOrIndex) -> float:
|
|
204
|
+
"""
|
|
205
|
+
hypot(*coordinates) -> value
|
|
206
|
+
|
|
207
|
+
Multidimensional Euclidean distance from the origin to a point.
|
|
208
|
+
|
|
209
|
+
Roughly equivalent to:
|
|
210
|
+
sqrt(sum(x**2 for x in coordinates))
|
|
211
|
+
|
|
212
|
+
For a two dimensional point (x, y), gives the hypotenuse
|
|
213
|
+
using the Pythagorean theorem: sqrt(x*x + y*y).
|
|
214
|
+
|
|
215
|
+
For example, the hypotenuse of a 3/4/5 right triangle is:
|
|
216
|
+
|
|
217
|
+
>>> hypot(3.0, 4.0)
|
|
218
|
+
5.0
|
|
219
|
+
"""
|
|
220
|
+
...
|
|
221
|
+
def isclose(
|
|
222
|
+
a: _SupportsFloatOrIndex,
|
|
223
|
+
b: _SupportsFloatOrIndex,
|
|
224
|
+
*,
|
|
225
|
+
rel_tol: _SupportsFloatOrIndex = 1e-09,
|
|
226
|
+
abs_tol: _SupportsFloatOrIndex = 0.0,
|
|
227
|
+
) -> bool:
|
|
228
|
+
"""
|
|
229
|
+
Determine whether two floating point numbers are close in value.
|
|
230
|
+
|
|
231
|
+
rel_tol
|
|
232
|
+
maximum difference for being considered "close", relative to the
|
|
233
|
+
magnitude of the input values
|
|
234
|
+
abs_tol
|
|
235
|
+
maximum difference for being considered "close", regardless of the
|
|
236
|
+
magnitude of the input values
|
|
237
|
+
|
|
238
|
+
Return True if a is close in value to b, and False otherwise.
|
|
239
|
+
|
|
240
|
+
For the values to be considered close, the difference between them
|
|
241
|
+
must be smaller than at least one of the tolerances.
|
|
242
|
+
|
|
243
|
+
-inf, inf and NaN behave similarly to the IEEE 754 Standard. That
|
|
244
|
+
is, NaN is not close to anything, even itself. inf and -inf are
|
|
245
|
+
only close to themselves.
|
|
246
|
+
"""
|
|
247
|
+
...
|
|
248
|
+
def isinf(x: _SupportsFloatOrIndex, /) -> bool:
|
|
249
|
+
"""Return True if x is a positive or negative infinity, and False otherwise."""
|
|
250
|
+
...
|
|
251
|
+
def isfinite(x: _SupportsFloatOrIndex, /) -> bool:
|
|
252
|
+
"""Return True if x is neither an infinity nor a NaN, and False otherwise."""
|
|
253
|
+
...
|
|
254
|
+
def isnan(x: _SupportsFloatOrIndex, /) -> bool:
|
|
255
|
+
"""Return True if x is a NaN (not a number), and False otherwise."""
|
|
256
|
+
...
|
|
257
|
+
def isqrt(n: SupportsIndex, /) -> int:
|
|
258
|
+
"""Return the integer part of the square root of the input."""
|
|
259
|
+
...
|
|
260
|
+
|
|
261
|
+
if sys.version_info >= (3, 9):
|
|
262
|
+
def lcm(*integers: SupportsIndex) -> int:
|
|
263
|
+
"""Least Common Multiple."""
|
|
264
|
+
...
|
|
265
|
+
|
|
266
|
+
def ldexp(x: _SupportsFloatOrIndex, i: int, /) -> float:
|
|
267
|
+
"""
|
|
268
|
+
Return x * (2**i).
|
|
269
|
+
|
|
270
|
+
This is essentially the inverse of frexp().
|
|
271
|
+
"""
|
|
272
|
+
...
|
|
273
|
+
def lgamma(x: _SupportsFloatOrIndex, /) -> float:
|
|
274
|
+
"""Natural logarithm of absolute value of Gamma function at x."""
|
|
275
|
+
...
|
|
276
|
+
def log(x: _SupportsFloatOrIndex, base: _SupportsFloatOrIndex = ...) -> float:
|
|
277
|
+
"""
|
|
278
|
+
log(x, [base=math.e])
|
|
279
|
+
Return the logarithm of x to the given base.
|
|
280
|
+
|
|
281
|
+
If the base not specified, returns the natural logarithm (base e) of x.
|
|
282
|
+
"""
|
|
283
|
+
...
|
|
284
|
+
def log10(x: _SupportsFloatOrIndex, /) -> float:
|
|
285
|
+
"""Return the base 10 logarithm of x."""
|
|
286
|
+
...
|
|
287
|
+
def log1p(x: _SupportsFloatOrIndex, /) -> float:
|
|
288
|
+
"""
|
|
289
|
+
Return the natural logarithm of 1+x (base e).
|
|
290
|
+
|
|
291
|
+
The result is computed in a way which is accurate for x near zero.
|
|
292
|
+
"""
|
|
293
|
+
...
|
|
294
|
+
def log2(x: _SupportsFloatOrIndex, /) -> float:
|
|
295
|
+
"""Return the base 2 logarithm of x."""
|
|
296
|
+
...
|
|
297
|
+
def modf(x: _SupportsFloatOrIndex, /) -> tuple[float, float]:
|
|
298
|
+
"""
|
|
299
|
+
Return the fractional and integer parts of x.
|
|
300
|
+
|
|
301
|
+
Both results carry the sign of x and are floats.
|
|
302
|
+
"""
|
|
303
|
+
...
|
|
304
|
+
|
|
305
|
+
if sys.version_info >= (3, 12):
|
|
306
|
+
def nextafter(x: _SupportsFloatOrIndex, y: _SupportsFloatOrIndex, /, *, steps: SupportsIndex | None = None) -> float:
|
|
307
|
+
"""
|
|
308
|
+
Return the floating-point value the given number of steps after x towards y.
|
|
309
|
+
|
|
310
|
+
If steps is not specified or is None, it defaults to 1.
|
|
311
|
+
|
|
312
|
+
Raises a TypeError, if x or y is not a double, or if steps is not an integer.
|
|
313
|
+
Raises ValueError if steps is negative.
|
|
314
|
+
"""
|
|
315
|
+
...
|
|
316
|
+
|
|
317
|
+
elif sys.version_info >= (3, 9):
|
|
318
|
+
def nextafter(x: _SupportsFloatOrIndex, y: _SupportsFloatOrIndex, /) -> float:
|
|
319
|
+
"""Return the next floating-point value after x towards y."""
|
|
320
|
+
...
|
|
321
|
+
|
|
322
|
+
def perm(n: SupportsIndex, k: SupportsIndex | None = None, /) -> int:
|
|
323
|
+
"""
|
|
324
|
+
Number of ways to choose k items from n items without repetition and with order.
|
|
325
|
+
|
|
326
|
+
Evaluates to n! / (n - k)! when k <= n and evaluates
|
|
327
|
+
to zero when k > n.
|
|
328
|
+
|
|
329
|
+
If k is not specified or is None, then k defaults to n
|
|
330
|
+
and the function returns n!.
|
|
331
|
+
|
|
332
|
+
Raises TypeError if either of the arguments are not integers.
|
|
333
|
+
Raises ValueError if either of the arguments are negative.
|
|
334
|
+
"""
|
|
335
|
+
...
|
|
336
|
+
def pow(x: _SupportsFloatOrIndex, y: _SupportsFloatOrIndex, /) -> float:
|
|
337
|
+
"""Return x**y (x to the power of y)."""
|
|
338
|
+
...
|
|
339
|
+
@overload
|
|
340
|
+
def prod(iterable: Iterable[SupportsIndex], /, *, start: SupportsIndex = 1) -> int:
|
|
341
|
+
"""
|
|
342
|
+
Calculate the product of all the elements in the input iterable.
|
|
343
|
+
|
|
344
|
+
The default start value for the product is 1.
|
|
345
|
+
|
|
346
|
+
When the iterable is empty, return the start value. This function is
|
|
347
|
+
intended specifically for use with numeric values and may reject
|
|
348
|
+
non-numeric types.
|
|
349
|
+
"""
|
|
350
|
+
...
|
|
351
|
+
@overload
|
|
352
|
+
def prod(iterable: Iterable[_SupportsFloatOrIndex], /, *, start: _SupportsFloatOrIndex = 1) -> float:
|
|
353
|
+
"""
|
|
354
|
+
Calculate the product of all the elements in the input iterable.
|
|
355
|
+
|
|
356
|
+
The default start value for the product is 1.
|
|
357
|
+
|
|
358
|
+
When the iterable is empty, return the start value. This function is
|
|
359
|
+
intended specifically for use with numeric values and may reject
|
|
360
|
+
non-numeric types.
|
|
361
|
+
"""
|
|
362
|
+
...
|
|
363
|
+
def radians(x: _SupportsFloatOrIndex, /) -> float:
|
|
364
|
+
"""Convert angle x from degrees to radians."""
|
|
365
|
+
...
|
|
366
|
+
def remainder(x: _SupportsFloatOrIndex, y: _SupportsFloatOrIndex, /) -> float:
|
|
367
|
+
"""
|
|
368
|
+
Difference between x and the closest integer multiple of y.
|
|
369
|
+
|
|
370
|
+
Return x - n*y where n*y is the closest integer multiple of y.
|
|
371
|
+
In the case where x is exactly halfway between two multiples of
|
|
372
|
+
y, the nearest even value of n is used. The result is always exact.
|
|
373
|
+
"""
|
|
374
|
+
...
|
|
375
|
+
def sin(x: _SupportsFloatOrIndex, /) -> float:
|
|
376
|
+
"""Return the sine of x (measured in radians)."""
|
|
377
|
+
...
|
|
378
|
+
def sinh(x: _SupportsFloatOrIndex, /) -> float:
|
|
379
|
+
"""Return the hyperbolic sine of x."""
|
|
380
|
+
...
|
|
381
|
+
|
|
382
|
+
if sys.version_info >= (3, 12):
|
|
383
|
+
def sumprod(p: Iterable[float], q: Iterable[float], /) -> float:
|
|
384
|
+
"""
|
|
385
|
+
Return the sum of products of values from two iterables p and q.
|
|
386
|
+
|
|
387
|
+
Roughly equivalent to:
|
|
388
|
+
|
|
389
|
+
sum(itertools.starmap(operator.mul, zip(p, q, strict=True)))
|
|
390
|
+
|
|
391
|
+
For float and mixed int/float inputs, the intermediate products
|
|
392
|
+
and sums are computed with extended precision.
|
|
393
|
+
"""
|
|
394
|
+
...
|
|
395
|
+
|
|
396
|
+
def sqrt(x: _SupportsFloatOrIndex, /) -> float:
|
|
397
|
+
"""Return the square root of x."""
|
|
398
|
+
...
|
|
399
|
+
def tan(x: _SupportsFloatOrIndex, /) -> float:
|
|
400
|
+
"""Return the tangent of x (measured in radians)."""
|
|
401
|
+
...
|
|
402
|
+
def tanh(x: _SupportsFloatOrIndex, /) -> float:
|
|
403
|
+
"""Return the hyperbolic tangent of x."""
|
|
404
|
+
...
|
|
405
|
+
|
|
406
|
+
# Is different from `_typeshed.SupportsTrunc`, which is not generic
|
|
407
|
+
class _SupportsTrunc(Protocol[_T_co]):
|
|
408
|
+
def __trunc__(self) -> _T_co: ...
|
|
409
|
+
|
|
410
|
+
def trunc(x: _SupportsTrunc[_T], /) -> _T:
|
|
411
|
+
"""
|
|
412
|
+
Truncates the Real x to the nearest Integral toward 0.
|
|
413
|
+
|
|
414
|
+
Uses the __trunc__ magic method.
|
|
415
|
+
"""
|
|
416
|
+
...
|
|
417
|
+
|
|
418
|
+
if sys.version_info >= (3, 9):
|
|
419
|
+
def ulp(x: _SupportsFloatOrIndex, /) -> float:
|
|
420
|
+
"""Return the value of the least significant bit of the float x."""
|
|
421
|
+
...
|
|
422
|
+
|
|
423
|
+
if sys.version_info >= (3, 13):
|
|
424
|
+
def fma(x: _SupportsFloatOrIndex, y: _SupportsFloatOrIndex, z: _SupportsFloatOrIndex, /) -> float: ...
|