pyrefly-numpy-stubs 1.3.0.dev3__py3-none-any.whl → 1.3.0.dev4__py3-none-any.whl
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.
- numpy-stubs/__init__.pyi +50 -44
- numpy-stubs/_shapes.pyi +12 -12
- numpy-stubs/linalg/__init__.pyi +4 -4
- {pyrefly_numpy_stubs-1.3.0.dev3.dist-info → pyrefly_numpy_stubs-1.3.0.dev4.dist-info}/METADATA +2 -2
- pyrefly_numpy_stubs-1.3.0.dev4.dist-info/RECORD +9 -0
- pyrefly_numpy_stubs-1.3.0.dev3.dist-info/RECORD +0 -9
- {pyrefly_numpy_stubs-1.3.0.dev3.dist-info → pyrefly_numpy_stubs-1.3.0.dev4.dist-info}/WHEEL +0 -0
- {pyrefly_numpy_stubs-1.3.0.dev3.dist-info → pyrefly_numpy_stubs-1.3.0.dev4.dist-info}/licenses/LICENSE +0 -0
numpy-stubs/__init__.pyi
CHANGED
|
@@ -3,17 +3,20 @@
|
|
|
3
3
|
# This source code is licensed under the MIT license found in the
|
|
4
4
|
# LICENSE file in the root directory of this source tree.
|
|
5
5
|
|
|
6
|
+
from collections.abc import Sequence
|
|
7
|
+
from types import EllipsisType
|
|
6
8
|
from typing import Any, Literal, overload
|
|
7
9
|
|
|
8
10
|
import shape_extensions
|
|
9
11
|
from numpy._shapes import diag_extent, matmul_shape, reduce_shape
|
|
10
|
-
from shape_extensions import broadcast, Flag, Int, IntTuple, IntVar
|
|
12
|
+
from shape_extensions import broadcast, Flag, Index, index_shape, Int, IntTuple, IntVar
|
|
11
13
|
|
|
12
14
|
from . import linalg as linalg, random as random
|
|
13
15
|
|
|
14
16
|
type _Shape = IntTuple
|
|
15
17
|
type _AnyShape = tuple[Any, ...]
|
|
16
18
|
type _Axis = int | tuple[int, ...] | None
|
|
19
|
+
type _BasicIndex = int | slice | list[int] | None | EllipsisType
|
|
17
20
|
|
|
18
21
|
class generic: ...
|
|
19
22
|
class bool_(generic): ...
|
|
@@ -23,6 +26,9 @@ class int32(generic): ...
|
|
|
23
26
|
class int64(generic): ...
|
|
24
27
|
class intp(generic): ...
|
|
25
28
|
|
|
29
|
+
type _IndexScalar = int | bool_ | int32 | int64 | intp
|
|
30
|
+
type _IndexSequence = Sequence[_IndexScalar] | Sequence[Sequence[_IndexScalar]]
|
|
31
|
+
|
|
26
32
|
class dtype[Scalar = Any]:
|
|
27
33
|
@overload
|
|
28
34
|
def __new__[ScalarT: generic](cls, dtype: type[ScalarT]) -> dtype[ScalarT]: ...
|
|
@@ -34,7 +40,7 @@ class dtype[Scalar = Any]:
|
|
|
34
40
|
# its body. Annotations inside the class reach the class through this alias.
|
|
35
41
|
_dtype = dtype
|
|
36
42
|
|
|
37
|
-
@shape_extensions.shaped_array(shape="Shape")
|
|
43
|
+
@shape_extensions.shaped_array(shape="Shape", builtin_indexing=False)
|
|
38
44
|
class ndarray[Shape: _Shape = _AnyShape, DType = Any]:
|
|
39
45
|
shape: Shape
|
|
40
46
|
dtype: DType
|
|
@@ -42,9 +48,7 @@ class ndarray[Shape: _Shape = _AnyShape, DType = Any]:
|
|
|
42
48
|
def __len__[N: IntVar](self: ndarray[[N]]) -> Int[N]: ...
|
|
43
49
|
@overload
|
|
44
50
|
def __len__[N: IntVar, M: IntVar](self: ndarray[[N, M]]) -> Int[N]: ...
|
|
45
|
-
|
|
46
|
-
# infers a gradual shape rather than `[I]`, and float indices are not
|
|
47
|
-
# rejected. `test_indexing.py` covers both cases at runtime only.
|
|
51
|
+
@overload
|
|
48
52
|
def __getitem__[
|
|
49
53
|
N: IntVar,
|
|
50
54
|
M: IntVar,
|
|
@@ -58,6 +62,21 @@ class ndarray[Shape: _Shape = _AnyShape, DType = Any]:
|
|
|
58
62
|
ndarray[[I], _dtype[ColumnIndexScalar]],
|
|
59
63
|
],
|
|
60
64
|
) -> ndarray[[I], DType]: ...
|
|
65
|
+
@overload
|
|
66
|
+
def __getitem__[I: Index](
|
|
67
|
+
self: ndarray[Shape, DType], key: I
|
|
68
|
+
) -> ndarray[index_shape(Shape, I), DType]: ...
|
|
69
|
+
# TODO(stroxler): Model general array-valued indices precisely enough to
|
|
70
|
+
# reject non-integer dtypes and incompatible advanced-index shapes.
|
|
71
|
+
@overload
|
|
72
|
+
def __getitem__(
|
|
73
|
+
self: ndarray[Shape, DType],
|
|
74
|
+
key: _BasicIndex
|
|
75
|
+
| _IndexScalar
|
|
76
|
+
| _IndexSequence
|
|
77
|
+
| ndarray
|
|
78
|
+
| tuple[_BasicIndex | _IndexScalar | _IndexSequence | ndarray, ...],
|
|
79
|
+
) -> ndarray[IntTuple, DType]: ...
|
|
61
80
|
# Only 2-D transpose is modeled for the NumPy shape-stub MVP.
|
|
62
81
|
@property
|
|
63
82
|
def T[N: IntVar, P: IntVar](
|
|
@@ -149,44 +168,33 @@ class ndarray[Shape: _Shape = _AnyShape, DType = Any]:
|
|
|
149
168
|
def __rpow__[OtherShape: _Shape](
|
|
150
169
|
self, other: ndarray[OtherShape]
|
|
151
170
|
) -> ndarray[broadcast(Shape, OtherShape), DType]: ...
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
# These narrow method bridges currently cover the shapes used by the example corpus.
|
|
159
|
-
@overload
|
|
160
|
-
def mean[N: IntVar, M: IntVar](
|
|
161
|
-
self: ndarray[[N, M], DType],
|
|
162
|
-
axis: Literal[0],
|
|
171
|
+
def __matmul__[OtherShape: _Shape](
|
|
172
|
+
self, other: ndarray[OtherShape]
|
|
173
|
+
) -> ndarray[matmul_shape(Shape, OtherShape), DType]: ...
|
|
174
|
+
def mean[Axis: Flag[_Axis], KeepDims: Flag[bool]](
|
|
175
|
+
self,
|
|
176
|
+
axis: Axis = None,
|
|
163
177
|
*,
|
|
164
|
-
keepdims:
|
|
165
|
-
) -> ndarray[
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
) -> ndarray[[], DType]: ...
|
|
170
|
-
@overload
|
|
171
|
-
def sum[N: IntVar, M: IntVar](
|
|
172
|
-
self: ndarray[[N, M], DType],
|
|
173
|
-
axis: Literal[1],
|
|
178
|
+
keepdims: KeepDims = False,
|
|
179
|
+
) -> ndarray[reduce_shape(Shape, Axis, KeepDims), DType]: ...
|
|
180
|
+
def sum[Axis: Flag[_Axis], KeepDims: Flag[bool]](
|
|
181
|
+
self,
|
|
182
|
+
axis: Axis = None,
|
|
174
183
|
*,
|
|
175
|
-
keepdims:
|
|
176
|
-
) -> ndarray[
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
axis: Literal[1],
|
|
184
|
+
keepdims: KeepDims = False,
|
|
185
|
+
) -> ndarray[reduce_shape(Shape, Axis, KeepDims), DType]: ...
|
|
186
|
+
def min[Axis: Flag[_Axis], KeepDims: Flag[bool]](
|
|
187
|
+
self,
|
|
188
|
+
axis: Axis = None,
|
|
181
189
|
*,
|
|
182
|
-
keepdims:
|
|
183
|
-
) -> ndarray[
|
|
184
|
-
def max[
|
|
185
|
-
self
|
|
186
|
-
axis:
|
|
190
|
+
keepdims: KeepDims = False,
|
|
191
|
+
) -> ndarray[reduce_shape(Shape, Axis, KeepDims), DType]: ...
|
|
192
|
+
def max[Axis: Flag[_Axis], KeepDims: Flag[bool]](
|
|
193
|
+
self,
|
|
194
|
+
axis: Axis = None,
|
|
187
195
|
*,
|
|
188
|
-
keepdims:
|
|
189
|
-
) -> ndarray[
|
|
196
|
+
keepdims: KeepDims = False,
|
|
197
|
+
) -> ndarray[reduce_shape(Shape, Axis, KeepDims), DType]: ...
|
|
190
198
|
|
|
191
199
|
def abs[Shape: _Shape](x: ndarray[Shape]) -> ndarray[Shape]: ...
|
|
192
200
|
def exp[Shape: _Shape](x: ndarray[Shape]) -> ndarray[Shape]: ...
|
|
@@ -224,7 +232,7 @@ def fill_diagonal[N: IntVar, DType](
|
|
|
224
232
|
@overload
|
|
225
233
|
def diag[N: IntVar, DType, K: Flag[int] = 0](
|
|
226
234
|
v: ndarray[[N], DType], k: K = 0
|
|
227
|
-
) -> ndarray[[diag_extent(N, K), diag_extent(N, K)], DType]: ...
|
|
235
|
+
) -> ndarray[[diag_extent(Int[N], K), diag_extent(Int[N], K)], DType]: ...
|
|
228
236
|
|
|
229
237
|
# TODO(stroxler): Model the shape arithmetic here; we can do better than `int`.
|
|
230
238
|
@overload
|
|
@@ -307,10 +315,8 @@ def argmin[N: IntVar, M: IntVar](
|
|
|
307
315
|
keepdims: Literal[False] = False,
|
|
308
316
|
) -> ndarray[[N], dtype[intp]]: ...
|
|
309
317
|
|
|
310
|
-
#
|
|
311
|
-
#
|
|
312
|
-
# gradual because dtype promotion is not modeled, while `ndarray.__matmul__`
|
|
313
|
-
# carries the left operand's dtype.
|
|
318
|
+
# The result dtype stays gradual because dtype promotion is not modeled, while
|
|
319
|
+
# `ndarray.__matmul__` carries the left operand's dtype.
|
|
314
320
|
def matmul[LeftShape: _Shape, RightShape: _Shape](
|
|
315
321
|
a: ndarray[LeftShape], b: ndarray[RightShape], /
|
|
316
322
|
) -> ndarray[matmul_shape(LeftShape, RightShape), Any]: ...
|
numpy-stubs/_shapes.pyi
CHANGED
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
# LICENSE file in the root directory of this source tree.
|
|
5
5
|
|
|
6
6
|
import shape_extensions.dsl as dsl
|
|
7
|
-
from shape_extensions import Int, IntTuple, type_shape_dsl_function
|
|
7
|
+
from shape_extensions import gufunc_broadcast, Int, IntTuple, type_shape_dsl_function
|
|
8
8
|
|
|
9
9
|
@type_shape_dsl_function
|
|
10
10
|
def int_min(a: Int, b: Int) -> Int:
|
|
@@ -25,17 +25,17 @@ def diag_extent(n: Int, k: int) -> Int:
|
|
|
25
25
|
|
|
26
26
|
@type_shape_dsl_function
|
|
27
27
|
def matmul_shape(left: IntTuple, right: IntTuple) -> IntTuple:
|
|
28
|
-
if len(left)
|
|
29
|
-
return dsl.Invalid("matmul expects
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
return
|
|
28
|
+
if len(left) == 0 or len(right) == 0:
|
|
29
|
+
return dsl.Invalid("matmul expects at least 1-D arrays")
|
|
30
|
+
operands = dsl.IntTuples((left, right))
|
|
31
|
+
if len(right) == 1:
|
|
32
|
+
spec = "(n),(n)->()"
|
|
33
|
+
return gufunc_broadcast(spec, operands)
|
|
34
|
+
if len(left) == 1:
|
|
35
|
+
spec = "(n),(n,p)->(p)"
|
|
36
|
+
return gufunc_broadcast(spec, operands)
|
|
37
|
+
spec = "(m,n),(n,p)->(m,p)"
|
|
38
|
+
return gufunc_broadcast(spec, operands)
|
|
39
39
|
|
|
40
40
|
@type_shape_dsl_function
|
|
41
41
|
def reduce_shape(
|
numpy-stubs/linalg/__init__.pyi
CHANGED
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
from typing import Literal, overload
|
|
7
7
|
|
|
8
8
|
from numpy._shapes import int_min
|
|
9
|
-
from shape_extensions import IntVar
|
|
9
|
+
from shape_extensions import Int, IntVar
|
|
10
10
|
|
|
11
11
|
from .. import ndarray
|
|
12
12
|
|
|
@@ -37,7 +37,7 @@ def svd[M: IntVar, N: IntVar, DType](
|
|
|
37
37
|
compute_uv: Literal[True] = True,
|
|
38
38
|
hermitian: Literal[False] = False,
|
|
39
39
|
) -> tuple[
|
|
40
|
-
ndarray[[M, int_min(M, N)], DType],
|
|
41
|
-
ndarray[[int_min(M, N)], DType],
|
|
42
|
-
ndarray[[int_min(M, N), N], DType],
|
|
40
|
+
ndarray[[M, int_min(Int[M], Int[N])], DType],
|
|
41
|
+
ndarray[[int_min(Int[M], Int[N])], DType],
|
|
42
|
+
ndarray[[int_min(Int[M], Int[N]), N], DType],
|
|
43
43
|
]: ...
|
{pyrefly_numpy_stubs-1.3.0.dev3.dist-info → pyrefly_numpy_stubs-1.3.0.dev4.dist-info}/METADATA
RENAMED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.5
|
|
2
2
|
Name: pyrefly-numpy-stubs
|
|
3
|
-
Version: 1.3.0.
|
|
3
|
+
Version: 1.3.0.dev4
|
|
4
4
|
Summary: NumPy type stubs with array-shape tracking, maintained by Pyrefly
|
|
5
5
|
Project-URL: homepage, https://pyrefly.org
|
|
6
6
|
Project-URL: documentation, https://pyrefly.org/en/docs/
|
|
@@ -33,7 +33,7 @@ Classifier: Programming Language :: Python
|
|
|
33
33
|
Classifier: Programming Language :: Python :: 3
|
|
34
34
|
Classifier: Typing :: Stubs Only
|
|
35
35
|
Requires-Python: >=3.12
|
|
36
|
-
Requires-Dist: pyrefly-shape-extensions==1.3.0.
|
|
36
|
+
Requires-Dist: pyrefly-shape-extensions==1.3.0.dev4
|
|
37
37
|
Description-Content-Type: text/markdown
|
|
38
38
|
|
|
39
39
|
# pyrefly-numpy-stubs
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
numpy-stubs/__init__.pyi,sha256=x6-BtE0fLxzf-5cvKq4Y5pNUtSh3CP0-D04aEeMaQkU,20566
|
|
2
|
+
numpy-stubs/_shapes.pyi,sha256=IoydstZbyxCcbeVX0CrmyVO6KXMiYLCVspif6syi_50,2171
|
|
3
|
+
numpy-stubs/py.typed,sha256=la67KBlbjXN-_-DfGNcdOcjYumVpKG_Tkw-8n5dnGB4,8
|
|
4
|
+
numpy-stubs/linalg/__init__.pyi,sha256=hbKWd6rzESYYh6ZChn6CqOJcIaSkHEkmpyxj5iihgjY,1389
|
|
5
|
+
numpy-stubs/random/__init__.pyi,sha256=1i-c5HYF01rw5Nn8CsWqaTOFVEy9oKvwj1eakn-zIH8,489
|
|
6
|
+
pyrefly_numpy_stubs-1.3.0.dev4.dist-info/METADATA,sha256=X9IbXpIWlNzLsveODwZsLnlLG4-0e56ZUV3v2rg9ISU,2314
|
|
7
|
+
pyrefly_numpy_stubs-1.3.0.dev4.dist-info/WHEEL,sha256=zOwg4jB6zX2kU910N-cMawjivD6tO8NEWvE12je1bVk,87
|
|
8
|
+
pyrefly_numpy_stubs-1.3.0.dev4.dist-info/licenses/LICENSE,sha256=2m03A-0Ry-Qr0hLHJZV8mNojy_8ZmMBfpLPZdtGljpM,1088
|
|
9
|
+
pyrefly_numpy_stubs-1.3.0.dev4.dist-info/RECORD,,
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
numpy-stubs/__init__.pyi,sha256=PoM0LHzyx_pnEDXPotBCPXTkh7KdnnUNWw90K8t2FxY,20388
|
|
2
|
-
numpy-stubs/_shapes.pyi,sha256=XQ9_RFZor1sN-JMc22k_Ot6dJLyvZuzL6Ec443xUytU,2121
|
|
3
|
-
numpy-stubs/py.typed,sha256=la67KBlbjXN-_-DfGNcdOcjYumVpKG_Tkw-8n5dnGB4,8
|
|
4
|
-
numpy-stubs/linalg/__init__.pyi,sha256=HpyX4T9dCOzgCZ5CenUdi-maii8NsLrkVW3vEDmUJIA,1354
|
|
5
|
-
numpy-stubs/random/__init__.pyi,sha256=1i-c5HYF01rw5Nn8CsWqaTOFVEy9oKvwj1eakn-zIH8,489
|
|
6
|
-
pyrefly_numpy_stubs-1.3.0.dev3.dist-info/METADATA,sha256=CTenGbnAR4JbshHE96FKURYWMWOg63Tg6CZlYVmt8fo,2314
|
|
7
|
-
pyrefly_numpy_stubs-1.3.0.dev3.dist-info/WHEEL,sha256=zOwg4jB6zX2kU910N-cMawjivD6tO8NEWvE12je1bVk,87
|
|
8
|
-
pyrefly_numpy_stubs-1.3.0.dev3.dist-info/licenses/LICENSE,sha256=2m03A-0Ry-Qr0hLHJZV8mNojy_8ZmMBfpLPZdtGljpM,1088
|
|
9
|
-
pyrefly_numpy_stubs-1.3.0.dev3.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|