pyrefly-numpy-stubs 1.4.0.dev3__py3-none-any.whl → 1.5.0.dev1__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 +816 -189
- numpy-stubs/_shapes.pyi +322 -24
- numpy-stubs/linalg/__init__.pyi +15 -8
- {pyrefly_numpy_stubs-1.4.0.dev3.dist-info → pyrefly_numpy_stubs-1.5.0.dev1.dist-info}/METADATA +6 -3
- pyrefly_numpy_stubs-1.5.0.dev1.dist-info/RECORD +9 -0
- {pyrefly_numpy_stubs-1.4.0.dev3.dist-info → pyrefly_numpy_stubs-1.5.0.dev1.dist-info}/WHEEL +1 -1
- pyrefly_numpy_stubs-1.4.0.dev3.dist-info/RECORD +0 -9
- {pyrefly_numpy_stubs-1.4.0.dev3.dist-info → pyrefly_numpy_stubs-1.5.0.dev1.dist-info}/licenses/LICENSE +0 -0
numpy-stubs/__init__.pyi
CHANGED
|
@@ -6,7 +6,17 @@
|
|
|
6
6
|
from builtins import bool as py_bool
|
|
7
7
|
from collections.abc import Iterator, Sequence
|
|
8
8
|
from types import EllipsisType
|
|
9
|
-
from typing import
|
|
9
|
+
from typing import (
|
|
10
|
+
Any,
|
|
11
|
+
Final,
|
|
12
|
+
Generic,
|
|
13
|
+
Literal,
|
|
14
|
+
Never,
|
|
15
|
+
overload,
|
|
16
|
+
Self,
|
|
17
|
+
SupportsIndex,
|
|
18
|
+
TypeVar,
|
|
19
|
+
)
|
|
10
20
|
|
|
11
21
|
import shape_extensions
|
|
12
22
|
from numpy.__config__ import (
|
|
@@ -18,6 +28,7 @@ from numpy._array_api_info import (
|
|
|
18
28
|
from numpy._core._asarray import (
|
|
19
29
|
require as require,
|
|
20
30
|
)
|
|
31
|
+
from numpy._core._internal import _ctypes
|
|
21
32
|
from numpy._core._type_aliases import (
|
|
22
33
|
sctypeDict as sctypeDict,
|
|
23
34
|
)
|
|
@@ -49,7 +60,6 @@ from numpy._core.fromnumeric import (
|
|
|
49
60
|
amax as amax,
|
|
50
61
|
amin as amin,
|
|
51
62
|
any as any,
|
|
52
|
-
argmax as argmax,
|
|
53
63
|
argpartition as argpartition,
|
|
54
64
|
argsort as argsort,
|
|
55
65
|
around as around,
|
|
@@ -182,16 +192,30 @@ from numpy._core.shape_base import (
|
|
|
182
192
|
)
|
|
183
193
|
from numpy._pytesttester import PytestTester
|
|
184
194
|
from numpy._shapes import (
|
|
195
|
+
compress_shape,
|
|
185
196
|
diag_extent,
|
|
197
|
+
diag_matrix_shape,
|
|
198
|
+
diagonal_shape,
|
|
199
|
+
dot_shape,
|
|
186
200
|
expand_dims_shape,
|
|
187
201
|
matmul_shape,
|
|
188
202
|
matvec_shape,
|
|
203
|
+
nonzero_shapes,
|
|
189
204
|
reduce_shape,
|
|
205
|
+
repeat_sequence_shape,
|
|
206
|
+
repeat_shape,
|
|
207
|
+
reshape_shape,
|
|
208
|
+
reshape_varargs_shape,
|
|
209
|
+
reverse_shape,
|
|
210
|
+
squeeze_shape,
|
|
190
211
|
stack_shape,
|
|
212
|
+
swapaxes_shape,
|
|
213
|
+
take_shape,
|
|
214
|
+
transpose_shape,
|
|
191
215
|
vecdot_shape,
|
|
192
216
|
vecmat_shape,
|
|
193
217
|
)
|
|
194
|
-
from numpy._typing import ArrayLike
|
|
218
|
+
from numpy._typing import _ArrayLikeInt_co, ArrayLike, DTypeLike
|
|
195
219
|
from numpy._typing._extended_precision import (
|
|
196
220
|
complex256 as complex256,
|
|
197
221
|
float128 as float128,
|
|
@@ -235,7 +259,6 @@ from numpy.lib._function_base_impl import (
|
|
|
235
259
|
hanning as hanning,
|
|
236
260
|
i0 as i0,
|
|
237
261
|
insert as insert,
|
|
238
|
-
interp as interp,
|
|
239
262
|
iterable as iterable,
|
|
240
263
|
kaiser as kaiser,
|
|
241
264
|
median as median,
|
|
@@ -381,7 +404,9 @@ from shape_extensions import (
|
|
|
381
404
|
Index,
|
|
382
405
|
index_shape,
|
|
383
406
|
Int,
|
|
407
|
+
IntListLiteral,
|
|
384
408
|
IntTuple,
|
|
409
|
+
IntTupleOrList,
|
|
385
410
|
IntTuples,
|
|
386
411
|
IntVar,
|
|
387
412
|
MapIntTuples,
|
|
@@ -409,30 +434,209 @@ from . import (
|
|
|
409
434
|
)
|
|
410
435
|
|
|
411
436
|
type _Shape = IntTuple
|
|
437
|
+
_ShapeT_co = TypeVar("_ShapeT_co", bound=_Shape, default=_Shape, covariant=True)
|
|
412
438
|
type _Axis = int | tuple[int, ...] | None
|
|
413
439
|
type _SingleAxis = int | None
|
|
414
440
|
type _BasicIndex = int | slice | list[int] | None | EllipsisType
|
|
441
|
+
type _NumberScalar = number | bool_ | int | float | complex
|
|
415
442
|
|
|
416
443
|
class generic:
|
|
444
|
+
@property
|
|
445
|
+
def shape(self) -> tuple[()]: ...
|
|
446
|
+
def __bool__(self, /) -> py_bool: ...
|
|
447
|
+
@overload
|
|
448
|
+
def __array__(self, dtype: None = None, /) -> ndarray[[], _dtype[Self]]: ...
|
|
449
|
+
@overload
|
|
450
|
+
def __array__[DType: _dtype](self, dtype: DType, /) -> ndarray[[], DType]: ...
|
|
417
451
|
def astype(self, dtype: Any, **kwargs: Any) -> Any: ...
|
|
418
452
|
|
|
419
|
-
class
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
453
|
+
class number(generic):
|
|
454
|
+
def __neg__(self) -> Self: ...
|
|
455
|
+
def __pos__(self) -> Self: ...
|
|
456
|
+
def __abs__(self) -> number: ...
|
|
457
|
+
# The result dtype depends on both operands.
|
|
458
|
+
def __add__(self, other: _NumberScalar, /) -> number: ...
|
|
459
|
+
def __radd__(self, other: _NumberScalar, /) -> number | complex: ...
|
|
460
|
+
def __sub__(self, other: _NumberScalar, /) -> number: ...
|
|
461
|
+
def __rsub__(self, other: _NumberScalar, /) -> number | complex: ...
|
|
462
|
+
def __mul__(self, other: _NumberScalar, /) -> number: ...
|
|
463
|
+
def __rmul__(self, other: _NumberScalar, /) -> number | complex: ...
|
|
464
|
+
def __truediv__(self, other: _NumberScalar, /) -> number: ...
|
|
465
|
+
def __rtruediv__(self, other: _NumberScalar, /) -> number | complex: ...
|
|
466
|
+
def __pow__(self, other: _NumberScalar, mod: None = None, /) -> number: ...
|
|
467
|
+
def __rpow__(
|
|
468
|
+
self, other: _NumberScalar, mod: None = None, /
|
|
469
|
+
) -> number | complex: ...
|
|
470
|
+
def __lt__(self, other: _NumberScalar, /) -> bool_: ...
|
|
471
|
+
def __le__(self, other: _NumberScalar, /) -> bool_: ...
|
|
472
|
+
def __gt__(self, other: _NumberScalar, /) -> bool_: ...
|
|
473
|
+
def __ge__(self, other: _NumberScalar, /) -> bool_: ...
|
|
474
|
+
def __int__(self, /) -> int: ...
|
|
475
|
+
def __float__(self, /) -> float: ...
|
|
476
|
+
|
|
477
|
+
class integer(number):
|
|
478
|
+
def __index__(self, /) -> int: ...
|
|
479
|
+
@overload
|
|
480
|
+
def __new__[Shape: _Shape](
|
|
481
|
+
cls: type[Self], value: ndarray[Shape, Any]
|
|
482
|
+
) -> ndarray[Shape, _dtype[Self]]: ...
|
|
483
|
+
@overload
|
|
484
|
+
def __new__[Shape: _Shape](
|
|
485
|
+
cls: type[Self], value: RegularNestedList[Shape, _ArrayScalar]
|
|
486
|
+
) -> ndarray[Shape, _dtype[Self]]: ...
|
|
487
|
+
@overload
|
|
488
|
+
def __new__(cls: type[Self], value: _ArrayScalar = ...) -> Self: ...
|
|
489
|
+
@overload
|
|
490
|
+
def __new__(
|
|
491
|
+
cls: type[Self], value: Sequence[Any]
|
|
492
|
+
) -> ndarray[IntTuple, _dtype[Self]]: ...
|
|
493
|
+
@overload
|
|
494
|
+
def __new__(cls: type[Self], value: object = ...) -> Self: ...
|
|
495
|
+
def __init__(self, value: object = ...) -> None: ...
|
|
496
|
+
|
|
497
|
+
class signedinteger(integer): ...
|
|
498
|
+
class unsignedinteger(integer): ...
|
|
499
|
+
class inexact(number): ...
|
|
500
|
+
|
|
501
|
+
class floating(inexact):
|
|
502
|
+
@overload
|
|
503
|
+
def __new__[Shape: _Shape](
|
|
504
|
+
cls: type[Self], value: ndarray[Shape, Any]
|
|
505
|
+
) -> ndarray[Shape, _dtype[Self]]: ...
|
|
506
|
+
@overload
|
|
507
|
+
def __new__[Shape: _Shape](
|
|
508
|
+
cls: type[Self], value: RegularNestedList[Shape, _ArrayScalar]
|
|
509
|
+
) -> ndarray[Shape, _dtype[Self]]: ...
|
|
510
|
+
@overload
|
|
511
|
+
def __new__(
|
|
512
|
+
cls: type[Self], value: number | bool_ | int | float | str | bytes = ...
|
|
513
|
+
) -> Self: ...
|
|
514
|
+
@overload
|
|
515
|
+
def __new__(
|
|
516
|
+
cls: type[Self], value: Sequence[Any]
|
|
517
|
+
) -> ndarray[IntTuple, _dtype[Self]]: ...
|
|
518
|
+
def __init__(
|
|
519
|
+
self, value: number | bool_ | int | float | str | bytes = ...
|
|
520
|
+
) -> None: ...
|
|
521
|
+
|
|
522
|
+
class complexfloating(inexact):
|
|
523
|
+
@overload
|
|
524
|
+
def __new__[Shape: _Shape](
|
|
525
|
+
cls: type[Self], value: ndarray[Shape, Any]
|
|
526
|
+
) -> ndarray[Shape, _dtype[Self]]: ...
|
|
527
|
+
@overload
|
|
528
|
+
def __new__[Shape: _Shape](
|
|
529
|
+
cls: type[Self], value: RegularNestedList[Shape, _ArrayScalar]
|
|
530
|
+
) -> ndarray[Shape, _dtype[Self]]: ...
|
|
531
|
+
@overload
|
|
532
|
+
def __new__(cls: type[Self], value: _NumberScalar | str | bytes = ...) -> Self: ...
|
|
533
|
+
@overload
|
|
534
|
+
def __new__(
|
|
535
|
+
cls: type[Self], value: Sequence[Any]
|
|
536
|
+
) -> ndarray[IntTuple, _dtype[Self]]: ...
|
|
537
|
+
def __init__(self, value: _NumberScalar | str | bytes = ...) -> None: ...
|
|
538
|
+
def __complex__(self, /) -> complex: ...
|
|
539
|
+
|
|
540
|
+
class bool_(generic):
|
|
541
|
+
@overload
|
|
542
|
+
def __new__[Shape: _Shape](
|
|
543
|
+
cls: type[Self], value: ndarray[Shape, Any]
|
|
544
|
+
) -> ndarray[Shape, _dtype[Self]]: ...
|
|
545
|
+
@overload
|
|
546
|
+
def __new__[Shape: _Shape](
|
|
547
|
+
cls: type[Self], value: RegularNestedList[Shape, _ArrayScalar]
|
|
548
|
+
) -> ndarray[Shape, _dtype[Self]]: ...
|
|
549
|
+
@overload
|
|
550
|
+
def __new__(cls: type[Self], value: _NumberScalar | str | bytes = ...) -> Self: ...
|
|
551
|
+
@overload
|
|
552
|
+
def __new__(
|
|
553
|
+
cls: type[Self], value: Sequence[Any]
|
|
554
|
+
) -> ndarray[IntTuple, _dtype[Self]]: ...
|
|
555
|
+
def __init__(self, value: _NumberScalar | str | bytes = ...) -> None: ...
|
|
556
|
+
def __int__(self, /) -> int: ...
|
|
557
|
+
def __float__(self, /) -> float: ...
|
|
558
|
+
def __add__(self, other: _NumberScalar, /) -> number | bool_: ...
|
|
559
|
+
def __radd__(self, other: _NumberScalar, /) -> number | bool_: ...
|
|
560
|
+
def __sub__(self, other: number | int | float | complex, /) -> number: ...
|
|
561
|
+
def __rsub__(self, other: number | int | float | complex, /) -> number: ...
|
|
562
|
+
def __mul__(self, other: _NumberScalar, /) -> number | bool_: ...
|
|
563
|
+
def __rmul__(self, other: _NumberScalar, /) -> number | bool_: ...
|
|
564
|
+
def __truediv__(self, other: _NumberScalar, /) -> number: ...
|
|
565
|
+
def __rtruediv__(self, other: _NumberScalar, /) -> number: ...
|
|
566
|
+
def __pow__(self, other: _NumberScalar, mod: None = None, /) -> number: ...
|
|
567
|
+
def __rpow__(self, other: _NumberScalar, mod: None = None, /) -> number: ...
|
|
568
|
+
|
|
569
|
+
class float16(floating): ...
|
|
570
|
+
class float32(floating): ...
|
|
425
571
|
|
|
426
|
-
|
|
572
|
+
class float64(floating):
|
|
573
|
+
# Narrow builtin-float support without inheriting float (which
|
|
574
|
+
# rewrites reflected ops like ``1j * float64`` via complex*float).
|
|
575
|
+
@overload
|
|
576
|
+
def __sub__(self, other: float, /) -> float64: ...
|
|
577
|
+
@overload
|
|
578
|
+
def __sub__(self, other: _NumberScalar, /) -> number: ...
|
|
579
|
+
@overload
|
|
580
|
+
def __rsub__(self, other: float, /) -> float64: ...
|
|
581
|
+
@overload
|
|
582
|
+
def __rsub__(self, other: _NumberScalar, /) -> number | complex: ...
|
|
583
|
+
@overload
|
|
584
|
+
def __gt__(self, other: float, /) -> bool_: ...
|
|
585
|
+
@overload
|
|
586
|
+
def __gt__(self, other: _NumberScalar, /) -> bool_: ...
|
|
587
|
+
@overload
|
|
588
|
+
def __ge__(self, other: float, /) -> bool_: ...
|
|
589
|
+
@overload
|
|
590
|
+
def __ge__(self, other: _NumberScalar, /) -> bool_: ...
|
|
591
|
+
@overload
|
|
592
|
+
def __lt__(self, other: float, /) -> bool_: ...
|
|
593
|
+
@overload
|
|
594
|
+
def __lt__(self, other: _NumberScalar, /) -> bool_: ...
|
|
595
|
+
@overload
|
|
596
|
+
def __le__(self, other: float, /) -> bool_: ...
|
|
597
|
+
@overload
|
|
598
|
+
def __le__(self, other: _NumberScalar, /) -> bool_: ...
|
|
599
|
+
|
|
600
|
+
class longdouble(floating): ...
|
|
601
|
+
class complex64(complexfloating): ...
|
|
602
|
+
class complex128(complexfloating): ...
|
|
603
|
+
class clongdouble(complexfloating): ...
|
|
604
|
+
class flexible(generic): ...
|
|
605
|
+
class character(flexible): ...
|
|
606
|
+
class bytes_(character, bytes): ...
|
|
607
|
+
class str_(character, str): ...
|
|
608
|
+
class void(flexible): ...
|
|
609
|
+
class object_(generic): ...
|
|
610
|
+
class datetime64(generic): ...
|
|
611
|
+
class timedelta64(signedinteger): ...
|
|
612
|
+
class int8(signedinteger): ...
|
|
613
|
+
class int16(signedinteger): ...
|
|
614
|
+
class int32(signedinteger): ...
|
|
615
|
+
class int64(signedinteger): ...
|
|
616
|
+
class intp(signedinteger): ...
|
|
617
|
+
class longlong(signedinteger): ...
|
|
618
|
+
class uint8(unsignedinteger): ...
|
|
619
|
+
class uint16(unsignedinteger): ...
|
|
620
|
+
class uint32(unsignedinteger): ...
|
|
621
|
+
class uint64(unsignedinteger): ...
|
|
622
|
+
class uintp(unsignedinteger): ...
|
|
623
|
+
class ulonglong(unsignedinteger): ...
|
|
624
|
+
|
|
625
|
+
type _IndexScalar = int | bool_ | integer
|
|
427
626
|
type _IndexSequence = Sequence[_IndexScalar] | Sequence[Sequence[_IndexScalar]]
|
|
428
627
|
type _ArrayIndex = (
|
|
429
628
|
_BasicIndex
|
|
430
629
|
| _IndexScalar
|
|
431
630
|
| _IndexSequence
|
|
631
|
+
| _ArrayLikeInt_co
|
|
432
632
|
| ndarray
|
|
433
|
-
| tuple[
|
|
633
|
+
| tuple[
|
|
634
|
+
_BasicIndex | _IndexScalar | _IndexSequence | _ArrayLikeInt_co | ndarray,
|
|
635
|
+
...,
|
|
636
|
+
]
|
|
434
637
|
)
|
|
435
|
-
type _ArrayScalar = None |
|
|
638
|
+
type _ArrayScalar = None | py_bool | int | float | complex | str | bytes | generic
|
|
639
|
+
_ScalarT_co = TypeVar("_ScalarT_co", bound=generic, default=Any, covariant=True)
|
|
436
640
|
|
|
437
641
|
__version__: Final[str]
|
|
438
642
|
e: Final[float]
|
|
@@ -446,13 +650,15 @@ True_: Final[bool_]
|
|
|
446
650
|
newaxis: Final[None] = None
|
|
447
651
|
test: Final[PytestTester]
|
|
448
652
|
|
|
449
|
-
class dtype[
|
|
653
|
+
class dtype(Generic[_ScalarT_co]):
|
|
450
654
|
@overload
|
|
451
655
|
def __new__[ScalarT: generic](cls, dtype: type[ScalarT]) -> dtype[ScalarT]: ...
|
|
452
656
|
@overload
|
|
453
657
|
def __new__(cls, dtype: Any = ...) -> dtype: ...
|
|
454
658
|
def __init__(self, dtype: Any = ...) -> None: ...
|
|
455
659
|
|
|
660
|
+
_DTypeT_co = TypeVar("_DTypeT_co", default=Any, covariant=True)
|
|
661
|
+
|
|
456
662
|
# `ndarray` declares a `dtype` attribute, which shadows the class above throughout
|
|
457
663
|
# its body. Annotations inside the class reach the class through this alias.
|
|
458
664
|
_dtype = dtype
|
|
@@ -461,16 +667,16 @@ class _Flags:
|
|
|
461
667
|
f_contiguous: py_bool
|
|
462
668
|
def __getitem__(self, key: str) -> py_bool: ...
|
|
463
669
|
|
|
464
|
-
class ndarray[
|
|
465
|
-
shape:
|
|
466
|
-
dtype:
|
|
670
|
+
class ndarray(Generic[_ShapeT_co, _DTypeT_co]):
|
|
671
|
+
shape: _ShapeT_co
|
|
672
|
+
dtype: _DTypeT_co
|
|
467
673
|
flags: _Flags
|
|
468
674
|
strides: tuple[int, ...]
|
|
469
675
|
@property
|
|
470
676
|
def __array_interface__(self) -> Any: ...
|
|
471
677
|
def __array__(
|
|
472
678
|
self, dtype: Any = None, copy: py_bool | None = None
|
|
473
|
-
) -> ndarray[
|
|
679
|
+
) -> ndarray[_ShapeT_co]: ...
|
|
474
680
|
def __buffer__(self, flags: int, /) -> memoryview: ...
|
|
475
681
|
@property
|
|
476
682
|
def base(self) -> Any: ...
|
|
@@ -487,16 +693,31 @@ class ndarray[Shape: _Shape = _Shape, DType = Any]:
|
|
|
487
693
|
@property
|
|
488
694
|
def size(self) -> int: ...
|
|
489
695
|
@property
|
|
490
|
-
def imag(self) -> ndarray[
|
|
696
|
+
def imag(self) -> ndarray[_ShapeT_co]: ...
|
|
491
697
|
@imag.setter
|
|
492
698
|
def imag(self, value: Any) -> None: ...
|
|
493
699
|
@property
|
|
494
|
-
def real(self) -> ndarray[
|
|
700
|
+
def real(self) -> ndarray[_ShapeT_co]: ...
|
|
495
701
|
@real.setter
|
|
496
702
|
def real(self, value: Any) -> None: ...
|
|
497
703
|
def __len__[N: IntVar, Rest: _Shape = []](
|
|
498
704
|
self: ndarray[[N, *Rest]],
|
|
499
705
|
) -> Int[N]: ...
|
|
706
|
+
# A gradual rank can match these fixed ranks; scalar-only returns would be unsafe.
|
|
707
|
+
@overload
|
|
708
|
+
def __getitem__[N: IntVar, ScalarT: generic](
|
|
709
|
+
self: ndarray[[N], _dtype[ScalarT]], key: int, /
|
|
710
|
+
) -> Any: ...
|
|
711
|
+
@overload
|
|
712
|
+
def __getitem__(self: ndarray[[], _DTypeT_co], key: tuple[()], /) -> Any: ...
|
|
713
|
+
@overload
|
|
714
|
+
def __getitem__[N: IntVar](
|
|
715
|
+
self: ndarray[[N], _DTypeT_co], key: tuple[int], /
|
|
716
|
+
) -> Any: ...
|
|
717
|
+
@overload
|
|
718
|
+
def __getitem__[N: IntVar, M: IntVar](
|
|
719
|
+
self: ndarray[[N, M], _DTypeT_co], key: tuple[int, int], /
|
|
720
|
+
) -> Any: ...
|
|
500
721
|
@overload
|
|
501
722
|
def __getitem__[
|
|
502
723
|
N: IntVar,
|
|
@@ -505,85 +726,117 @@ class ndarray[Shape: _Shape = _Shape, DType = Any]:
|
|
|
505
726
|
RowIndexScalar: (int32, int64, intp),
|
|
506
727
|
ColumnIndexScalar: (int32, int64, intp),
|
|
507
728
|
](
|
|
508
|
-
self: ndarray[[N, M],
|
|
729
|
+
self: ndarray[[N, M], _DTypeT_co],
|
|
509
730
|
key: tuple[
|
|
510
731
|
ndarray[[I], _dtype[RowIndexScalar]],
|
|
511
732
|
ndarray[[I], _dtype[ColumnIndexScalar]],
|
|
512
733
|
],
|
|
513
|
-
) -> ndarray[[I],
|
|
734
|
+
) -> ndarray[[I], _DTypeT_co]: ...
|
|
514
735
|
@overload
|
|
515
736
|
def __getitem__[I: Index](
|
|
516
|
-
self: ndarray[
|
|
517
|
-
) -> ndarray[index_shape(
|
|
737
|
+
self: ndarray[_ShapeT_co, _DTypeT_co], key: I
|
|
738
|
+
) -> ndarray[index_shape(_ShapeT_co, I), _DTypeT_co]: ...
|
|
518
739
|
# TODO(stroxler): Model general array-valued indices precisely enough to
|
|
519
740
|
# reject non-integer dtypes and incompatible advanced-index shapes.
|
|
520
741
|
@overload
|
|
521
742
|
def __getitem__(
|
|
522
|
-
self: ndarray[
|
|
743
|
+
self: ndarray[_ShapeT_co, _DTypeT_co],
|
|
523
744
|
key: _ArrayIndex,
|
|
524
|
-
) -> ndarray[IntTuple,
|
|
745
|
+
) -> ndarray[IntTuple, _DTypeT_co]: ...
|
|
525
746
|
# Assignment preserves the receiver's shape; value broadcasting is gradual.
|
|
526
747
|
def __setitem__(self, key: _ArrayIndex, value: ArrayLike, /) -> None: ...
|
|
748
|
+
# Unknown-rank arrays may yield scalars, so prefer the gradual overload.
|
|
527
749
|
@overload
|
|
528
|
-
def __iter__[N: IntVar
|
|
529
|
-
self: ndarray[[N, M, *Rest], DType], /
|
|
530
|
-
) -> Iterator[ndarray[[M, *Rest], DType]]: ...
|
|
531
|
-
# Iteration over one-dimensional arrays yields NumPy scalars.
|
|
750
|
+
def __iter__[N: IntVar](self: ndarray[[N], _DTypeT_co], /) -> Iterator[Any]: ...
|
|
532
751
|
@overload
|
|
533
|
-
def __iter__[N: IntVar
|
|
752
|
+
def __iter__[N: IntVar, M: IntVar, Rest: _Shape = []](
|
|
753
|
+
self: ndarray[[N, M, *Rest], _DTypeT_co], /
|
|
754
|
+
) -> Iterator[ndarray[[M, *Rest], _DTypeT_co]]: ...
|
|
534
755
|
def __int__(self: ndarray[[]], /) -> int: ...
|
|
756
|
+
def __index__(self: ndarray[[], _dtype[integer]], /) -> int: ...
|
|
535
757
|
def __float__(self: ndarray[[]], /) -> float: ...
|
|
536
758
|
def __complex__(self: ndarray[[]], /) -> complex: ...
|
|
537
759
|
# Only 2-D transpose is modeled for the NumPy shape-stub MVP.
|
|
538
760
|
@property
|
|
539
761
|
def T[N: IntVar, P: IntVar](
|
|
540
|
-
self: ndarray[[N, P],
|
|
541
|
-
) -> ndarray[[P, N],
|
|
762
|
+
self: ndarray[[N, P], _DTypeT_co],
|
|
763
|
+
) -> ndarray[[P, N], _DTypeT_co]: ...
|
|
542
764
|
# Unpacking preserves gradual array shapes instead of using the scalar default.
|
|
765
|
+
@overload
|
|
543
766
|
def __add__[OtherShape: _Shape = []](
|
|
544
767
|
self, other: ndarray[[*OtherShape]] | int | float
|
|
545
|
-
) -> ndarray[_broadcast_shape(
|
|
768
|
+
) -> ndarray[_broadcast_shape(_ShapeT_co, OtherShape), _DTypeT_co]: ...
|
|
769
|
+
@overload
|
|
770
|
+
def __add__(self, other: complex | number | bool_) -> ndarray[_ShapeT_co]: ...
|
|
771
|
+
@overload
|
|
546
772
|
def __radd__[OtherShape: _Shape = []](
|
|
547
773
|
self, other: ndarray[[*OtherShape]] | int | float
|
|
548
|
-
) -> ndarray[_broadcast_shape(
|
|
774
|
+
) -> ndarray[_broadcast_shape(_ShapeT_co, OtherShape), _DTypeT_co]: ...
|
|
775
|
+
@overload
|
|
776
|
+
def __radd__(self, other: complex | number | bool_) -> ndarray[_ShapeT_co]: ...
|
|
777
|
+
@overload
|
|
549
778
|
def __sub__[OtherShape: _Shape = []](
|
|
550
779
|
self, other: ndarray[[*OtherShape]] | int | float
|
|
551
|
-
) -> ndarray[_broadcast_shape(
|
|
780
|
+
) -> ndarray[_broadcast_shape(_ShapeT_co, OtherShape), _DTypeT_co]: ...
|
|
781
|
+
@overload
|
|
782
|
+
def __sub__(self, other: complex | number | bool_) -> ndarray[_ShapeT_co]: ...
|
|
783
|
+
@overload
|
|
552
784
|
def __rsub__[OtherShape: _Shape = []](
|
|
553
785
|
self, other: ndarray[[*OtherShape]] | int | float
|
|
554
|
-
) -> ndarray[_broadcast_shape(
|
|
786
|
+
) -> ndarray[_broadcast_shape(_ShapeT_co, OtherShape), _DTypeT_co]: ...
|
|
787
|
+
@overload
|
|
788
|
+
def __rsub__(self, other: complex | number | bool_) -> ndarray[_ShapeT_co]: ...
|
|
789
|
+
@overload
|
|
555
790
|
def __truediv__[OtherShape: _Shape = []](
|
|
556
791
|
self, other: ndarray[[*OtherShape]] | int | float
|
|
557
|
-
) -> ndarray[_broadcast_shape(
|
|
792
|
+
) -> ndarray[_broadcast_shape(_ShapeT_co, OtherShape), _DTypeT_co]: ...
|
|
793
|
+
@overload
|
|
794
|
+
def __truediv__(self, other: complex | number | bool_) -> ndarray[_ShapeT_co]: ...
|
|
795
|
+
@overload
|
|
558
796
|
def __rtruediv__[OtherShape: _Shape = []](
|
|
559
797
|
self, other: ndarray[[*OtherShape]] | int | float
|
|
560
|
-
) -> ndarray[_broadcast_shape(
|
|
798
|
+
) -> ndarray[_broadcast_shape(_ShapeT_co, OtherShape), _DTypeT_co]: ...
|
|
799
|
+
@overload
|
|
800
|
+
def __rtruediv__(self, other: complex | number | bool_) -> ndarray[_ShapeT_co]: ...
|
|
801
|
+
@overload
|
|
561
802
|
def __mul__[OtherShape: _Shape = []](
|
|
562
803
|
self, other: ndarray[[*OtherShape]] | int | float
|
|
563
|
-
) -> ndarray[_broadcast_shape(
|
|
804
|
+
) -> ndarray[_broadcast_shape(_ShapeT_co, OtherShape), _DTypeT_co]: ...
|
|
805
|
+
@overload
|
|
806
|
+
def __mul__(self, other: complex | number | bool_) -> ndarray[_ShapeT_co]: ...
|
|
807
|
+
@overload
|
|
564
808
|
def __rmul__[OtherShape: _Shape = []](
|
|
565
809
|
self, other: ndarray[[*OtherShape]] | int | float
|
|
566
|
-
) -> ndarray[_broadcast_shape(
|
|
810
|
+
) -> ndarray[_broadcast_shape(_ShapeT_co, OtherShape), _DTypeT_co]: ...
|
|
811
|
+
@overload
|
|
812
|
+
def __rmul__(self, other: complex | number | bool_) -> ndarray[_ShapeT_co]: ...
|
|
567
813
|
def __floordiv__[OtherShape: _Shape = []](
|
|
568
814
|
self, other: ndarray[[*OtherShape]] | int | float
|
|
569
|
-
) -> ndarray[_broadcast_shape(
|
|
815
|
+
) -> ndarray[_broadcast_shape(_ShapeT_co, OtherShape), _DTypeT_co]: ...
|
|
570
816
|
def __rfloordiv__[OtherShape: _Shape = []](
|
|
571
817
|
self, other: ndarray[[*OtherShape]] | int | float
|
|
572
|
-
) -> ndarray[_broadcast_shape(
|
|
818
|
+
) -> ndarray[_broadcast_shape(_ShapeT_co, OtherShape), _DTypeT_co]: ...
|
|
573
819
|
def __mod__[OtherShape: _Shape = []](
|
|
574
820
|
self, other: ndarray[[*OtherShape]] | int | float
|
|
575
|
-
) -> ndarray[_broadcast_shape(
|
|
821
|
+
) -> ndarray[_broadcast_shape(_ShapeT_co, OtherShape), _DTypeT_co]: ...
|
|
576
822
|
def __rmod__[OtherShape: _Shape = []](
|
|
577
823
|
self, other: ndarray[[*OtherShape]] | int | float
|
|
578
|
-
) -> ndarray[_broadcast_shape(
|
|
579
|
-
def __neg__(self) -> ndarray[
|
|
580
|
-
def __pos__(self) -> ndarray[
|
|
824
|
+
) -> ndarray[_broadcast_shape(_ShapeT_co, OtherShape), _DTypeT_co]: ...
|
|
825
|
+
def __neg__(self) -> ndarray[_ShapeT_co, _DTypeT_co]: ...
|
|
826
|
+
def __pos__(self) -> ndarray[_ShapeT_co, _DTypeT_co]: ...
|
|
827
|
+
def __abs__(self, /) -> ndarray[_ShapeT_co]: ...
|
|
828
|
+
@overload
|
|
581
829
|
def __pow__[OtherShape: _Shape = []](
|
|
582
830
|
self, other: ndarray[[*OtherShape]] | int | float
|
|
583
|
-
) -> ndarray[_broadcast_shape(
|
|
831
|
+
) -> ndarray[_broadcast_shape(_ShapeT_co, OtherShape), _DTypeT_co]: ...
|
|
832
|
+
@overload
|
|
833
|
+
def __pow__(self, other: complex | number | bool_) -> ndarray[_ShapeT_co]: ...
|
|
834
|
+
@overload
|
|
584
835
|
def __rpow__[OtherShape: _Shape = []](
|
|
585
836
|
self, other: ndarray[[*OtherShape]] | int | float
|
|
586
|
-
) -> ndarray[_broadcast_shape(
|
|
837
|
+
) -> ndarray[_broadcast_shape(_ShapeT_co, OtherShape), _DTypeT_co]: ...
|
|
838
|
+
@overload
|
|
839
|
+
def __rpow__(self, other: complex | number | bool_) -> ndarray[_ShapeT_co]: ...
|
|
587
840
|
# Scalar results also satisfy Python's truth-valued comparison protocols.
|
|
588
841
|
@overload
|
|
589
842
|
def __lt__(self: ndarray[[]], other: Any, /) -> Any: ...
|
|
@@ -592,7 +845,7 @@ class ndarray[Shape: _Shape = _Shape, DType = Any]:
|
|
|
592
845
|
self,
|
|
593
846
|
other: ndarray[[*OtherShape]] | int | float | complex | str | bytes | generic,
|
|
594
847
|
/,
|
|
595
|
-
) -> ndarray[_broadcast_shape(
|
|
848
|
+
) -> ndarray[_broadcast_shape(_ShapeT_co, OtherShape), _dtype[bool_]]: ...
|
|
596
849
|
@overload
|
|
597
850
|
def __lt__(self, other: ArrayLike, /) -> ndarray[IntTuple, _dtype[bool_]]: ...
|
|
598
851
|
@overload
|
|
@@ -602,7 +855,7 @@ class ndarray[Shape: _Shape = _Shape, DType = Any]:
|
|
|
602
855
|
self,
|
|
603
856
|
other: ndarray[[*OtherShape]] | int | float | complex | str | bytes | generic,
|
|
604
857
|
/,
|
|
605
|
-
) -> ndarray[_broadcast_shape(
|
|
858
|
+
) -> ndarray[_broadcast_shape(_ShapeT_co, OtherShape), _dtype[bool_]]: ...
|
|
606
859
|
@overload
|
|
607
860
|
def __le__(self, other: ArrayLike, /) -> ndarray[IntTuple, _dtype[bool_]]: ...
|
|
608
861
|
@overload
|
|
@@ -612,7 +865,7 @@ class ndarray[Shape: _Shape = _Shape, DType = Any]:
|
|
|
612
865
|
self,
|
|
613
866
|
other: ndarray[[*OtherShape]] | int | float | complex | str | bytes | generic,
|
|
614
867
|
/,
|
|
615
|
-
) -> ndarray[_broadcast_shape(
|
|
868
|
+
) -> ndarray[_broadcast_shape(_ShapeT_co, OtherShape), _dtype[bool_]]: ...
|
|
616
869
|
@overload
|
|
617
870
|
def __gt__(self, other: ArrayLike, /) -> ndarray[IntTuple, _dtype[bool_]]: ...
|
|
618
871
|
@overload
|
|
@@ -622,7 +875,7 @@ class ndarray[Shape: _Shape = _Shape, DType = Any]:
|
|
|
622
875
|
self,
|
|
623
876
|
other: ndarray[[*OtherShape]] | int | float | complex | str | bytes | generic,
|
|
624
877
|
/,
|
|
625
|
-
) -> ndarray[_broadcast_shape(
|
|
878
|
+
) -> ndarray[_broadcast_shape(_ShapeT_co, OtherShape), _dtype[bool_]]: ...
|
|
626
879
|
@overload
|
|
627
880
|
def __ge__(self, other: ArrayLike, /) -> ndarray[IntTuple, _dtype[bool_]]: ...
|
|
628
881
|
@overload
|
|
@@ -632,7 +885,7 @@ class ndarray[Shape: _Shape = _Shape, DType = Any]:
|
|
|
632
885
|
self,
|
|
633
886
|
other: ndarray[[*OtherShape]] | int | float | complex | str | bytes | generic,
|
|
634
887
|
/,
|
|
635
|
-
) -> ndarray[_broadcast_shape(
|
|
888
|
+
) -> ndarray[_broadcast_shape(_ShapeT_co, OtherShape), _dtype[bool_]]: ...
|
|
636
889
|
@overload
|
|
637
890
|
def __eq__(self, other: ArrayLike, /) -> ndarray[IntTuple, _dtype[bool_]]: ...
|
|
638
891
|
@overload
|
|
@@ -642,55 +895,57 @@ class ndarray[Shape: _Shape = _Shape, DType = Any]:
|
|
|
642
895
|
self,
|
|
643
896
|
other: ndarray[[*OtherShape]] | int | float | complex | str | bytes | generic,
|
|
644
897
|
/,
|
|
645
|
-
) -> ndarray[_broadcast_shape(
|
|
898
|
+
) -> ndarray[_broadcast_shape(_ShapeT_co, OtherShape), _dtype[bool_]]: ...
|
|
646
899
|
@overload
|
|
647
900
|
def __ne__(self, other: ArrayLike, /) -> ndarray[IntTuple, _dtype[bool_]]: ...
|
|
648
|
-
def __invert__(self) -> ndarray[
|
|
901
|
+
def __invert__(self) -> ndarray[_ShapeT_co, _DTypeT_co]: ...
|
|
649
902
|
def __and__[OtherShape: _Shape = []](
|
|
650
903
|
self, other: ndarray[[*OtherShape]] | _IndexScalar, /
|
|
651
|
-
) -> ndarray[_broadcast_shape(
|
|
904
|
+
) -> ndarray[_broadcast_shape(_ShapeT_co, OtherShape)]: ...
|
|
652
905
|
def __or__[OtherShape: _Shape = []](
|
|
653
906
|
self, other: ndarray[[*OtherShape]] | _IndexScalar, /
|
|
654
|
-
) -> ndarray[_broadcast_shape(
|
|
907
|
+
) -> ndarray[_broadcast_shape(_ShapeT_co, OtherShape)]: ...
|
|
655
908
|
def __xor__[OtherShape: _Shape = []](
|
|
656
909
|
self, other: ndarray[[*OtherShape]] | _IndexScalar, /
|
|
657
|
-
) -> ndarray[_broadcast_shape(
|
|
910
|
+
) -> ndarray[_broadcast_shape(_ShapeT_co, OtherShape)]: ...
|
|
658
911
|
def __rand__[OtherShape: _Shape = []](
|
|
659
912
|
self, other: ndarray[[*OtherShape]] | _IndexScalar, /
|
|
660
|
-
) -> ndarray[_broadcast_shape(
|
|
913
|
+
) -> ndarray[_broadcast_shape(_ShapeT_co, OtherShape)]: ...
|
|
661
914
|
def __ror__[OtherShape: _Shape = []](
|
|
662
915
|
self, other: ndarray[[*OtherShape]] | _IndexScalar, /
|
|
663
|
-
) -> ndarray[_broadcast_shape(
|
|
916
|
+
) -> ndarray[_broadcast_shape(_ShapeT_co, OtherShape)]: ...
|
|
664
917
|
def __rxor__[OtherShape: _Shape = []](
|
|
665
918
|
self, other: ndarray[[*OtherShape]] | _IndexScalar, /
|
|
666
|
-
) -> ndarray[_broadcast_shape(
|
|
919
|
+
) -> ndarray[_broadcast_shape(_ShapeT_co, OtherShape)]: ...
|
|
667
920
|
def __matmul__[OtherShape: _Shape](
|
|
668
921
|
self, other: ndarray[OtherShape]
|
|
669
|
-
) -> ndarray[matmul_shape(
|
|
922
|
+
) -> ndarray[matmul_shape(_ShapeT_co, OtherShape), _DTypeT_co]: ...
|
|
670
923
|
def mean[Axis: Flag[_Axis], KeepDims: Flag[py_bool]](
|
|
671
924
|
self,
|
|
672
925
|
axis: Axis = None,
|
|
673
926
|
*,
|
|
674
927
|
keepdims: KeepDims = False,
|
|
675
|
-
) -> ndarray[reduce_shape(
|
|
928
|
+
) -> ndarray[reduce_shape(_ShapeT_co, Axis, KeepDims), _DTypeT_co]: ...
|
|
676
929
|
def sum[Axis: Flag[_Axis], KeepDims: Flag[py_bool]](
|
|
677
930
|
self,
|
|
678
931
|
axis: Axis = None,
|
|
679
932
|
*,
|
|
680
933
|
keepdims: KeepDims = False,
|
|
681
|
-
) -> ndarray[reduce_shape(
|
|
934
|
+
) -> ndarray[reduce_shape(_ShapeT_co, Axis, KeepDims), _DTypeT_co]: ...
|
|
682
935
|
def min[Axis: Flag[_Axis], KeepDims: Flag[py_bool]](
|
|
683
936
|
self,
|
|
684
937
|
axis: Axis = None,
|
|
685
938
|
*,
|
|
686
939
|
keepdims: KeepDims = False,
|
|
687
|
-
|
|
940
|
+
initial: _ArrayScalar = ...,
|
|
941
|
+
) -> ndarray[reduce_shape(_ShapeT_co, Axis, KeepDims), _DTypeT_co]: ...
|
|
688
942
|
def max[Axis: Flag[_Axis], KeepDims: Flag[py_bool]](
|
|
689
943
|
self,
|
|
690
944
|
axis: Axis = None,
|
|
691
945
|
*,
|
|
692
946
|
keepdims: KeepDims = False,
|
|
693
|
-
|
|
947
|
+
initial: _ArrayScalar = ...,
|
|
948
|
+
) -> ndarray[reduce_shape(_ShapeT_co, Axis, KeepDims), _DTypeT_co]: ...
|
|
694
949
|
def all[Axis: Flag[_Axis], KeepDims: Flag[py_bool]](
|
|
695
950
|
self,
|
|
696
951
|
axis: Axis = None,
|
|
@@ -698,7 +953,7 @@ class ndarray[Shape: _Shape = _Shape, DType = Any]:
|
|
|
698
953
|
keepdims: KeepDims = False,
|
|
699
954
|
*,
|
|
700
955
|
where: Any = True,
|
|
701
|
-
) -> ndarray[reduce_shape(
|
|
956
|
+
) -> ndarray[reduce_shape(_ShapeT_co, Axis, KeepDims), _dtype[bool_]]: ...
|
|
702
957
|
def any[Axis: Flag[_Axis], KeepDims: Flag[py_bool]](
|
|
703
958
|
self,
|
|
704
959
|
axis: Axis = None,
|
|
@@ -706,21 +961,31 @@ class ndarray[Shape: _Shape = _Shape, DType = Any]:
|
|
|
706
961
|
keepdims: KeepDims = False,
|
|
707
962
|
*,
|
|
708
963
|
where: Any = True,
|
|
709
|
-
) -> ndarray[reduce_shape(
|
|
964
|
+
) -> ndarray[reduce_shape(_ShapeT_co, Axis, KeepDims), _dtype[bool_]]: ...
|
|
965
|
+
@overload
|
|
966
|
+
def argmax(
|
|
967
|
+
self, axis: None = None, out: None = None, *, keepdims: Literal[False] = False
|
|
968
|
+
) -> intp: ...
|
|
969
|
+
@overload
|
|
710
970
|
def argmax[Axis: Flag[_SingleAxis], KeepDims: Flag[py_bool]](
|
|
711
971
|
self,
|
|
712
972
|
axis: Axis = None,
|
|
713
973
|
out: Any = None,
|
|
714
974
|
*,
|
|
715
975
|
keepdims: KeepDims = False,
|
|
716
|
-
) -> ndarray[reduce_shape(
|
|
976
|
+
) -> ndarray[reduce_shape(_ShapeT_co, Axis, KeepDims), _dtype[intp]]: ...
|
|
977
|
+
@overload
|
|
978
|
+
def argmin(
|
|
979
|
+
self, axis: None = None, out: None = None, *, keepdims: Literal[False] = False
|
|
980
|
+
) -> intp: ...
|
|
981
|
+
@overload
|
|
717
982
|
def argmin[Axis: Flag[_SingleAxis], KeepDims: Flag[py_bool]](
|
|
718
983
|
self,
|
|
719
984
|
axis: Axis = None,
|
|
720
985
|
out: Any = None,
|
|
721
986
|
*,
|
|
722
987
|
keepdims: KeepDims = False,
|
|
723
|
-
) -> ndarray[reduce_shape(
|
|
988
|
+
) -> ndarray[reduce_shape(_ShapeT_co, Axis, KeepDims), _dtype[intp]]: ...
|
|
724
989
|
def prod[Axis: Flag[_Axis], KeepDims: Flag[py_bool]](
|
|
725
990
|
self,
|
|
726
991
|
axis: Axis = None,
|
|
@@ -730,7 +995,7 @@ class ndarray[Shape: _Shape = _Shape, DType = Any]:
|
|
|
730
995
|
keepdims: KeepDims = False,
|
|
731
996
|
initial: Any = None,
|
|
732
997
|
where: Any = True,
|
|
733
|
-
) -> ndarray[reduce_shape(
|
|
998
|
+
) -> ndarray[reduce_shape(_ShapeT_co, Axis, KeepDims)]: ...
|
|
734
999
|
def std[Axis: Flag[_Axis], KeepDims: Flag[py_bool]](
|
|
735
1000
|
self,
|
|
736
1001
|
axis: Axis = None,
|
|
@@ -742,7 +1007,7 @@ class ndarray[Shape: _Shape = _Shape, DType = Any]:
|
|
|
742
1007
|
where: Any = True,
|
|
743
1008
|
mean: Any = None,
|
|
744
1009
|
correction: Any = None,
|
|
745
|
-
) -> ndarray[reduce_shape(
|
|
1010
|
+
) -> ndarray[reduce_shape(_ShapeT_co, Axis, KeepDims)]: ...
|
|
746
1011
|
def var[Axis: Flag[_Axis], KeepDims: Flag[py_bool]](
|
|
747
1012
|
self,
|
|
748
1013
|
axis: Axis = None,
|
|
@@ -754,7 +1019,7 @@ class ndarray[Shape: _Shape = _Shape, DType = Any]:
|
|
|
754
1019
|
where: Any = True,
|
|
755
1020
|
mean: Any = None,
|
|
756
1021
|
correction: Any = None,
|
|
757
|
-
) -> ndarray[reduce_shape(
|
|
1022
|
+
) -> ndarray[reduce_shape(_ShapeT_co, Axis, KeepDims)]: ...
|
|
758
1023
|
@overload
|
|
759
1024
|
def argpartition(
|
|
760
1025
|
self,
|
|
@@ -770,7 +1035,7 @@ class ndarray[Shape: _Shape = _Shape, DType = Any]:
|
|
|
770
1035
|
axis: int = -1,
|
|
771
1036
|
kind: str = "introselect",
|
|
772
1037
|
order: Any = None,
|
|
773
|
-
) -> ndarray[
|
|
1038
|
+
) -> ndarray[_ShapeT_co, _dtype[intp]]: ...
|
|
774
1039
|
@overload
|
|
775
1040
|
def argsort(
|
|
776
1041
|
self,
|
|
@@ -790,7 +1055,7 @@ class ndarray[Shape: _Shape = _Shape, DType = Any]:
|
|
|
790
1055
|
*,
|
|
791
1056
|
stable: py_bool | None = None,
|
|
792
1057
|
descending: py_bool | None = None,
|
|
793
|
-
) -> ndarray[
|
|
1058
|
+
) -> ndarray[_ShapeT_co, _dtype[intp]]: ...
|
|
794
1059
|
@overload
|
|
795
1060
|
def astype[ScalarT: generic](
|
|
796
1061
|
self,
|
|
@@ -799,7 +1064,7 @@ class ndarray[Shape: _Shape = _Shape, DType = Any]:
|
|
|
799
1064
|
casting: str = "unsafe",
|
|
800
1065
|
subok: py_bool = True,
|
|
801
1066
|
copy: py_bool = True,
|
|
802
|
-
) -> ndarray[
|
|
1067
|
+
) -> ndarray[_ShapeT_co, _dtype[ScalarT]]: ...
|
|
803
1068
|
@overload
|
|
804
1069
|
def astype(
|
|
805
1070
|
self,
|
|
@@ -808,14 +1073,14 @@ class ndarray[Shape: _Shape = _Shape, DType = Any]:
|
|
|
808
1073
|
casting: str = "unsafe",
|
|
809
1074
|
subok: py_bool = True,
|
|
810
1075
|
copy: py_bool = True,
|
|
811
|
-
) -> ndarray[
|
|
812
|
-
def byteswap(self, inplace: py_bool = False) -> ndarray[
|
|
1076
|
+
) -> ndarray[_ShapeT_co]: ...
|
|
1077
|
+
def byteswap(self, inplace: py_bool = False) -> ndarray[_ShapeT_co, _DTypeT_co]: ...
|
|
813
1078
|
def clip(
|
|
814
1079
|
self, min: Any = None, max: Any = None, out: Any = None, **kwargs: Any
|
|
815
|
-
) -> ndarray[
|
|
816
|
-
def conj(self) -> ndarray[
|
|
817
|
-
def conjugate(self) -> ndarray[
|
|
818
|
-
def copy(self, order: str = "C") -> ndarray[
|
|
1080
|
+
) -> ndarray[_ShapeT_co, _DTypeT_co]: ...
|
|
1081
|
+
def conj(self) -> ndarray[_ShapeT_co, _DTypeT_co]: ...
|
|
1082
|
+
def conjugate(self) -> ndarray[_ShapeT_co, _DTypeT_co]: ...
|
|
1083
|
+
def copy(self, order: str = "C") -> ndarray[_ShapeT_co, _DTypeT_co]: ...
|
|
819
1084
|
@overload
|
|
820
1085
|
def cumprod(
|
|
821
1086
|
self, axis: None = None, dtype: Any = None, out: Any = None
|
|
@@ -823,7 +1088,7 @@ class ndarray[Shape: _Shape = _Shape, DType = Any]:
|
|
|
823
1088
|
@overload
|
|
824
1089
|
def cumprod(
|
|
825
1090
|
self, axis: int, dtype: Any = None, out: Any = None
|
|
826
|
-
) -> ndarray[
|
|
1091
|
+
) -> ndarray[_ShapeT_co]: ...
|
|
827
1092
|
@overload
|
|
828
1093
|
def cumsum(
|
|
829
1094
|
self, axis: None = None, dtype: Any = None, out: Any = None
|
|
@@ -831,12 +1096,12 @@ class ndarray[Shape: _Shape = _Shape, DType = Any]:
|
|
|
831
1096
|
@overload
|
|
832
1097
|
def cumsum(
|
|
833
1098
|
self, axis: int, dtype: Any = None, out: Any = None
|
|
834
|
-
) -> ndarray[
|
|
1099
|
+
) -> ndarray[_ShapeT_co]: ...
|
|
835
1100
|
def dump(self, file: Any) -> None: ...
|
|
836
1101
|
def dumps(self) -> bytes: ...
|
|
837
1102
|
def fill(self, value: Any, /) -> None: ...
|
|
838
|
-
def flatten(self, order: str = "C") -> ndarray[[int],
|
|
839
|
-
def getfield(self, dtype: Any, offset: int = 0) -> ndarray[
|
|
1103
|
+
def flatten(self, order: str = "C") -> ndarray[[int], _DTypeT_co]: ...
|
|
1104
|
+
def getfield(self, dtype: Any, offset: int = 0) -> ndarray[_ShapeT_co]: ...
|
|
840
1105
|
def item(self, *args: Any) -> Any: ...
|
|
841
1106
|
def partition(
|
|
842
1107
|
self,
|
|
@@ -846,10 +1111,17 @@ class ndarray[Shape: _Shape = _Shape, DType = Any]:
|
|
|
846
1111
|
order: Any = None,
|
|
847
1112
|
) -> None: ...
|
|
848
1113
|
def put(self, indices: Any, values: Any, mode: str = "raise") -> None: ...
|
|
849
|
-
def ravel(self, order: str = "C") -> ndarray[[int],
|
|
850
|
-
|
|
851
|
-
|
|
852
|
-
|
|
1114
|
+
def ravel(self, order: str = "C") -> ndarray[[int], _DTypeT_co]: ...
|
|
1115
|
+
def resize(self, *, not_usable_with_shape_types: Never) -> None:
|
|
1116
|
+
"""Unsupported: resizing changes the receiver's shape in place.
|
|
1117
|
+
|
|
1118
|
+
A statically typed array cannot acquire a new shape type after a method call.
|
|
1119
|
+
Create a new array instead of resizing an existing one.
|
|
1120
|
+
"""
|
|
1121
|
+
...
|
|
1122
|
+
def round(
|
|
1123
|
+
self, decimals: int = 0, out: Any = None
|
|
1124
|
+
) -> ndarray[_ShapeT_co, _DTypeT_co]: ...
|
|
853
1125
|
def setfield(self, val: Any, dtype: Any, offset: int = 0) -> None: ...
|
|
854
1126
|
def setflags(
|
|
855
1127
|
self,
|
|
@@ -867,29 +1139,279 @@ class ndarray[Shape: _Shape = _Shape, DType = Any]:
|
|
|
867
1139
|
) -> None: ...
|
|
868
1140
|
def to_device(
|
|
869
1141
|
self, device: Literal["cpu"], /, *, stream: Any = None
|
|
870
|
-
) -> ndarray[
|
|
1142
|
+
) -> ndarray[_ShapeT_co, _DTypeT_co]: ...
|
|
871
1143
|
def tobytes(self, order: str = "C") -> bytes: ...
|
|
872
1144
|
def tofile(self, fid: Any, sep: str = "", format: str = "%s") -> None: ...
|
|
873
1145
|
def tolist(self) -> Any: ...
|
|
874
1146
|
|
|
875
|
-
# TODO(stroxler):
|
|
876
|
-
|
|
877
|
-
|
|
878
|
-
|
|
879
|
-
|
|
880
|
-
|
|
881
|
-
|
|
882
|
-
|
|
883
|
-
|
|
884
|
-
|
|
885
|
-
|
|
886
|
-
|
|
887
|
-
|
|
888
|
-
|
|
889
|
-
|
|
890
|
-
|
|
891
|
-
|
|
892
|
-
|
|
1147
|
+
# TODO(stroxler): Model broadcast choices and condition-dependent compress lengths.
|
|
1148
|
+
@overload
|
|
1149
|
+
def choose(
|
|
1150
|
+
self,
|
|
1151
|
+
choices: ArrayLike,
|
|
1152
|
+
out: None = None,
|
|
1153
|
+
mode: Literal["raise", "wrap", "clip"] = "raise",
|
|
1154
|
+
) -> ndarray[IntTuple]: ...
|
|
1155
|
+
@overload
|
|
1156
|
+
def choose[Out: ndarray](
|
|
1157
|
+
self,
|
|
1158
|
+
choices: ArrayLike,
|
|
1159
|
+
out: Out,
|
|
1160
|
+
mode: Literal["raise", "wrap", "clip"] = "raise",
|
|
1161
|
+
) -> Out: ...
|
|
1162
|
+
@overload
|
|
1163
|
+
def compress[Axis: Flag[int | None]](
|
|
1164
|
+
self, condition: Sequence[int] | ndarray, axis: Axis = None, out: None = None
|
|
1165
|
+
) -> ndarray[compress_shape(_ShapeT_co, Axis), _DTypeT_co]: ...
|
|
1166
|
+
@overload
|
|
1167
|
+
def compress[Out: ndarray](
|
|
1168
|
+
self,
|
|
1169
|
+
condition: Sequence[int] | ndarray,
|
|
1170
|
+
axis: int | None,
|
|
1171
|
+
out: Out,
|
|
1172
|
+
) -> Out: ...
|
|
1173
|
+
@overload
|
|
1174
|
+
def compress[Out: ndarray](
|
|
1175
|
+
self,
|
|
1176
|
+
condition: Sequence[int] | ndarray,
|
|
1177
|
+
axis: int | None = None,
|
|
1178
|
+
*,
|
|
1179
|
+
out: Out,
|
|
1180
|
+
) -> Out: ...
|
|
1181
|
+
@property
|
|
1182
|
+
def ctypes(self) -> _ctypes[int]: ...
|
|
1183
|
+
def diagonal[Offset: Flag[int], First: Flag[int], Second: Flag[int]](
|
|
1184
|
+
self, offset: Offset = 0, axis1: First = 0, axis2: Second = 1
|
|
1185
|
+
) -> ndarray[
|
|
1186
|
+
diagonal_shape(_ShapeT_co, First, Second, True, Offset), _DTypeT_co
|
|
1187
|
+
]: ...
|
|
1188
|
+
@overload
|
|
1189
|
+
def dot[N: IntVar](
|
|
1190
|
+
self: ndarray[[N], _DTypeT_co], b: ndarray[[N]], /, out: None = None
|
|
1191
|
+
) -> generic: ...
|
|
1192
|
+
@overload
|
|
1193
|
+
def dot(self: ndarray[[]], b: _ArrayScalar, /, out: None = None) -> generic: ...
|
|
1194
|
+
@overload
|
|
1195
|
+
def dot[Right: IntTuple](
|
|
1196
|
+
self, b: ndarray[Right], /, out: None = None
|
|
1197
|
+
) -> ndarray[dot_shape(_ShapeT_co, Right)]: ...
|
|
1198
|
+
@overload
|
|
1199
|
+
def dot[Right: IntTuple](
|
|
1200
|
+
self,
|
|
1201
|
+
b: RegularNestedList[Right, _ArrayScalar],
|
|
1202
|
+
/,
|
|
1203
|
+
out: None = None,
|
|
1204
|
+
) -> ndarray[dot_shape(_ShapeT_co, Right)]: ...
|
|
1205
|
+
@overload
|
|
1206
|
+
def dot(
|
|
1207
|
+
self, b: int | float | complex | generic, /, out: None = None
|
|
1208
|
+
) -> ndarray[_ShapeT_co]: ...
|
|
1209
|
+
@overload
|
|
1210
|
+
def dot[Out: ndarray](self, b: ArrayLike, /, out: Out) -> Out: ...
|
|
1211
|
+
# TODO(stroxler): Infer scalar dtype promotion for vector inner products.
|
|
1212
|
+
@property
|
|
1213
|
+
def flat(self) -> flatiter[ndarray[_ShapeT_co, _DTypeT_co]]: ...
|
|
1214
|
+
@property
|
|
1215
|
+
def mT(self) -> ndarray[swapaxes_shape(_ShapeT_co, -1, -2), _DTypeT_co]: ...
|
|
1216
|
+
def nonzero(
|
|
1217
|
+
self,
|
|
1218
|
+
) -> MapIntTuples[
|
|
1219
|
+
lambda S: ndarray[S, dtype[intp]], nonzero_shapes(_ShapeT_co)
|
|
1220
|
+
]: ...
|
|
1221
|
+
@overload
|
|
1222
|
+
def repeat[Repeats: Int, Axis: Flag[int | None]](
|
|
1223
|
+
self, repeats: Repeats, /, axis: Axis = None
|
|
1224
|
+
) -> ndarray[repeat_shape(_ShapeT_co, Repeats, Axis), _DTypeT_co]: ...
|
|
1225
|
+
@overload
|
|
1226
|
+
def repeat[Repeats: IntTuple, Axis: Flag[int | None]](
|
|
1227
|
+
self, repeats: Repeats | IntListLiteral[Repeats], /, axis: Axis = None
|
|
1228
|
+
) -> ndarray[repeat_sequence_shape(_ShapeT_co, Repeats, Axis), _DTypeT_co]: ...
|
|
1229
|
+
@overload
|
|
1230
|
+
def repeat[Axis: Flag[int | None]](
|
|
1231
|
+
self, repeats: Sequence[int] | ndarray, /, axis: Axis = None
|
|
1232
|
+
) -> ndarray[repeat_shape(_ShapeT_co, Int, Axis), _DTypeT_co]: ...
|
|
1233
|
+
@overload
|
|
1234
|
+
def reshape(
|
|
1235
|
+
self,
|
|
1236
|
+
shape: None,
|
|
1237
|
+
/,
|
|
1238
|
+
*,
|
|
1239
|
+
order: Literal["C", "F", "A"] = "C",
|
|
1240
|
+
copy: py_bool | None = None,
|
|
1241
|
+
) -> ndarray[_ShapeT_co, _DTypeT_co]: ...
|
|
1242
|
+
@overload
|
|
1243
|
+
def reshape[Target: IntTuple](
|
|
1244
|
+
self,
|
|
1245
|
+
shape: IntTupleOrList[Target],
|
|
1246
|
+
/,
|
|
1247
|
+
*,
|
|
1248
|
+
order: Literal["C", "F", "A"] = "C",
|
|
1249
|
+
copy: py_bool | None = None,
|
|
1250
|
+
) -> ndarray[reshape_shape(_ShapeT_co, Target), _DTypeT_co]: ...
|
|
1251
|
+
@overload
|
|
1252
|
+
def reshape[Target: IntTuple](
|
|
1253
|
+
self,
|
|
1254
|
+
/,
|
|
1255
|
+
*shape: *Target,
|
|
1256
|
+
order: Literal["C", "F", "A"] = "C",
|
|
1257
|
+
copy: py_bool | None = None,
|
|
1258
|
+
) -> ndarray[reshape_varargs_shape(_ShapeT_co, Target), _DTypeT_co]: ...
|
|
1259
|
+
@overload
|
|
1260
|
+
def searchsorted[N: IntVar](
|
|
1261
|
+
self: ndarray[[N]],
|
|
1262
|
+
v: _ArrayScalar | ndarray[[]],
|
|
1263
|
+
/,
|
|
1264
|
+
side: Literal["left", "right"] = "left",
|
|
1265
|
+
sorter: ndarray[[N], _dtype[intp]] | Sequence[int] | None = None,
|
|
1266
|
+
) -> intp: ...
|
|
1267
|
+
@overload
|
|
1268
|
+
def searchsorted[N: IntVar, Values: _Shape](
|
|
1269
|
+
self: ndarray[[N]],
|
|
1270
|
+
v: ndarray[Values],
|
|
1271
|
+
/,
|
|
1272
|
+
side: Literal["left", "right"] = "left",
|
|
1273
|
+
sorter: ndarray[[N], _dtype[intp]] | Sequence[int] | None = None,
|
|
1274
|
+
) -> ndarray[Values, _dtype[intp]]: ...
|
|
1275
|
+
@overload
|
|
1276
|
+
def searchsorted[N: IntVar, Values: _Shape](
|
|
1277
|
+
self: ndarray[[N]],
|
|
1278
|
+
v: RegularNestedList[Values, _ArrayScalar],
|
|
1279
|
+
/,
|
|
1280
|
+
side: Literal["left", "right"] = "left",
|
|
1281
|
+
sorter: ndarray[[N], _dtype[intp]] | Sequence[int] | None = None,
|
|
1282
|
+
) -> ndarray[Values, _dtype[intp]]: ...
|
|
1283
|
+
def squeeze[Axis: Flag[_Axis]](
|
|
1284
|
+
self, axis: Axis = None
|
|
1285
|
+
) -> ndarray[squeeze_shape(_ShapeT_co, Axis), _DTypeT_co]: ...
|
|
1286
|
+
def swapaxes[First: Flag[int], Second: Flag[int]](
|
|
1287
|
+
self, axis1: First, axis2: Second, /
|
|
1288
|
+
) -> ndarray[swapaxes_shape(_ShapeT_co, First, Second), _DTypeT_co]: ...
|
|
1289
|
+
@overload
|
|
1290
|
+
def take(
|
|
1291
|
+
self,
|
|
1292
|
+
indices: int | int32 | int64 | intp,
|
|
1293
|
+
/,
|
|
1294
|
+
axis: None = None,
|
|
1295
|
+
out: None = None,
|
|
1296
|
+
mode: Literal["raise", "wrap", "clip"] = "raise",
|
|
1297
|
+
) -> generic: ...
|
|
1298
|
+
@overload
|
|
1299
|
+
def take[Axis: Flag[int]](
|
|
1300
|
+
self,
|
|
1301
|
+
indices: int | int32 | int64 | intp,
|
|
1302
|
+
/,
|
|
1303
|
+
axis: Axis,
|
|
1304
|
+
out: None = None,
|
|
1305
|
+
mode: Literal["raise", "wrap", "clip"] = "raise",
|
|
1306
|
+
) -> ndarray[take_shape(_ShapeT_co, IntTuple[()], Axis), _DTypeT_co]: ...
|
|
1307
|
+
@overload
|
|
1308
|
+
def take[Indices: IntTuple](
|
|
1309
|
+
self,
|
|
1310
|
+
indices: ndarray[Indices],
|
|
1311
|
+
/,
|
|
1312
|
+
axis: None = None,
|
|
1313
|
+
out: None = None,
|
|
1314
|
+
mode: Literal["raise", "wrap", "clip"] = "raise",
|
|
1315
|
+
) -> ndarray[Indices, _DTypeT_co]: ...
|
|
1316
|
+
@overload
|
|
1317
|
+
def take(
|
|
1318
|
+
self,
|
|
1319
|
+
indices: Sequence[int],
|
|
1320
|
+
/,
|
|
1321
|
+
axis: None = None,
|
|
1322
|
+
out: None = None,
|
|
1323
|
+
mode: Literal["raise", "wrap", "clip"] = "raise",
|
|
1324
|
+
) -> ndarray[[int], _DTypeT_co]: ...
|
|
1325
|
+
@overload
|
|
1326
|
+
def take[Axis: Flag[int]](
|
|
1327
|
+
self,
|
|
1328
|
+
indices: Sequence[int],
|
|
1329
|
+
/,
|
|
1330
|
+
axis: Axis,
|
|
1331
|
+
out: None = None,
|
|
1332
|
+
mode: Literal["raise", "wrap", "clip"] = "raise",
|
|
1333
|
+
) -> ndarray[take_shape(_ShapeT_co, IntTuple[int], Axis), _DTypeT_co]: ...
|
|
1334
|
+
@overload
|
|
1335
|
+
def take[Indices: IntTuple, Axis: Flag[int]](
|
|
1336
|
+
self,
|
|
1337
|
+
indices: ndarray[Indices],
|
|
1338
|
+
/,
|
|
1339
|
+
axis: Axis,
|
|
1340
|
+
out: None = None,
|
|
1341
|
+
mode: Literal["raise", "wrap", "clip"] = "raise",
|
|
1342
|
+
) -> ndarray[take_shape(_ShapeT_co, Indices, Axis), _DTypeT_co]: ...
|
|
1343
|
+
@overload
|
|
1344
|
+
def take[Out: ndarray](
|
|
1345
|
+
self,
|
|
1346
|
+
indices: int | Sequence[int] | ndarray,
|
|
1347
|
+
/,
|
|
1348
|
+
axis: int | None,
|
|
1349
|
+
out: Out,
|
|
1350
|
+
mode: Literal["raise", "wrap", "clip"] = "raise",
|
|
1351
|
+
) -> Out: ...
|
|
1352
|
+
@overload
|
|
1353
|
+
def take[Out: ndarray](
|
|
1354
|
+
self,
|
|
1355
|
+
indices: int | Sequence[int] | ndarray,
|
|
1356
|
+
/,
|
|
1357
|
+
axis: int | None = None,
|
|
1358
|
+
*,
|
|
1359
|
+
out: Out,
|
|
1360
|
+
mode: Literal["raise", "wrap", "clip"] = "raise",
|
|
1361
|
+
) -> Out: ...
|
|
1362
|
+
# TODO(stroxler): Restrict index-array dtypes to valid index types.
|
|
1363
|
+
@overload
|
|
1364
|
+
def trace[M: IntVar, N: IntVar](
|
|
1365
|
+
self: ndarray[[M, N], _DTypeT_co],
|
|
1366
|
+
offset: int = 0,
|
|
1367
|
+
axis1: int = 0,
|
|
1368
|
+
axis2: int = 1,
|
|
1369
|
+
dtype: Any = None,
|
|
1370
|
+
out: None = None,
|
|
1371
|
+
) -> generic: ...
|
|
1372
|
+
@overload
|
|
1373
|
+
def trace[First: Flag[int], Second: Flag[int]](
|
|
1374
|
+
self,
|
|
1375
|
+
offset: int = 0,
|
|
1376
|
+
axis1: First = 0,
|
|
1377
|
+
axis2: Second = 1,
|
|
1378
|
+
dtype: Any = None,
|
|
1379
|
+
out: None = None,
|
|
1380
|
+
) -> ndarray[diagonal_shape(_ShapeT_co, First, Second, False, 0)]: ...
|
|
1381
|
+
@overload
|
|
1382
|
+
def trace[Out: ndarray](
|
|
1383
|
+
self,
|
|
1384
|
+
offset: int = 0,
|
|
1385
|
+
axis1: int = 0,
|
|
1386
|
+
axis2: int = 1,
|
|
1387
|
+
dtype: Any = None,
|
|
1388
|
+
*,
|
|
1389
|
+
out: Out,
|
|
1390
|
+
) -> Out: ...
|
|
1391
|
+
# TODO(stroxler): Validate 2-D axes and infer scalar dtype promotion.
|
|
1392
|
+
@overload
|
|
1393
|
+
def transpose(
|
|
1394
|
+
self, axes: None = None, /
|
|
1395
|
+
) -> ndarray[reverse_shape(_ShapeT_co), _DTypeT_co]: ...
|
|
1396
|
+
@overload
|
|
1397
|
+
def transpose[Axes: IntTuple](
|
|
1398
|
+
self, axes: Axes, /
|
|
1399
|
+
) -> ndarray[transpose_shape(_ShapeT_co, Axes), _DTypeT_co]: ...
|
|
1400
|
+
@overload
|
|
1401
|
+
def transpose[Axes: IntTuple](
|
|
1402
|
+
self, *axes: *Axes
|
|
1403
|
+
) -> ndarray[transpose_shape(_ShapeT_co, Axes), _DTypeT_co]: ...
|
|
1404
|
+
# TODO(stroxler): Reinterpretation can change the final dimension's size.
|
|
1405
|
+
@overload
|
|
1406
|
+
def view(self, /) -> ndarray[_ShapeT_co, _DTypeT_co]: ...
|
|
1407
|
+
@overload
|
|
1408
|
+
def view[ArrayT: ndarray](self, /, *, type: type[ArrayT]) -> ArrayT: ...
|
|
1409
|
+
@overload
|
|
1410
|
+
def view[ScalarT: generic](
|
|
1411
|
+
self, dtype: type[ScalarT] | _dtype[ScalarT], /
|
|
1412
|
+
) -> ndarray[IntTuple, _dtype[ScalarT]]: ...
|
|
1413
|
+
@overload
|
|
1414
|
+
def view(self, dtype: str, /) -> ndarray[IntTuple]: ...
|
|
893
1415
|
|
|
894
1416
|
class ufunc:
|
|
895
1417
|
__name__: str
|
|
@@ -910,8 +1432,8 @@ class ufunc:
|
|
|
910
1432
|
def at(self, a: ndarray, indices: Any, b: Any = None, /) -> None: ...
|
|
911
1433
|
|
|
912
1434
|
permute_dims = transpose
|
|
913
|
-
# TODO(stroxler):
|
|
914
|
-
concat
|
|
1435
|
+
# TODO(stroxler): Model concatenation of overlay ndarrays with a shape rule.
|
|
1436
|
+
concat = concatenate
|
|
915
1437
|
|
|
916
1438
|
@overload
|
|
917
1439
|
def stack[Shapes: IntTuples, Axis: Flag[int]](
|
|
@@ -959,6 +1481,14 @@ class _UnaryUFunc(ufunc):
|
|
|
959
1481
|
def __call__[Shape: _Shape](
|
|
960
1482
|
self, x: ndarray[Shape], /, out: Any = None, **kwargs: Any
|
|
961
1483
|
) -> ndarray[Shape]: ...
|
|
1484
|
+
# Scalars stay gradual so comparisons like `np.log(0.9) < 0` keep typing.
|
|
1485
|
+
@overload
|
|
1486
|
+
def __call__(self, x: _ArrayScalar, /, out: Any = None, **kwargs: Any) -> Any: ...
|
|
1487
|
+
# Non-scalar array-likes should not fall through to the generic Any ufunc overload.
|
|
1488
|
+
@overload
|
|
1489
|
+
def __call__(
|
|
1490
|
+
self, x: ArrayLike, /, out: Any = None, **kwargs: Any
|
|
1491
|
+
) -> ndarray | generic: ...
|
|
962
1492
|
@overload
|
|
963
1493
|
def __call__(self, x: Any, /, out: Any = None, **kwargs: Any) -> Any: ...
|
|
964
1494
|
|
|
@@ -1208,9 +1738,9 @@ def array[Shape: _Shape, DType](
|
|
|
1208
1738
|
object: ndarray[Shape, DType],
|
|
1209
1739
|
dtype: None = None,
|
|
1210
1740
|
*,
|
|
1211
|
-
copy:
|
|
1741
|
+
copy: py_bool | None = ...,
|
|
1212
1742
|
order: str | None = None,
|
|
1213
|
-
subok:
|
|
1743
|
+
subok: py_bool = ...,
|
|
1214
1744
|
ndmin: Literal[0] = 0,
|
|
1215
1745
|
like: None = None,
|
|
1216
1746
|
) -> ndarray[Shape, DType]: ...
|
|
@@ -1219,9 +1749,9 @@ def array[Shape: _Shape](
|
|
|
1219
1749
|
object: ndarray[Shape, Any],
|
|
1220
1750
|
dtype: Any,
|
|
1221
1751
|
*,
|
|
1222
|
-
copy:
|
|
1752
|
+
copy: py_bool | None = ...,
|
|
1223
1753
|
order: str | None = None,
|
|
1224
|
-
subok:
|
|
1754
|
+
subok: py_bool = ...,
|
|
1225
1755
|
ndmin: Literal[0] = 0,
|
|
1226
1756
|
like: None = None,
|
|
1227
1757
|
) -> ndarray[Shape]: ...
|
|
@@ -1230,9 +1760,9 @@ def array[Shape: _Shape = []](
|
|
|
1230
1760
|
object: _ArrayScalar | RegularNestedList[Shape, _ArrayScalar],
|
|
1231
1761
|
dtype: Any = ...,
|
|
1232
1762
|
*,
|
|
1233
|
-
copy:
|
|
1763
|
+
copy: py_bool | None = ...,
|
|
1234
1764
|
order: str | None = None,
|
|
1235
|
-
subok:
|
|
1765
|
+
subok: py_bool = ...,
|
|
1236
1766
|
ndmin: Literal[0] = 0,
|
|
1237
1767
|
like: None = None,
|
|
1238
1768
|
) -> ndarray[Shape]: ...
|
|
@@ -1241,9 +1771,9 @@ def array(
|
|
|
1241
1771
|
object: Any,
|
|
1242
1772
|
dtype: Any = ...,
|
|
1243
1773
|
*,
|
|
1244
|
-
copy:
|
|
1774
|
+
copy: py_bool | None = ...,
|
|
1245
1775
|
order: str | None = None,
|
|
1246
|
-
subok:
|
|
1776
|
+
subok: py_bool = ...,
|
|
1247
1777
|
ndmin: int = ...,
|
|
1248
1778
|
like: None = None,
|
|
1249
1779
|
) -> ndarray[IntTuple]: ...
|
|
@@ -1252,9 +1782,9 @@ def array(
|
|
|
1252
1782
|
object: Any,
|
|
1253
1783
|
dtype: Any = ...,
|
|
1254
1784
|
*,
|
|
1255
|
-
copy:
|
|
1785
|
+
copy: py_bool | None = ...,
|
|
1256
1786
|
order: str | None = None,
|
|
1257
|
-
subok:
|
|
1787
|
+
subok: py_bool = ...,
|
|
1258
1788
|
ndmin: int = ...,
|
|
1259
1789
|
like: Any,
|
|
1260
1790
|
) -> Any: ...
|
|
@@ -1265,7 +1795,7 @@ def asarray[Shape: _Shape, DType](
|
|
|
1265
1795
|
order: str | None = None,
|
|
1266
1796
|
*,
|
|
1267
1797
|
device: Any = ...,
|
|
1268
|
-
copy:
|
|
1798
|
+
copy: py_bool | None = ...,
|
|
1269
1799
|
like: None = None,
|
|
1270
1800
|
) -> ndarray[Shape, DType]: ...
|
|
1271
1801
|
@overload
|
|
@@ -1275,7 +1805,7 @@ def asarray[Shape: _Shape](
|
|
|
1275
1805
|
order: str | None = None,
|
|
1276
1806
|
*,
|
|
1277
1807
|
device: Any = ...,
|
|
1278
|
-
copy:
|
|
1808
|
+
copy: py_bool | None = ...,
|
|
1279
1809
|
like: None = None,
|
|
1280
1810
|
) -> ndarray[Shape]: ...
|
|
1281
1811
|
@overload
|
|
@@ -1285,7 +1815,7 @@ def asarray[Shape: _Shape = []](
|
|
|
1285
1815
|
order: str | None = None,
|
|
1286
1816
|
*,
|
|
1287
1817
|
device: Any = ...,
|
|
1288
|
-
copy:
|
|
1818
|
+
copy: py_bool | None = ...,
|
|
1289
1819
|
like: None = None,
|
|
1290
1820
|
) -> ndarray[Shape]: ...
|
|
1291
1821
|
@overload
|
|
@@ -1295,7 +1825,7 @@ def asarray(
|
|
|
1295
1825
|
order: str | None = None,
|
|
1296
1826
|
*,
|
|
1297
1827
|
device: Any = ...,
|
|
1298
|
-
copy:
|
|
1828
|
+
copy: py_bool | None = ...,
|
|
1299
1829
|
like: None = None,
|
|
1300
1830
|
) -> ndarray[IntTuple]: ...
|
|
1301
1831
|
@overload
|
|
@@ -1305,10 +1835,30 @@ def asarray(
|
|
|
1305
1835
|
order: str | None = None,
|
|
1306
1836
|
*,
|
|
1307
1837
|
device: Any = ...,
|
|
1308
|
-
copy:
|
|
1838
|
+
copy: py_bool | None = ...,
|
|
1309
1839
|
like: Any,
|
|
1310
1840
|
) -> Any: ...
|
|
1311
|
-
def round[Shape: _Shape](
|
|
1841
|
+
def round[Shape: _Shape](a: ndarray[Shape], decimals: int = 0) -> ndarray[Shape]: ...
|
|
1842
|
+
|
|
1843
|
+
# Interpolation tracks query shapes and leaves the result dtype gradual.
|
|
1844
|
+
@overload
|
|
1845
|
+
def interp[N: IntVar, Rest: _Shape = []](
|
|
1846
|
+
x: ndarray[[N, *Rest]] | RegularNestedList[[N, *Rest], _ArrayScalar],
|
|
1847
|
+
xp: ArrayLike,
|
|
1848
|
+
fp: ArrayLike,
|
|
1849
|
+
left: Any = ...,
|
|
1850
|
+
right: Any = ...,
|
|
1851
|
+
period: Any = ...,
|
|
1852
|
+
) -> ndarray[[N, *Rest]]: ...
|
|
1853
|
+
@overload
|
|
1854
|
+
def interp(
|
|
1855
|
+
x: _ArrayScalar | ArrayLike,
|
|
1856
|
+
xp: ArrayLike,
|
|
1857
|
+
fp: ArrayLike,
|
|
1858
|
+
left: Any = ...,
|
|
1859
|
+
right: Any = ...,
|
|
1860
|
+
period: Any = ...,
|
|
1861
|
+
) -> Any: ...
|
|
1312
1862
|
@overload
|
|
1313
1863
|
def clip[Shape: _Shape](
|
|
1314
1864
|
a: ndarray[Shape], a_min: int | float, a_max: int | float
|
|
@@ -1321,25 +1871,42 @@ def fill_diagonal[N: IntVar, DType](
|
|
|
1321
1871
|
wrap: py_bool = False,
|
|
1322
1872
|
) -> None: ...
|
|
1323
1873
|
@overload
|
|
1324
|
-
def diag[N: IntVar, DType, K:
|
|
1874
|
+
def diag[N: IntVar, DType, K: Int = 0](
|
|
1325
1875
|
v: ndarray[[N], DType], k: K = 0
|
|
1326
1876
|
) -> ndarray[[diag_extent(Int[N], K), diag_extent(Int[N], K)], DType]: ...
|
|
1327
|
-
|
|
1328
|
-
# TODO(stroxler): Model the shape arithmetic here; we can do better than `int`.
|
|
1329
1877
|
@overload
|
|
1330
|
-
def diag[M: IntVar, N: IntVar, DType](
|
|
1331
|
-
v: ndarray[[M, N], DType], k:
|
|
1332
|
-
) -> ndarray[[
|
|
1878
|
+
def diag[M: IntVar, N: IntVar, DType, K: Flag[int] = 0](
|
|
1879
|
+
v: ndarray[[M, N], DType], k: K = 0
|
|
1880
|
+
) -> ndarray[diag_matrix_shape(Int[M], Int[N], K), DType]: ...
|
|
1333
1881
|
|
|
1334
1882
|
# Trailing fallback for ranks the precise overloads do not model, so their dtype survives
|
|
1335
1883
|
# instead of degrading to `Any`. The parameter shape is a type variable rather than
|
|
1336
1884
|
# `IntTuple`: a gradual parameter shape would also match known-rank arguments whose dtype is
|
|
1337
1885
|
# gradual, and that ambiguity collapses their precise result to a gradual shape.
|
|
1886
|
+
# TODO(stroxler): Reject known-invalid ranks without losing unknown-rank dtype information.
|
|
1338
1887
|
@overload
|
|
1339
1888
|
def diag[S: _Shape, DType](
|
|
1340
1889
|
v: ndarray[S, DType], k: int = 0
|
|
1341
1890
|
) -> ndarray[IntTuple, DType]: ...
|
|
1342
|
-
|
|
1891
|
+
@overload
|
|
1892
|
+
def arange[N: IntVar](
|
|
1893
|
+
stop: Int[N],
|
|
1894
|
+
/,
|
|
1895
|
+
*,
|
|
1896
|
+
dtype: None = None,
|
|
1897
|
+
device: Literal["cpu"] | None = None,
|
|
1898
|
+
like: None = None,
|
|
1899
|
+
) -> ndarray[[N], dtype[intp]]: ...
|
|
1900
|
+
@overload
|
|
1901
|
+
def arange(
|
|
1902
|
+
start: float | integer | floating,
|
|
1903
|
+
stop: float | integer | floating | None = None,
|
|
1904
|
+
step: float | integer | floating = 1,
|
|
1905
|
+
dtype: DTypeLike | None = None,
|
|
1906
|
+
*,
|
|
1907
|
+
device: Literal["cpu"] | None = None,
|
|
1908
|
+
like: None = None,
|
|
1909
|
+
) -> ndarray[[int]]: ...
|
|
1343
1910
|
def expand_dims[Shape: _Shape, DType, Axis: Flag[int]](
|
|
1344
1911
|
a: ndarray[Shape, DType], axis: Axis
|
|
1345
1912
|
) -> ndarray[expand_dims_shape(Shape, Axis), DType]: ...
|
|
@@ -1368,11 +1935,19 @@ def min[
|
|
|
1368
1935
|
Axis: Flag[_Axis],
|
|
1369
1936
|
KeepDims: Flag[py_bool],
|
|
1370
1937
|
](
|
|
1371
|
-
a: ndarray[Shape, DType],
|
|
1938
|
+
a: ndarray[Shape, DType],
|
|
1939
|
+
axis: Axis = None,
|
|
1940
|
+
*,
|
|
1941
|
+
keepdims: KeepDims = False,
|
|
1942
|
+
initial: _ArrayScalar = ...,
|
|
1372
1943
|
) -> ndarray[reduce_shape(Shape, Axis, KeepDims), Any]: ...
|
|
1373
1944
|
@overload
|
|
1374
1945
|
def min(
|
|
1375
|
-
a: Sequence[ArrayLike],
|
|
1946
|
+
a: Sequence[ArrayLike],
|
|
1947
|
+
axis: _Axis = None,
|
|
1948
|
+
*,
|
|
1949
|
+
keepdims: py_bool = False,
|
|
1950
|
+
initial: _ArrayScalar = ...,
|
|
1376
1951
|
) -> Any: ...
|
|
1377
1952
|
@overload
|
|
1378
1953
|
def max[
|
|
@@ -1381,24 +1956,93 @@ def max[
|
|
|
1381
1956
|
Axis: Flag[_Axis],
|
|
1382
1957
|
KeepDims: Flag[py_bool],
|
|
1383
1958
|
](
|
|
1384
|
-
a: ndarray[Shape, DType],
|
|
1959
|
+
a: ndarray[Shape, DType],
|
|
1960
|
+
axis: Axis = None,
|
|
1961
|
+
*,
|
|
1962
|
+
keepdims: KeepDims = False,
|
|
1963
|
+
initial: _ArrayScalar = ...,
|
|
1385
1964
|
) -> ndarray[reduce_shape(Shape, Axis, KeepDims), Any]: ...
|
|
1386
1965
|
@overload
|
|
1387
1966
|
def max(
|
|
1388
|
-
a: Sequence[ArrayLike],
|
|
1967
|
+
a: Sequence[ArrayLike],
|
|
1968
|
+
axis: _Axis = None,
|
|
1969
|
+
*,
|
|
1970
|
+
keepdims: py_bool = False,
|
|
1971
|
+
initial: _ArrayScalar = ...,
|
|
1389
1972
|
) -> Any: ...
|
|
1390
1973
|
@overload
|
|
1974
|
+
def argmin[Out: ndarray, Axis: Flag[_SingleAxis], KeepDims: Flag[py_bool]](
|
|
1975
|
+
a: ArrayLike, axis: Axis, out: Out, *, keepdims: KeepDims = False
|
|
1976
|
+
) -> Out: ...
|
|
1977
|
+
@overload
|
|
1978
|
+
def argmin[Out: ndarray, Axis: Flag[_SingleAxis], KeepDims: Flag[py_bool]](
|
|
1979
|
+
a: ArrayLike, axis: Axis = None, *, out: Out, keepdims: KeepDims = False
|
|
1980
|
+
) -> Out: ...
|
|
1981
|
+
@overload
|
|
1982
|
+
def argmin(
|
|
1983
|
+
a: ArrayLike,
|
|
1984
|
+
axis: None = None,
|
|
1985
|
+
out: None = None,
|
|
1986
|
+
*,
|
|
1987
|
+
keepdims: Literal[False] = False,
|
|
1988
|
+
) -> intp: ...
|
|
1989
|
+
@overload
|
|
1391
1990
|
def argmin[
|
|
1392
1991
|
Shape: _Shape,
|
|
1393
1992
|
DType,
|
|
1394
1993
|
Axis: Flag[_SingleAxis],
|
|
1395
1994
|
KeepDims: Flag[py_bool],
|
|
1396
1995
|
](
|
|
1397
|
-
a: ndarray[Shape, DType],
|
|
1996
|
+
a: ndarray[Shape, DType],
|
|
1997
|
+
axis: Axis = None,
|
|
1998
|
+
out: None = None,
|
|
1999
|
+
*,
|
|
2000
|
+
keepdims: KeepDims = False,
|
|
1398
2001
|
) -> ndarray[reduce_shape(Shape, Axis, KeepDims), dtype[intp]]: ...
|
|
1399
2002
|
@overload
|
|
1400
|
-
def argmin(
|
|
1401
|
-
a: Sequence[ArrayLike]
|
|
2003
|
+
def argmin[Axis: Flag[_SingleAxis], KeepDims: Flag[py_bool]](
|
|
2004
|
+
a: Sequence[ArrayLike] | _ArrayScalar,
|
|
2005
|
+
axis: Axis = None,
|
|
2006
|
+
out: None = None,
|
|
2007
|
+
*,
|
|
2008
|
+
keepdims: KeepDims = False,
|
|
2009
|
+
) -> Any: ...
|
|
2010
|
+
@overload
|
|
2011
|
+
def argmax[Out: ndarray, Axis: Flag[_SingleAxis], KeepDims: Flag[py_bool]](
|
|
2012
|
+
a: ArrayLike, axis: Axis, out: Out, *, keepdims: KeepDims = False
|
|
2013
|
+
) -> Out: ...
|
|
2014
|
+
@overload
|
|
2015
|
+
def argmax[Out: ndarray, Axis: Flag[_SingleAxis], KeepDims: Flag[py_bool]](
|
|
2016
|
+
a: ArrayLike, axis: Axis = None, *, out: Out, keepdims: KeepDims = False
|
|
2017
|
+
) -> Out: ...
|
|
2018
|
+
@overload
|
|
2019
|
+
def argmax(
|
|
2020
|
+
a: ArrayLike,
|
|
2021
|
+
axis: None = None,
|
|
2022
|
+
out: None = None,
|
|
2023
|
+
*,
|
|
2024
|
+
keepdims: Literal[False] = False,
|
|
2025
|
+
) -> intp: ...
|
|
2026
|
+
@overload
|
|
2027
|
+
def argmax[
|
|
2028
|
+
Shape: _Shape,
|
|
2029
|
+
DType,
|
|
2030
|
+
Axis: Flag[_SingleAxis],
|
|
2031
|
+
KeepDims: Flag[py_bool],
|
|
2032
|
+
](
|
|
2033
|
+
a: ndarray[Shape, DType],
|
|
2034
|
+
axis: Axis = None,
|
|
2035
|
+
out: None = None,
|
|
2036
|
+
*,
|
|
2037
|
+
keepdims: KeepDims = False,
|
|
2038
|
+
) -> ndarray[reduce_shape(Shape, Axis, KeepDims), dtype[intp]]: ...
|
|
2039
|
+
@overload
|
|
2040
|
+
def argmax[Axis: Flag[_SingleAxis], KeepDims: Flag[py_bool]](
|
|
2041
|
+
a: Sequence[ArrayLike] | _ArrayScalar,
|
|
2042
|
+
axis: Axis = None,
|
|
2043
|
+
out: None = None,
|
|
2044
|
+
*,
|
|
2045
|
+
keepdims: KeepDims = False,
|
|
1402
2046
|
) -> Any: ...
|
|
1403
2047
|
@overload
|
|
1404
2048
|
def zeros[N: IntVar, ScalarT: generic](
|
|
@@ -1572,51 +2216,34 @@ def identity[N: IntVar](
|
|
|
1572
2216
|
n: Int[N], dtype: Any, *, like: Any = ...
|
|
1573
2217
|
) -> ndarray[[N, N]]: ...
|
|
1574
2218
|
|
|
1575
|
-
|
|
1576
|
-
|
|
1577
|
-
class
|
|
1578
|
-
|
|
1579
|
-
|
|
2219
|
+
bool = bool_
|
|
2220
|
+
|
|
2221
|
+
class broadcast:
|
|
2222
|
+
def __new__(cls, *args: ArrayLike) -> broadcast: ...
|
|
2223
|
+
def __init__(self, *args: ArrayLike) -> None: ...
|
|
2224
|
+
index: int
|
|
2225
|
+
iters: tuple[flatiter[Any], ...]
|
|
2226
|
+
nd: int
|
|
2227
|
+
ndim: int
|
|
2228
|
+
numiter: int
|
|
2229
|
+
shape: tuple[int, ...]
|
|
2230
|
+
size: int
|
|
2231
|
+
def __iter__(self) -> broadcast: ...
|
|
2232
|
+
def __next__(self) -> tuple[Any, ...]: ...
|
|
2233
|
+
def reset(self) -> None: ...
|
|
1580
2234
|
|
|
1581
|
-
|
|
1582
|
-
|
|
1583
|
-
|
|
1584
|
-
|
|
1585
|
-
|
|
1586
|
-
|
|
1587
|
-
|
|
1588
|
-
|
|
1589
|
-
|
|
1590
|
-
|
|
1591
|
-
|
|
1592
|
-
|
|
1593
|
-
|
|
1594
|
-
|
|
1595
|
-
|
|
1596
|
-
half: Any
|
|
1597
|
-
int16: Any
|
|
1598
|
-
int8: Any
|
|
1599
|
-
int_: Any
|
|
1600
|
-
intc: Any
|
|
1601
|
-
long: Any
|
|
1602
|
-
longdouble: Any
|
|
1603
|
-
longlong: Any
|
|
1604
|
-
object_: Any
|
|
1605
|
-
short: Any
|
|
1606
|
-
signedinteger: Any
|
|
1607
|
-
single: Any
|
|
1608
|
-
str_: Any
|
|
1609
|
-
timedelta64: Any
|
|
1610
|
-
ubyte: Any
|
|
1611
|
-
uint: Any
|
|
1612
|
-
uint16: Any
|
|
1613
|
-
uint32: Any
|
|
1614
|
-
uint64: Any
|
|
1615
|
-
uint8: Any
|
|
1616
|
-
uintc: Any
|
|
1617
|
-
uintp: Any
|
|
1618
|
-
ulong: Any
|
|
1619
|
-
ulonglong: Any
|
|
1620
|
-
unsignedinteger: Any
|
|
1621
|
-
ushort: Any
|
|
1622
|
-
void: Any
|
|
2235
|
+
byte = int8
|
|
2236
|
+
cdouble = complex128
|
|
2237
|
+
csingle = complex64
|
|
2238
|
+
double = float64
|
|
2239
|
+
half = float16
|
|
2240
|
+
int_ = intp
|
|
2241
|
+
intc = int32
|
|
2242
|
+
long = int64
|
|
2243
|
+
short = int16
|
|
2244
|
+
single = float32
|
|
2245
|
+
ubyte = uint8
|
|
2246
|
+
uint = uintp
|
|
2247
|
+
uintc = uint32
|
|
2248
|
+
ulong = uint64
|
|
2249
|
+
ushort = uint16
|