summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--doc/release/upcoming_changes/18935.new_feature.rst28
-rw-r--r--doc/source/reference/random/c-api.rst2
-rw-r--r--doc/source/user/basics.indexing.rst6
-rw-r--r--doc_requirements.txt2
-rw-r--r--numpy/__init__.pyi978
-rw-r--r--numpy/core/_add_newdocs.py4
-rw-r--r--numpy/core/fromnumeric.py12
-rw-r--r--numpy/lib/index_tricks.pyi30
-rw-r--r--numpy/lib/ufunclike.pyi10
-rw-r--r--numpy/typing/__init__.py5
-rw-r--r--numpy/typing/_add_docstring.py51
-rw-r--r--numpy/typing/_array_like.py5
-rw-r--r--numpy/typing/_callable.py5
-rw-r--r--numpy/typing/_generic_alias.py207
-rw-r--r--numpy/typing/tests/data/fail/datasource.py15
-rw-r--r--numpy/typing/tests/data/fail/ndarray_misc.py9
-rw-r--r--numpy/typing/tests/data/pass/multiarray.py37
-rw-r--r--numpy/typing/tests/data/pass/ndarray_misc.py21
-rw-r--r--numpy/typing/tests/data/pass/scalars.py62
-rw-r--r--numpy/typing/tests/data/reveal/datasource.py21
-rw-r--r--numpy/typing/tests/data/reveal/multiarray.py35
-rw-r--r--numpy/typing/tests/data/reveal/ndarray_misc.py34
-rw-r--r--numpy/typing/tests/data/reveal/scalars.py93
-rw-r--r--numpy/typing/tests/test_generic_alias.py112
-rw-r--r--test_requirements.txt2
25 files changed, 1268 insertions, 518 deletions
diff --git a/doc/release/upcoming_changes/18935.new_feature.rst b/doc/release/upcoming_changes/18935.new_feature.rst
new file mode 100644
index 000000000..8c6e25da6
--- /dev/null
+++ b/doc/release/upcoming_changes/18935.new_feature.rst
@@ -0,0 +1,28 @@
+A runtime-subcriptable alias has been added for `ndarray`
+---------------------------------------------------------
+`numpy.typing.NDArray` has been added, a runtime-subscriptable alias for
+``np.ndarray[Any, np.dtype[~Scalar]]``. The new type alias can be used
+for annotating arrays with a given dtype and unspecified shape. :sup:`1`
+
+:sup:`1` NumPy does not support the annotating of array shapes as of 1.21,
+this is expected to change in the future though (see :pep:`646`).
+
+Examples
+~~~~~~~~
+
+.. code-block:: python
+
+ >>> import numpy as np
+ >>> import numpy.typing as npt
+
+ >>> print(npt.NDArray)
+ numpy.ndarray[typing.Any, numpy.dtype[~ScalarType]]
+
+ >>> print(npt.NDArray[np.float64])
+ numpy.ndarray[typing.Any, numpy.dtype[numpy.float64]]
+
+ >>> NDArrayInt = npt.NDArray[np.int_]
+ >>> a: NDArrayInt = np.arange(10)
+
+ >>> def func(a: npt.ArrayLike) -> npt.NDArray[Any]:
+ ... return np.array(a)
diff --git a/doc/source/reference/random/c-api.rst b/doc/source/reference/random/c-api.rst
index 7c7996115..de403ce98 100644
--- a/doc/source/reference/random/c-api.rst
+++ b/doc/source/reference/random/c-api.rst
@@ -3,6 +3,8 @@ C API for random
.. currentmodule:: numpy.random
+.. versionadded:: 1.19.0
+
Access to various distributions below is available via Cython or C-wrapper
libraries like CFFI. All the functions accept a :c:type:`bitgen_t` as their
first argument. To access these from Cython or C, you must link with the
diff --git a/doc/source/user/basics.indexing.rst b/doc/source/user/basics.indexing.rst
index 9545bb78c..7ee61b130 100644
--- a/doc/source/user/basics.indexing.rst
+++ b/doc/source/user/basics.indexing.rst
@@ -11,7 +11,7 @@ Indexing
:ref:`Indexing routines <routines.indexing>`
Array indexing refers to any use of the square brackets ([]) to index
-array values. There are many options to indexing, which give numpy
+array values. There are many options to indexing, which give NumPy
indexing great power, but with power comes some complexity and the
potential for confusion. This section is just an overview of the
various options and issues related to indexing. Aside from single
@@ -39,7 +39,7 @@ and accepts negative indices for indexing from the end of the array. ::
>>> x[-2]
8
-Unlike lists and tuples, numpy arrays support multidimensional indexing
+Unlike lists and tuples, NumPy arrays support multidimensional indexing
for multidimensional arrays. That means that it is not necessary to
separate each dimension's index into its own set of square brackets. ::
@@ -285,7 +285,7 @@ with four True elements to select rows from a 3-D array of shape
[20, 21, 22, 23, 24],
[25, 26, 27, 28, 29]])
-For further details, consult the numpy reference documentation on array indexing.
+For further details, consult the NumPy reference documentation on array indexing.
Combining index arrays with slices
==================================
diff --git a/doc_requirements.txt b/doc_requirements.txt
index 2606f6270..340366854 100644
--- a/doc_requirements.txt
+++ b/doc_requirements.txt
@@ -1,4 +1,4 @@
-sphinx==4.0.0
+sphinx==4.0.1
numpydoc==1.1.0
ipython
scipy
diff --git a/numpy/__init__.pyi b/numpy/__init__.pyi
index b708b99ab..2d23f926d 100644
--- a/numpy/__init__.pyi
+++ b/numpy/__init__.pyi
@@ -10,7 +10,7 @@ from numpy.core._internal import _ctypes
from numpy.typing import (
# Arrays
ArrayLike,
- _ArrayND,
+ NDArray,
_SupportsArray,
_NestedSequence,
_RecursiveSequence,
@@ -42,6 +42,7 @@ from numpy.typing import (
_ComplexLike_co,
_TD64Like_co,
_NumberLike_co,
+ _ScalarLike_co,
# `number` precision
NBitBase,
@@ -558,13 +559,6 @@ __git_version__: str
#
# Placeholders for classes
# TODO: Remove `__getattr__` once the classes are stubbed out
-class DataSource:
- def __init__(self, destpath: Any = ...) -> None: ...
- def __del__(self): ...
- def abspath(self, path): ...
- def exists(self, path): ...
- def open(self, path, mode=..., encoding=..., newline=...): ...
-
class MachAr:
def __init__(
self,
@@ -576,10 +570,6 @@ class MachAr:
) -> None: ...
def __getattr__(self, key: str) -> Any: ...
-class broadcast:
- def __new__(cls: Any, *args: Any) -> Any: ...
- def __getattr__(self, key: str) -> Any: ...
-
class busdaycalendar:
def __new__(cls, weekmask: Any = ..., holidays: Any = ...) -> Any: ...
def __getattr__(self, key: str) -> Any: ...
@@ -1239,19 +1229,9 @@ class _ArrayOrScalarCommon:
def copy(self: _ArraySelf, order: _OrderKACF = ...) -> _ArraySelf: ...
def dump(self, file: str) -> None: ...
def dumps(self) -> bytes: ...
- def flatten(self, order: _OrderKACF = ...) -> ndarray: ...
def getfield(
self: _ArraySelf, dtype: DTypeLike, offset: int = ...
) -> _ArraySelf: ...
- def ravel(self, order: _OrderKACF = ...) -> ndarray: ...
- @overload
- def reshape(
- self, __shape: _ShapeLike, *, order: _OrderACF = ...
- ) -> ndarray: ...
- @overload
- def reshape(
- self, *shape: SupportsIndex, order: _OrderACF = ...
- ) -> ndarray: ...
def tobytes(self, order: _OrderKACF = ...) -> bytes: ...
# NOTE: `tostring()` is deprecated and therefore excluded
# def tostring(self, order=...): ...
@@ -1649,12 +1629,12 @@ _T_co = TypeVar("_T_co", covariant=True)
_2Tuple = Tuple[_T, _T]
_Casting = Literal["no", "equiv", "safe", "same_kind", "unsafe"]
-_ArrayUInt_co = _ArrayND[Union[bool_, unsignedinteger[Any]]]
-_ArrayInt_co = _ArrayND[Union[bool_, integer[Any]]]
-_ArrayFloat_co = _ArrayND[Union[bool_, integer[Any], floating[Any]]]
-_ArrayComplex_co = _ArrayND[Union[bool_, integer[Any], floating[Any], complexfloating[Any, Any]]]
-_ArrayNumber_co = _ArrayND[Union[bool_, number[Any]]]
-_ArrayTD64_co = _ArrayND[Union[bool_, integer[Any], timedelta64]]
+_ArrayUInt_co = NDArray[Union[bool_, unsignedinteger[Any]]]
+_ArrayInt_co = NDArray[Union[bool_, integer[Any]]]
+_ArrayFloat_co = NDArray[Union[bool_, integer[Any], floating[Any]]]
+_ArrayComplex_co = NDArray[Union[bool_, integer[Any], floating[Any], complexfloating[Any, Any]]]
+_ArrayNumber_co = NDArray[Union[bool_, number[Any]]]
+_ArrayTD64_co = NDArray[Union[bool_, integer[Any], timedelta64]]
class _SupportsItem(Protocol[_T_co]):
def item(self, __args: Any) -> _T_co: ...
@@ -1718,40 +1698,59 @@ class ndarray(_ArrayOrScalarCommon, Generic[_ShapeType, _DType_co]):
def itemset(self, __value: Any) -> None: ...
@overload
def itemset(self, __item: _ShapeLike, __value: Any) -> None: ...
+
@overload
def resize(self, __new_shape: _ShapeLike, *, refcheck: bool = ...) -> None: ...
@overload
def resize(self, *new_shape: SupportsIndex, refcheck: bool = ...) -> None: ...
+
def setflags(
self, write: bool = ..., align: bool = ..., uic: bool = ...
) -> None: ...
+
def squeeze(
- self: _ArraySelf, axis: Union[SupportsIndex, Tuple[SupportsIndex, ...]] = ...
- ) -> _ArraySelf: ...
- def swapaxes(self: _ArraySelf, axis1: SupportsIndex, axis2: SupportsIndex) -> _ArraySelf: ...
+ self,
+ axis: Union[SupportsIndex, Tuple[SupportsIndex, ...]] = ...,
+ ) -> ndarray[Any, _DType_co]: ...
+
+ def swapaxes(
+ self,
+ axis1: SupportsIndex,
+ axis2: SupportsIndex,
+ ) -> ndarray[Any, _DType_co]: ...
+
@overload
def transpose(self: _ArraySelf, __axes: _ShapeLike) -> _ArraySelf: ...
@overload
def transpose(self: _ArraySelf, *axes: SupportsIndex) -> _ArraySelf: ...
+
def argpartition(
self,
kth: _ArrayLikeInt_co,
axis: Optional[SupportsIndex] = ...,
kind: _PartitionKind = ...,
order: Union[None, str, Sequence[str]] = ...,
- ) -> ndarray: ...
+ ) -> ndarray[Any, dtype[intp]]: ...
+
def diagonal(
- self: _ArraySelf,
+ self,
offset: SupportsIndex = ...,
axis1: SupportsIndex = ...,
axis2: SupportsIndex = ...,
- ) -> _ArraySelf: ...
+ ) -> ndarray[Any, _DType_co]: ...
+
+ # 1D + 1D returns a scalar;
+ # all other with at least 1 non-0D array return an ndarray.
+ @overload
+ def dot(self, b: _ScalarLike_co, out: None = ...) -> ndarray: ...
@overload
- def dot(self, b: ArrayLike, out: None = ...) -> ndarray: ...
+ def dot(self, b: ArrayLike, out: None = ...) -> Any: ... # type: ignore[misc]
@overload
- def dot(self, b: ArrayLike, out: _NdArraySubClass = ...) -> _NdArraySubClass: ...
+ def dot(self, b: ArrayLike, out: _NdArraySubClass) -> _NdArraySubClass: ...
+
# `nonzero()` is deprecated for 0d arrays/generics
- def nonzero(self) -> Tuple[ndarray, ...]: ...
+ def nonzero(self) -> Tuple[ndarray[Any, dtype[intp]], ...]: ...
+
def partition(
self,
kth: _ArrayLikeInt_co,
@@ -1759,26 +1758,45 @@ class ndarray(_ArrayOrScalarCommon, Generic[_ShapeType, _DType_co]):
kind: _PartitionKind = ...,
order: Union[None, str, Sequence[str]] = ...,
) -> None: ...
+
# `put` is technically available to `generic`,
# but is pointless as `generic`s are immutable
def put(
- self, ind: _ArrayLikeInt_co, v: ArrayLike, mode: _ModeKind = ...
+ self,
+ ind: _ArrayLikeInt_co,
+ v: ArrayLike,
+ mode: _ModeKind = ...,
) -> None: ...
+
+ @overload
+ def searchsorted( # type: ignore[misc]
+ self, # >= 1D array
+ v: _ScalarLike_co, # 0D array-like
+ side: _SortSide = ...,
+ sorter: Optional[_ArrayLikeInt_co] = ...,
+ ) -> intp: ...
+ @overload
def searchsorted(
self, # >= 1D array
v: ArrayLike,
side: _SortSide = ...,
- sorter: Optional[_ArrayLikeInt_co] = ..., # 1D int array
- ) -> ndarray: ...
+ sorter: Optional[_ArrayLikeInt_co] = ...,
+ ) -> ndarray[Any, dtype[intp]]: ...
+
def setfield(
- self, val: ArrayLike, dtype: DTypeLike, offset: SupportsIndex = ...
+ self,
+ val: ArrayLike,
+ dtype: DTypeLike,
+ offset: SupportsIndex = ...,
) -> None: ...
+
def sort(
self,
axis: SupportsIndex = ...,
kind: Optional[_SortKind] = ...,
order: Union[None, str, Sequence[str]] = ...,
) -> None: ...
+
@overload
def trace(
self, # >= 2D array
@@ -1829,17 +1847,46 @@ class ndarray(_ArrayOrScalarCommon, Generic[_ShapeType, _DType_co]):
axis: Optional[SupportsIndex] = ...,
) -> ndarray[Any, _DType_co]: ...
- # Many of these special methods are irrelevant currently, since protocols
- # aren't supported yet. That said, I'm adding them for completeness.
- # https://docs.python.org/3/reference/datamodel.html
- def __int__(self) -> int: ...
- def __float__(self) -> float: ...
- def __complex__(self) -> complex: ...
+ def flatten(
+ self,
+ order: _OrderKACF = ...,
+ ) -> ndarray[Any, _DType_co]: ...
+
+ def ravel(
+ self,
+ order: _OrderKACF = ...,
+ ) -> ndarray[Any, _DType_co]: ...
+
+ @overload
+ def reshape(
+ self, __shape: _ShapeLike, *, order: _OrderACF = ...
+ ) -> ndarray[Any, _DType_co]: ...
+ @overload
+ def reshape(
+ self, *shape: SupportsIndex, order: _OrderACF = ...
+ ) -> ndarray[Any, _DType_co]: ...
+
+ # Dispatch to the underlying `generic` via protocols
+ def __int__(
+ self: ndarray[Any, dtype[SupportsInt]], # type: ignore[type-var]
+ ) -> int: ...
+
+ def __float__(
+ self: ndarray[Any, dtype[SupportsFloat]], # type: ignore[type-var]
+ ) -> float: ...
+
+ def __complex__(
+ self: ndarray[Any, dtype[SupportsComplex]], # type: ignore[type-var]
+ ) -> complex: ...
+
+ def __index__(
+ self: ndarray[Any, dtype[SupportsIndex]], # type: ignore[type-var]
+ ) -> int: ...
+
def __len__(self) -> int: ...
def __setitem__(self, key, value): ...
def __iter__(self) -> Any: ...
def __contains__(self, key) -> bool: ...
- def __index__(self) -> int: ...
# The last overload is for catching recursive objects whose
# nesting is too deep.
@@ -1848,128 +1895,128 @@ class ndarray(_ArrayOrScalarCommon, Generic[_ShapeType, _DType_co]):
# strings, it will pass through the final overload otherwise
@overload
- def __lt__(self: _ArrayND[Any], other: _NestedSequence[Union[str, bytes]]) -> NoReturn: ...
+ def __lt__(self: NDArray[Any], other: _NestedSequence[Union[str, bytes]]) -> NoReturn: ...
@overload
- def __lt__(self: _ArrayNumber_co, other: _ArrayLikeNumber_co) -> _ArrayND[bool_]: ...
+ def __lt__(self: _ArrayNumber_co, other: _ArrayLikeNumber_co) -> NDArray[bool_]: ...
@overload
- def __lt__(self: _ArrayTD64_co, other: _ArrayLikeTD64_co) -> _ArrayND[bool_]: ...
+ def __lt__(self: _ArrayTD64_co, other: _ArrayLikeTD64_co) -> NDArray[bool_]: ...
@overload
- def __lt__(self: _ArrayND[datetime64], other: _ArrayLikeDT64_co) -> _ArrayND[bool_]: ...
+ def __lt__(self: NDArray[datetime64], other: _ArrayLikeDT64_co) -> NDArray[bool_]: ...
@overload
- def __lt__(self: _ArrayND[object_], other: Any) -> _ArrayND[bool_]: ...
+ def __lt__(self: NDArray[object_], other: Any) -> NDArray[bool_]: ...
@overload
- def __lt__(self: _ArrayND[Any], other: _ArrayLikeObject_co) -> _ArrayND[bool_]: ...
+ def __lt__(self: NDArray[Any], other: _ArrayLikeObject_co) -> NDArray[bool_]: ...
@overload
def __lt__(
- self: _ArrayND[Union[number[Any], datetime64, timedelta64, bool_]],
+ self: NDArray[Union[number[Any], datetime64, timedelta64, bool_]],
other: _RecursiveSequence,
- ) -> _ArrayND[bool_]: ...
+ ) -> NDArray[bool_]: ...
@overload
- def __le__(self: _ArrayND[Any], other: _NestedSequence[Union[str, bytes]]) -> NoReturn: ...
+ def __le__(self: NDArray[Any], other: _NestedSequence[Union[str, bytes]]) -> NoReturn: ...
@overload
- def __le__(self: _ArrayNumber_co, other: _ArrayLikeNumber_co) -> _ArrayND[bool_]: ...
+ def __le__(self: _ArrayNumber_co, other: _ArrayLikeNumber_co) -> NDArray[bool_]: ...
@overload
- def __le__(self: _ArrayTD64_co, other: _ArrayLikeTD64_co) -> _ArrayND[bool_]: ...
+ def __le__(self: _ArrayTD64_co, other: _ArrayLikeTD64_co) -> NDArray[bool_]: ...
@overload
- def __le__(self: _ArrayND[datetime64], other: _ArrayLikeDT64_co) -> _ArrayND[bool_]: ...
+ def __le__(self: NDArray[datetime64], other: _ArrayLikeDT64_co) -> NDArray[bool_]: ...
@overload
- def __le__(self: _ArrayND[object_], other: Any) -> _ArrayND[bool_]: ...
+ def __le__(self: NDArray[object_], other: Any) -> NDArray[bool_]: ...
@overload
- def __le__(self: _ArrayND[Any], other: _ArrayLikeObject_co) -> _ArrayND[bool_]: ...
+ def __le__(self: NDArray[Any], other: _ArrayLikeObject_co) -> NDArray[bool_]: ...
@overload
def __le__(
- self: _ArrayND[Union[number[Any], datetime64, timedelta64, bool_]],
+ self: NDArray[Union[number[Any], datetime64, timedelta64, bool_]],
other: _RecursiveSequence,
- ) -> _ArrayND[bool_]: ...
+ ) -> NDArray[bool_]: ...
@overload
- def __gt__(self: _ArrayND[Any], other: _NestedSequence[Union[str, bytes]]) -> NoReturn: ...
+ def __gt__(self: NDArray[Any], other: _NestedSequence[Union[str, bytes]]) -> NoReturn: ...
@overload
- def __gt__(self: _ArrayNumber_co, other: _ArrayLikeNumber_co) -> _ArrayND[bool_]: ...
+ def __gt__(self: _ArrayNumber_co, other: _ArrayLikeNumber_co) -> NDArray[bool_]: ...
@overload
- def __gt__(self: _ArrayTD64_co, other: _ArrayLikeTD64_co) -> _ArrayND[bool_]: ...
+ def __gt__(self: _ArrayTD64_co, other: _ArrayLikeTD64_co) -> NDArray[bool_]: ...
@overload
- def __gt__(self: _ArrayND[datetime64], other: _ArrayLikeDT64_co) -> _ArrayND[bool_]: ...
+ def __gt__(self: NDArray[datetime64], other: _ArrayLikeDT64_co) -> NDArray[bool_]: ...
@overload
- def __gt__(self: _ArrayND[object_], other: Any) -> _ArrayND[bool_]: ...
+ def __gt__(self: NDArray[object_], other: Any) -> NDArray[bool_]: ...
@overload
- def __gt__(self: _ArrayND[Any], other: _ArrayLikeObject_co) -> _ArrayND[bool_]: ...
+ def __gt__(self: NDArray[Any], other: _ArrayLikeObject_co) -> NDArray[bool_]: ...
@overload
def __gt__(
- self: _ArrayND[Union[number[Any], datetime64, timedelta64, bool_]],
+ self: NDArray[Union[number[Any], datetime64, timedelta64, bool_]],
other: _RecursiveSequence,
- ) -> _ArrayND[bool_]: ...
+ ) -> NDArray[bool_]: ...
@overload
- def __ge__(self: _ArrayND[Any], other: _NestedSequence[Union[str, bytes]]) -> NoReturn: ...
+ def __ge__(self: NDArray[Any], other: _NestedSequence[Union[str, bytes]]) -> NoReturn: ...
@overload
- def __ge__(self: _ArrayNumber_co, other: _ArrayLikeNumber_co) -> _ArrayND[bool_]: ...
+ def __ge__(self: _ArrayNumber_co, other: _ArrayLikeNumber_co) -> NDArray[bool_]: ...
@overload
- def __ge__(self: _ArrayTD64_co, other: _ArrayLikeTD64_co) -> _ArrayND[bool_]: ...
+ def __ge__(self: _ArrayTD64_co, other: _ArrayLikeTD64_co) -> NDArray[bool_]: ...
@overload
- def __ge__(self: _ArrayND[datetime64], other: _ArrayLikeDT64_co) -> _ArrayND[bool_]: ...
+ def __ge__(self: NDArray[datetime64], other: _ArrayLikeDT64_co) -> NDArray[bool_]: ...
@overload
- def __ge__(self: _ArrayND[object_], other: Any) -> _ArrayND[bool_]: ...
+ def __ge__(self: NDArray[object_], other: Any) -> NDArray[bool_]: ...
@overload
- def __ge__(self: _ArrayND[Any], other: _ArrayLikeObject_co) -> _ArrayND[bool_]: ...
+ def __ge__(self: NDArray[Any], other: _ArrayLikeObject_co) -> NDArray[bool_]: ...
@overload
def __ge__(
- self: _ArrayND[Union[number[Any], datetime64, timedelta64, bool_]],
+ self: NDArray[Union[number[Any], datetime64, timedelta64, bool_]],
other: _RecursiveSequence,
- ) -> _ArrayND[bool_]: ...
+ ) -> NDArray[bool_]: ...
# Unary ops
@overload
- def __abs__(self: _ArrayND[bool_]) -> _ArrayND[bool_]: ...
+ def __abs__(self: NDArray[bool_]) -> NDArray[bool_]: ...
@overload
- def __abs__(self: _ArrayND[complexfloating[_NBit1, _NBit1]]) -> _ArrayND[floating[_NBit1]]: ...
+ def __abs__(self: NDArray[complexfloating[_NBit1, _NBit1]]) -> NDArray[floating[_NBit1]]: ...
@overload
- def __abs__(self: _ArrayND[_NumberType]) -> _ArrayND[_NumberType]: ...
+ def __abs__(self: NDArray[_NumberType]) -> NDArray[_NumberType]: ...
@overload
- def __abs__(self: _ArrayND[timedelta64]) -> _ArrayND[timedelta64]: ...
+ def __abs__(self: NDArray[timedelta64]) -> NDArray[timedelta64]: ...
@overload
- def __abs__(self: _ArrayND[object_]) -> Any: ...
+ def __abs__(self: NDArray[object_]) -> Any: ...
@overload
- def __invert__(self: _ArrayND[bool_]) -> _ArrayND[bool_]: ...
+ def __invert__(self: NDArray[bool_]) -> NDArray[bool_]: ...
@overload
- def __invert__(self: _ArrayND[_IntType]) -> _ArrayND[_IntType]: ...
+ def __invert__(self: NDArray[_IntType]) -> NDArray[_IntType]: ...
@overload
- def __invert__(self: _ArrayND[object_]) -> Any: ...
+ def __invert__(self: NDArray[object_]) -> Any: ...
@overload
- def __pos__(self: _ArrayND[_NumberType]) -> _ArrayND[_NumberType]: ...
+ def __pos__(self: NDArray[_NumberType]) -> NDArray[_NumberType]: ...
@overload
- def __pos__(self: _ArrayND[timedelta64]) -> _ArrayND[timedelta64]: ...
+ def __pos__(self: NDArray[timedelta64]) -> NDArray[timedelta64]: ...
@overload
- def __pos__(self: _ArrayND[object_]) -> Any: ...
+ def __pos__(self: NDArray[object_]) -> Any: ...
@overload
- def __neg__(self: _ArrayND[_NumberType]) -> _ArrayND[_NumberType]: ...
+ def __neg__(self: NDArray[_NumberType]) -> NDArray[_NumberType]: ...
@overload
- def __neg__(self: _ArrayND[timedelta64]) -> _ArrayND[timedelta64]: ...
+ def __neg__(self: NDArray[timedelta64]) -> NDArray[timedelta64]: ...
@overload
- def __neg__(self: _ArrayND[object_]) -> Any: ...
+ def __neg__(self: NDArray[object_]) -> Any: ...
# Binary ops
# NOTE: `ndarray` does not implement `__imatmul__`
@overload
- def __matmul__(self: _ArrayND[Any], other: _NestedSequence[Union[str, bytes]]) -> NoReturn: ...
+ def __matmul__(self: NDArray[Any], other: _NestedSequence[Union[str, bytes]]) -> NoReturn: ...
@overload
- def __matmul__(self: _ArrayND[bool_], other: _ArrayLikeBool_co) -> _ArrayND[bool_]: ... # type: ignore[misc]
+ def __matmul__(self: NDArray[bool_], other: _ArrayLikeBool_co) -> NDArray[bool_]: ... # type: ignore[misc]
@overload
- def __matmul__(self: _ArrayUInt_co, other: _ArrayLikeUInt_co) -> _ArrayND[unsignedinteger[Any]]: ... # type: ignore[misc]
+ def __matmul__(self: _ArrayUInt_co, other: _ArrayLikeUInt_co) -> NDArray[unsignedinteger[Any]]: ... # type: ignore[misc]
@overload
- def __matmul__(self: _ArrayInt_co, other: _ArrayLikeInt_co) -> _ArrayND[signedinteger[Any]]: ... # type: ignore[misc]
+ def __matmul__(self: _ArrayInt_co, other: _ArrayLikeInt_co) -> NDArray[signedinteger[Any]]: ... # type: ignore[misc]
@overload
- def __matmul__(self: _ArrayFloat_co, other: _ArrayLikeFloat_co) -> _ArrayND[floating[Any]]: ... # type: ignore[misc]
+ def __matmul__(self: _ArrayFloat_co, other: _ArrayLikeFloat_co) -> NDArray[floating[Any]]: ... # type: ignore[misc]
@overload
- def __matmul__(self: _ArrayComplex_co, other: _ArrayLikeComplex_co) -> _ArrayND[complexfloating[Any, Any]]: ...
+ def __matmul__(self: _ArrayComplex_co, other: _ArrayLikeComplex_co) -> NDArray[complexfloating[Any, Any]]: ...
@overload
- def __matmul__(self: _ArrayND[object_], other: Any) -> Any: ...
+ def __matmul__(self: NDArray[object_], other: Any) -> Any: ...
@overload
- def __matmul__(self: _ArrayND[Any], other: _ArrayLikeObject_co) -> Any: ...
+ def __matmul__(self: NDArray[Any], other: _ArrayLikeObject_co) -> Any: ...
@overload
def __matmul__(
self: _ArrayNumber_co,
@@ -1977,21 +2024,21 @@ class ndarray(_ArrayOrScalarCommon, Generic[_ShapeType, _DType_co]):
) -> Any: ...
@overload
- def __rmatmul__(self: _ArrayND[Any], other: _NestedSequence[Union[str, bytes]]) -> NoReturn: ...
+ def __rmatmul__(self: NDArray[Any], other: _NestedSequence[Union[str, bytes]]) -> NoReturn: ...
@overload
- def __rmatmul__(self: _ArrayND[bool_], other: _ArrayLikeBool_co) -> _ArrayND[bool_]: ... # type: ignore[misc]
+ def __rmatmul__(self: NDArray[bool_], other: _ArrayLikeBool_co) -> NDArray[bool_]: ... # type: ignore[misc]
@overload
- def __rmatmul__(self: _ArrayUInt_co, other: _ArrayLikeUInt_co) -> _ArrayND[unsignedinteger[Any]]: ... # type: ignore[misc]
+ def __rmatmul__(self: _ArrayUInt_co, other: _ArrayLikeUInt_co) -> NDArray[unsignedinteger[Any]]: ... # type: ignore[misc]
@overload
- def __rmatmul__(self: _ArrayInt_co, other: _ArrayLikeInt_co) -> _ArrayND[signedinteger[Any]]: ... # type: ignore[misc]
+ def __rmatmul__(self: _ArrayInt_co, other: _ArrayLikeInt_co) -> NDArray[signedinteger[Any]]: ... # type: ignore[misc]
@overload
- def __rmatmul__(self: _ArrayFloat_co, other: _ArrayLikeFloat_co) -> _ArrayND[floating[Any]]: ... # type: ignore[misc]
+ def __rmatmul__(self: _ArrayFloat_co, other: _ArrayLikeFloat_co) -> NDArray[floating[Any]]: ... # type: ignore[misc]
@overload
- def __rmatmul__(self: _ArrayComplex_co, other: _ArrayLikeComplex_co) -> _ArrayND[complexfloating[Any, Any]]: ...
+ def __rmatmul__(self: _ArrayComplex_co, other: _ArrayLikeComplex_co) -> NDArray[complexfloating[Any, Any]]: ...
@overload
- def __rmatmul__(self: _ArrayND[object_], other: Any) -> Any: ...
+ def __rmatmul__(self: NDArray[object_], other: Any) -> Any: ...
@overload
- def __rmatmul__(self: _ArrayND[Any], other: _ArrayLikeObject_co) -> Any: ...
+ def __rmatmul__(self: NDArray[Any], other: _ArrayLikeObject_co) -> Any: ...
@overload
def __rmatmul__(
self: _ArrayNumber_co,
@@ -1999,761 +2046,761 @@ class ndarray(_ArrayOrScalarCommon, Generic[_ShapeType, _DType_co]):
) -> Any: ...
@overload
- def __mod__(self: _ArrayND[Any], other: _NestedSequence[Union[str, bytes]]) -> NoReturn: ...
+ def __mod__(self: NDArray[Any], other: _NestedSequence[Union[str, bytes]]) -> NoReturn: ...
@overload
- def __mod__(self: _ArrayND[bool_], other: _ArrayLikeBool_co) -> _ArrayND[int8]: ... # type: ignore[misc]
+ def __mod__(self: NDArray[bool_], other: _ArrayLikeBool_co) -> NDArray[int8]: ... # type: ignore[misc]
@overload
- def __mod__(self: _ArrayUInt_co, other: _ArrayLikeUInt_co) -> _ArrayND[unsignedinteger[Any]]: ... # type: ignore[misc]
+ def __mod__(self: _ArrayUInt_co, other: _ArrayLikeUInt_co) -> NDArray[unsignedinteger[Any]]: ... # type: ignore[misc]
@overload
- def __mod__(self: _ArrayInt_co, other: _ArrayLikeInt_co) -> _ArrayND[signedinteger[Any]]: ... # type: ignore[misc]
+ def __mod__(self: _ArrayInt_co, other: _ArrayLikeInt_co) -> NDArray[signedinteger[Any]]: ... # type: ignore[misc]
@overload
- def __mod__(self: _ArrayFloat_co, other: _ArrayLikeFloat_co) -> _ArrayND[floating[Any]]: ... # type: ignore[misc]
+ def __mod__(self: _ArrayFloat_co, other: _ArrayLikeFloat_co) -> NDArray[floating[Any]]: ... # type: ignore[misc]
@overload
- def __mod__(self: _ArrayTD64_co, other: _NestedSequence[_SupportsArray[dtype[timedelta64]]]) -> _ArrayND[timedelta64]: ...
+ def __mod__(self: _ArrayTD64_co, other: _NestedSequence[_SupportsArray[dtype[timedelta64]]]) -> NDArray[timedelta64]: ...
@overload
- def __mod__(self: _ArrayND[object_], other: Any) -> Any: ...
+ def __mod__(self: NDArray[object_], other: Any) -> Any: ...
@overload
- def __mod__(self: _ArrayND[Any], other: _ArrayLikeObject_co) -> Any: ...
+ def __mod__(self: NDArray[Any], other: _ArrayLikeObject_co) -> Any: ...
@overload
def __mod__(
- self: _ArrayND[Union[bool_, integer[Any], floating[Any], timedelta64]],
+ self: NDArray[Union[bool_, integer[Any], floating[Any], timedelta64]],
other: _RecursiveSequence,
) -> Any: ...
@overload
- def __rmod__(self: _ArrayND[Any], other: _NestedSequence[Union[str, bytes]]) -> NoReturn: ...
+ def __rmod__(self: NDArray[Any], other: _NestedSequence[Union[str, bytes]]) -> NoReturn: ...
@overload
- def __rmod__(self: _ArrayND[bool_], other: _ArrayLikeBool_co) -> _ArrayND[int8]: ... # type: ignore[misc]
+ def __rmod__(self: NDArray[bool_], other: _ArrayLikeBool_co) -> NDArray[int8]: ... # type: ignore[misc]
@overload
- def __rmod__(self: _ArrayUInt_co, other: _ArrayLikeUInt_co) -> _ArrayND[unsignedinteger[Any]]: ... # type: ignore[misc]
+ def __rmod__(self: _ArrayUInt_co, other: _ArrayLikeUInt_co) -> NDArray[unsignedinteger[Any]]: ... # type: ignore[misc]
@overload
- def __rmod__(self: _ArrayInt_co, other: _ArrayLikeInt_co) -> _ArrayND[signedinteger[Any]]: ... # type: ignore[misc]
+ def __rmod__(self: _ArrayInt_co, other: _ArrayLikeInt_co) -> NDArray[signedinteger[Any]]: ... # type: ignore[misc]
@overload
- def __rmod__(self: _ArrayFloat_co, other: _ArrayLikeFloat_co) -> _ArrayND[floating[Any]]: ... # type: ignore[misc]
+ def __rmod__(self: _ArrayFloat_co, other: _ArrayLikeFloat_co) -> NDArray[floating[Any]]: ... # type: ignore[misc]
@overload
- def __rmod__(self: _ArrayTD64_co, other: _NestedSequence[_SupportsArray[dtype[timedelta64]]]) -> _ArrayND[timedelta64]: ...
+ def __rmod__(self: _ArrayTD64_co, other: _NestedSequence[_SupportsArray[dtype[timedelta64]]]) -> NDArray[timedelta64]: ...
@overload
- def __rmod__(self: _ArrayND[object_], other: Any) -> Any: ...
+ def __rmod__(self: NDArray[object_], other: Any) -> Any: ...
@overload
- def __rmod__(self: _ArrayND[Any], other: _ArrayLikeObject_co) -> Any: ...
+ def __rmod__(self: NDArray[Any], other: _ArrayLikeObject_co) -> Any: ...
@overload
def __rmod__(
- self: _ArrayND[Union[bool_, integer[Any], floating[Any], timedelta64]],
+ self: NDArray[Union[bool_, integer[Any], floating[Any], timedelta64]],
other: _RecursiveSequence,
) -> Any: ...
@overload
- def __divmod__(self: _ArrayND[Any], other: _NestedSequence[Union[str, bytes]]) -> NoReturn: ...
+ def __divmod__(self: NDArray[Any], other: _NestedSequence[Union[str, bytes]]) -> NoReturn: ...
@overload
- def __divmod__(self: _ArrayND[bool_], other: _ArrayLikeBool_co) -> _2Tuple[_ArrayND[int8]]: ... # type: ignore[misc]
+ def __divmod__(self: NDArray[bool_], other: _ArrayLikeBool_co) -> _2Tuple[NDArray[int8]]: ... # type: ignore[misc]
@overload
- def __divmod__(self: _ArrayUInt_co, other: _ArrayLikeUInt_co) -> _2Tuple[_ArrayND[unsignedinteger[Any]]]: ... # type: ignore[misc]
+ def __divmod__(self: _ArrayUInt_co, other: _ArrayLikeUInt_co) -> _2Tuple[NDArray[unsignedinteger[Any]]]: ... # type: ignore[misc]
@overload
- def __divmod__(self: _ArrayInt_co, other: _ArrayLikeInt_co) -> _2Tuple[_ArrayND[signedinteger[Any]]]: ... # type: ignore[misc]
+ def __divmod__(self: _ArrayInt_co, other: _ArrayLikeInt_co) -> _2Tuple[NDArray[signedinteger[Any]]]: ... # type: ignore[misc]
@overload
- def __divmod__(self: _ArrayFloat_co, other: _ArrayLikeFloat_co) -> _2Tuple[_ArrayND[floating[Any]]]: ... # type: ignore[misc]
+ def __divmod__(self: _ArrayFloat_co, other: _ArrayLikeFloat_co) -> _2Tuple[NDArray[floating[Any]]]: ... # type: ignore[misc]
@overload
- def __divmod__(self: _ArrayTD64_co, other: _NestedSequence[_SupportsArray[dtype[timedelta64]]]) -> Tuple[_ArrayND[int64], _ArrayND[timedelta64]]: ...
+ def __divmod__(self: _ArrayTD64_co, other: _NestedSequence[_SupportsArray[dtype[timedelta64]]]) -> Tuple[NDArray[int64], NDArray[timedelta64]]: ...
@overload
def __divmod__(
- self: _ArrayND[Union[bool_, integer[Any], floating[Any], timedelta64]],
+ self: NDArray[Union[bool_, integer[Any], floating[Any], timedelta64]],
other: _RecursiveSequence,
) -> _2Tuple[Any]: ...
@overload
- def __rdivmod__(self: _ArrayND[Any], other: _NestedSequence[Union[str, bytes]]) -> NoReturn: ...
+ def __rdivmod__(self: NDArray[Any], other: _NestedSequence[Union[str, bytes]]) -> NoReturn: ...
@overload
- def __rdivmod__(self: _ArrayND[bool_], other: _ArrayLikeBool_co) -> _2Tuple[_ArrayND[int8]]: ... # type: ignore[misc]
+ def __rdivmod__(self: NDArray[bool_], other: _ArrayLikeBool_co) -> _2Tuple[NDArray[int8]]: ... # type: ignore[misc]
@overload
- def __rdivmod__(self: _ArrayUInt_co, other: _ArrayLikeUInt_co) -> _2Tuple[_ArrayND[unsignedinteger[Any]]]: ... # type: ignore[misc]
+ def __rdivmod__(self: _ArrayUInt_co, other: _ArrayLikeUInt_co) -> _2Tuple[NDArray[unsignedinteger[Any]]]: ... # type: ignore[misc]
@overload
- def __rdivmod__(self: _ArrayInt_co, other: _ArrayLikeInt_co) -> _2Tuple[_ArrayND[signedinteger[Any]]]: ... # type: ignore[misc]
+ def __rdivmod__(self: _ArrayInt_co, other: _ArrayLikeInt_co) -> _2Tuple[NDArray[signedinteger[Any]]]: ... # type: ignore[misc]
@overload
- def __rdivmod__(self: _ArrayFloat_co, other: _ArrayLikeFloat_co) -> _2Tuple[_ArrayND[floating[Any]]]: ... # type: ignore[misc]
+ def __rdivmod__(self: _ArrayFloat_co, other: _ArrayLikeFloat_co) -> _2Tuple[NDArray[floating[Any]]]: ... # type: ignore[misc]
@overload
- def __rdivmod__(self: _ArrayTD64_co, other: _NestedSequence[_SupportsArray[dtype[timedelta64]]]) -> Tuple[_ArrayND[int64], _ArrayND[timedelta64]]: ...
+ def __rdivmod__(self: _ArrayTD64_co, other: _NestedSequence[_SupportsArray[dtype[timedelta64]]]) -> Tuple[NDArray[int64], NDArray[timedelta64]]: ...
@overload
def __rdivmod__(
- self: _ArrayND[Union[bool_, integer[Any], floating[Any], timedelta64]],
+ self: NDArray[Union[bool_, integer[Any], floating[Any], timedelta64]],
other: _RecursiveSequence,
) -> _2Tuple[Any]: ...
@overload
- def __add__(self: _ArrayND[Any], other: _NestedSequence[Union[str, bytes]]) -> NoReturn: ...
+ def __add__(self: NDArray[Any], other: _NestedSequence[Union[str, bytes]]) -> NoReturn: ...
@overload
- def __add__(self: _ArrayND[bool_], other: _ArrayLikeBool_co) -> _ArrayND[bool_]: ... # type: ignore[misc]
+ def __add__(self: NDArray[bool_], other: _ArrayLikeBool_co) -> NDArray[bool_]: ... # type: ignore[misc]
@overload
- def __add__(self: _ArrayUInt_co, other: _ArrayLikeUInt_co) -> _ArrayND[unsignedinteger[Any]]: ... # type: ignore[misc]
+ def __add__(self: _ArrayUInt_co, other: _ArrayLikeUInt_co) -> NDArray[unsignedinteger[Any]]: ... # type: ignore[misc]
@overload
- def __add__(self: _ArrayInt_co, other: _ArrayLikeInt_co) -> _ArrayND[signedinteger[Any]]: ... # type: ignore[misc]
+ def __add__(self: _ArrayInt_co, other: _ArrayLikeInt_co) -> NDArray[signedinteger[Any]]: ... # type: ignore[misc]
@overload
- def __add__(self: _ArrayFloat_co, other: _ArrayLikeFloat_co) -> _ArrayND[floating[Any]]: ... # type: ignore[misc]
+ def __add__(self: _ArrayFloat_co, other: _ArrayLikeFloat_co) -> NDArray[floating[Any]]: ... # type: ignore[misc]
@overload
- def __add__(self: _ArrayComplex_co, other: _ArrayLikeComplex_co) -> _ArrayND[complexfloating[Any, Any]]: ... # type: ignore[misc]
+ def __add__(self: _ArrayComplex_co, other: _ArrayLikeComplex_co) -> NDArray[complexfloating[Any, Any]]: ... # type: ignore[misc]
@overload
- def __add__(self: _ArrayTD64_co, other: _ArrayLikeTD64_co) -> _ArrayND[timedelta64]: ... # type: ignore[misc]
+ def __add__(self: _ArrayTD64_co, other: _ArrayLikeTD64_co) -> NDArray[timedelta64]: ... # type: ignore[misc]
@overload
- def __add__(self: _ArrayTD64_co, other: _ArrayLikeDT64_co) -> _ArrayND[datetime64]: ...
+ def __add__(self: _ArrayTD64_co, other: _ArrayLikeDT64_co) -> NDArray[datetime64]: ...
@overload
- def __add__(self: _ArrayND[datetime64], other: _ArrayLikeTD64_co) -> _ArrayND[datetime64]: ...
+ def __add__(self: NDArray[datetime64], other: _ArrayLikeTD64_co) -> NDArray[datetime64]: ...
@overload
- def __add__(self: _ArrayND[object_], other: Any) -> Any: ...
+ def __add__(self: NDArray[object_], other: Any) -> Any: ...
@overload
- def __add__(self: _ArrayND[Any], other: _ArrayLikeObject_co) -> Any: ...
+ def __add__(self: NDArray[Any], other: _ArrayLikeObject_co) -> Any: ...
@overload
def __add__(
- self: _ArrayND[Union[bool_, number[Any], timedelta64, datetime64]],
+ self: NDArray[Union[bool_, number[Any], timedelta64, datetime64]],
other: _RecursiveSequence,
) -> Any: ...
@overload
- def __radd__(self: _ArrayND[Any], other: _NestedSequence[Union[str, bytes]]) -> NoReturn: ...
+ def __radd__(self: NDArray[Any], other: _NestedSequence[Union[str, bytes]]) -> NoReturn: ...
@overload
- def __radd__(self: _ArrayND[bool_], other: _ArrayLikeBool_co) -> _ArrayND[bool_]: ... # type: ignore[misc]
+ def __radd__(self: NDArray[bool_], other: _ArrayLikeBool_co) -> NDArray[bool_]: ... # type: ignore[misc]
@overload
- def __radd__(self: _ArrayUInt_co, other: _ArrayLikeUInt_co) -> _ArrayND[unsignedinteger[Any]]: ... # type: ignore[misc]
+ def __radd__(self: _ArrayUInt_co, other: _ArrayLikeUInt_co) -> NDArray[unsignedinteger[Any]]: ... # type: ignore[misc]
@overload
- def __radd__(self: _ArrayInt_co, other: _ArrayLikeInt_co) -> _ArrayND[signedinteger[Any]]: ... # type: ignore[misc]
+ def __radd__(self: _ArrayInt_co, other: _ArrayLikeInt_co) -> NDArray[signedinteger[Any]]: ... # type: ignore[misc]
@overload
- def __radd__(self: _ArrayFloat_co, other: _ArrayLikeFloat_co) -> _ArrayND[floating[Any]]: ... # type: ignore[misc]
+ def __radd__(self: _ArrayFloat_co, other: _ArrayLikeFloat_co) -> NDArray[floating[Any]]: ... # type: ignore[misc]
@overload
- def __radd__(self: _ArrayComplex_co, other: _ArrayLikeComplex_co) -> _ArrayND[complexfloating[Any, Any]]: ... # type: ignore[misc]
+ def __radd__(self: _ArrayComplex_co, other: _ArrayLikeComplex_co) -> NDArray[complexfloating[Any, Any]]: ... # type: ignore[misc]
@overload
- def __radd__(self: _ArrayTD64_co, other: _ArrayLikeTD64_co) -> _ArrayND[timedelta64]: ... # type: ignore[misc]
+ def __radd__(self: _ArrayTD64_co, other: _ArrayLikeTD64_co) -> NDArray[timedelta64]: ... # type: ignore[misc]
@overload
- def __radd__(self: _ArrayTD64_co, other: _ArrayLikeDT64_co) -> _ArrayND[datetime64]: ...
+ def __radd__(self: _ArrayTD64_co, other: _ArrayLikeDT64_co) -> NDArray[datetime64]: ...
@overload
- def __radd__(self: _ArrayND[datetime64], other: _ArrayLikeTD64_co) -> _ArrayND[datetime64]: ...
+ def __radd__(self: NDArray[datetime64], other: _ArrayLikeTD64_co) -> NDArray[datetime64]: ...
@overload
- def __radd__(self: _ArrayND[object_], other: Any) -> Any: ...
+ def __radd__(self: NDArray[object_], other: Any) -> Any: ...
@overload
- def __radd__(self: _ArrayND[Any], other: _ArrayLikeObject_co) -> Any: ...
+ def __radd__(self: NDArray[Any], other: _ArrayLikeObject_co) -> Any: ...
@overload
def __radd__(
- self: _ArrayND[Union[bool_, number[Any], timedelta64, datetime64]],
+ self: NDArray[Union[bool_, number[Any], timedelta64, datetime64]],
other: _RecursiveSequence,
) -> Any: ...
@overload
- def __sub__(self: _ArrayND[Any], other: _NestedSequence[Union[str, bytes]]) -> NoReturn: ...
+ def __sub__(self: NDArray[Any], other: _NestedSequence[Union[str, bytes]]) -> NoReturn: ...
@overload
- def __sub__(self: _ArrayND[bool_], other: _ArrayLikeBool_co) -> NoReturn: ...
+ def __sub__(self: NDArray[bool_], other: _ArrayLikeBool_co) -> NoReturn: ...
@overload
- def __sub__(self: _ArrayUInt_co, other: _ArrayLikeUInt_co) -> _ArrayND[unsignedinteger[Any]]: ... # type: ignore[misc]
+ def __sub__(self: _ArrayUInt_co, other: _ArrayLikeUInt_co) -> NDArray[unsignedinteger[Any]]: ... # type: ignore[misc]
@overload
- def __sub__(self: _ArrayInt_co, other: _ArrayLikeInt_co) -> _ArrayND[signedinteger[Any]]: ... # type: ignore[misc]
+ def __sub__(self: _ArrayInt_co, other: _ArrayLikeInt_co) -> NDArray[signedinteger[Any]]: ... # type: ignore[misc]
@overload
- def __sub__(self: _ArrayFloat_co, other: _ArrayLikeFloat_co) -> _ArrayND[floating[Any]]: ... # type: ignore[misc]
+ def __sub__(self: _ArrayFloat_co, other: _ArrayLikeFloat_co) -> NDArray[floating[Any]]: ... # type: ignore[misc]
@overload
- def __sub__(self: _ArrayComplex_co, other: _ArrayLikeComplex_co) -> _ArrayND[complexfloating[Any, Any]]: ... # type: ignore[misc]
+ def __sub__(self: _ArrayComplex_co, other: _ArrayLikeComplex_co) -> NDArray[complexfloating[Any, Any]]: ... # type: ignore[misc]
@overload
- def __sub__(self: _ArrayTD64_co, other: _ArrayLikeTD64_co) -> _ArrayND[timedelta64]: ... # type: ignore[misc]
+ def __sub__(self: _ArrayTD64_co, other: _ArrayLikeTD64_co) -> NDArray[timedelta64]: ... # type: ignore[misc]
@overload
- def __sub__(self: _ArrayND[datetime64], other: _ArrayLikeTD64_co) -> _ArrayND[datetime64]: ...
+ def __sub__(self: NDArray[datetime64], other: _ArrayLikeTD64_co) -> NDArray[datetime64]: ...
@overload
- def __sub__(self: _ArrayND[datetime64], other: _ArrayLikeDT64_co) -> _ArrayND[timedelta64]: ...
+ def __sub__(self: NDArray[datetime64], other: _ArrayLikeDT64_co) -> NDArray[timedelta64]: ...
@overload
- def __sub__(self: _ArrayND[object_], other: Any) -> Any: ...
+ def __sub__(self: NDArray[object_], other: Any) -> Any: ...
@overload
- def __sub__(self: _ArrayND[Any], other: _ArrayLikeObject_co) -> Any: ...
+ def __sub__(self: NDArray[Any], other: _ArrayLikeObject_co) -> Any: ...
@overload
def __sub__(
- self: _ArrayND[Union[bool_, number[Any], timedelta64, datetime64]],
+ self: NDArray[Union[bool_, number[Any], timedelta64, datetime64]],
other: _RecursiveSequence,
) -> Any: ...
@overload
- def __rsub__(self: _ArrayND[Any], other: _NestedSequence[Union[str, bytes]]) -> NoReturn: ...
+ def __rsub__(self: NDArray[Any], other: _NestedSequence[Union[str, bytes]]) -> NoReturn: ...
@overload
- def __rsub__(self: _ArrayND[bool_], other: _ArrayLikeBool_co) -> NoReturn: ...
+ def __rsub__(self: NDArray[bool_], other: _ArrayLikeBool_co) -> NoReturn: ...
@overload
- def __rsub__(self: _ArrayUInt_co, other: _ArrayLikeUInt_co) -> _ArrayND[unsignedinteger[Any]]: ... # type: ignore[misc]
+ def __rsub__(self: _ArrayUInt_co, other: _ArrayLikeUInt_co) -> NDArray[unsignedinteger[Any]]: ... # type: ignore[misc]
@overload
- def __rsub__(self: _ArrayInt_co, other: _ArrayLikeInt_co) -> _ArrayND[signedinteger[Any]]: ... # type: ignore[misc]
+ def __rsub__(self: _ArrayInt_co, other: _ArrayLikeInt_co) -> NDArray[signedinteger[Any]]: ... # type: ignore[misc]
@overload
- def __rsub__(self: _ArrayFloat_co, other: _ArrayLikeFloat_co) -> _ArrayND[floating[Any]]: ... # type: ignore[misc]
+ def __rsub__(self: _ArrayFloat_co, other: _ArrayLikeFloat_co) -> NDArray[floating[Any]]: ... # type: ignore[misc]
@overload
- def __rsub__(self: _ArrayComplex_co, other: _ArrayLikeComplex_co) -> _ArrayND[complexfloating[Any, Any]]: ... # type: ignore[misc]
+ def __rsub__(self: _ArrayComplex_co, other: _ArrayLikeComplex_co) -> NDArray[complexfloating[Any, Any]]: ... # type: ignore[misc]
@overload
- def __rsub__(self: _ArrayTD64_co, other: _ArrayLikeTD64_co) -> _ArrayND[timedelta64]: ... # type: ignore[misc]
+ def __rsub__(self: _ArrayTD64_co, other: _ArrayLikeTD64_co) -> NDArray[timedelta64]: ... # type: ignore[misc]
@overload
- def __rsub__(self: _ArrayTD64_co, other: _ArrayLikeDT64_co) -> _ArrayND[datetime64]: ... # type: ignore[misc]
+ def __rsub__(self: _ArrayTD64_co, other: _ArrayLikeDT64_co) -> NDArray[datetime64]: ... # type: ignore[misc]
@overload
- def __rsub__(self: _ArrayND[datetime64], other: _ArrayLikeDT64_co) -> _ArrayND[timedelta64]: ...
+ def __rsub__(self: NDArray[datetime64], other: _ArrayLikeDT64_co) -> NDArray[timedelta64]: ...
@overload
- def __rsub__(self: _ArrayND[object_], other: Any) -> Any: ...
+ def __rsub__(self: NDArray[object_], other: Any) -> Any: ...
@overload
- def __rsub__(self: _ArrayND[Any], other: _ArrayLikeObject_co) -> Any: ...
+ def __rsub__(self: NDArray[Any], other: _ArrayLikeObject_co) -> Any: ...
@overload
def __rsub__(
- self: _ArrayND[Union[bool_, number[Any], timedelta64, datetime64]],
+ self: NDArray[Union[bool_, number[Any], timedelta64, datetime64]],
other: _RecursiveSequence,
) -> Any: ...
@overload
- def __mul__(self: _ArrayND[Any], other: _NestedSequence[Union[str, bytes]]) -> NoReturn: ...
+ def __mul__(self: NDArray[Any], other: _NestedSequence[Union[str, bytes]]) -> NoReturn: ...
@overload
- def __mul__(self: _ArrayND[bool_], other: _ArrayLikeBool_co) -> _ArrayND[bool_]: ... # type: ignore[misc]
+ def __mul__(self: NDArray[bool_], other: _ArrayLikeBool_co) -> NDArray[bool_]: ... # type: ignore[misc]
@overload
- def __mul__(self: _ArrayUInt_co, other: _ArrayLikeUInt_co) -> _ArrayND[unsignedinteger[Any]]: ... # type: ignore[misc]
+ def __mul__(self: _ArrayUInt_co, other: _ArrayLikeUInt_co) -> NDArray[unsignedinteger[Any]]: ... # type: ignore[misc]
@overload
- def __mul__(self: _ArrayInt_co, other: _ArrayLikeInt_co) -> _ArrayND[signedinteger[Any]]: ... # type: ignore[misc]
+ def __mul__(self: _ArrayInt_co, other: _ArrayLikeInt_co) -> NDArray[signedinteger[Any]]: ... # type: ignore[misc]
@overload
- def __mul__(self: _ArrayFloat_co, other: _ArrayLikeFloat_co) -> _ArrayND[floating[Any]]: ... # type: ignore[misc]
+ def __mul__(self: _ArrayFloat_co, other: _ArrayLikeFloat_co) -> NDArray[floating[Any]]: ... # type: ignore[misc]
@overload
- def __mul__(self: _ArrayComplex_co, other: _ArrayLikeComplex_co) -> _ArrayND[complexfloating[Any, Any]]: ... # type: ignore[misc]
+ def __mul__(self: _ArrayComplex_co, other: _ArrayLikeComplex_co) -> NDArray[complexfloating[Any, Any]]: ... # type: ignore[misc]
@overload
- def __mul__(self: _ArrayTD64_co, other: _ArrayLikeFloat_co) -> _ArrayND[timedelta64]: ...
+ def __mul__(self: _ArrayTD64_co, other: _ArrayLikeFloat_co) -> NDArray[timedelta64]: ...
@overload
- def __mul__(self: _ArrayFloat_co, other: _ArrayLikeTD64_co) -> _ArrayND[timedelta64]: ...
+ def __mul__(self: _ArrayFloat_co, other: _ArrayLikeTD64_co) -> NDArray[timedelta64]: ...
@overload
- def __mul__(self: _ArrayND[object_], other: Any) -> Any: ...
+ def __mul__(self: NDArray[object_], other: Any) -> Any: ...
@overload
- def __mul__(self: _ArrayND[Any], other: _ArrayLikeObject_co) -> Any: ...
+ def __mul__(self: NDArray[Any], other: _ArrayLikeObject_co) -> Any: ...
@overload
def __mul__(
- self: _ArrayND[Union[bool_, number[Any], timedelta64]],
+ self: NDArray[Union[bool_, number[Any], timedelta64]],
other: _RecursiveSequence,
) -> Any: ...
@overload
- def __rmul__(self: _ArrayND[Any], other: _NestedSequence[Union[str, bytes]]) -> NoReturn: ...
+ def __rmul__(self: NDArray[Any], other: _NestedSequence[Union[str, bytes]]) -> NoReturn: ...
@overload
- def __rmul__(self: _ArrayND[bool_], other: _ArrayLikeBool_co) -> _ArrayND[bool_]: ... # type: ignore[misc]
+ def __rmul__(self: NDArray[bool_], other: _ArrayLikeBool_co) -> NDArray[bool_]: ... # type: ignore[misc]
@overload
- def __rmul__(self: _ArrayUInt_co, other: _ArrayLikeUInt_co) -> _ArrayND[unsignedinteger[Any]]: ... # type: ignore[misc]
+ def __rmul__(self: _ArrayUInt_co, other: _ArrayLikeUInt_co) -> NDArray[unsignedinteger[Any]]: ... # type: ignore[misc]
@overload
- def __rmul__(self: _ArrayInt_co, other: _ArrayLikeInt_co) -> _ArrayND[signedinteger[Any]]: ... # type: ignore[misc]
+ def __rmul__(self: _ArrayInt_co, other: _ArrayLikeInt_co) -> NDArray[signedinteger[Any]]: ... # type: ignore[misc]
@overload
- def __rmul__(self: _ArrayFloat_co, other: _ArrayLikeFloat_co) -> _ArrayND[floating[Any]]: ... # type: ignore[misc]
+ def __rmul__(self: _ArrayFloat_co, other: _ArrayLikeFloat_co) -> NDArray[floating[Any]]: ... # type: ignore[misc]
@overload
- def __rmul__(self: _ArrayComplex_co, other: _ArrayLikeComplex_co) -> _ArrayND[complexfloating[Any, Any]]: ... # type: ignore[misc]
+ def __rmul__(self: _ArrayComplex_co, other: _ArrayLikeComplex_co) -> NDArray[complexfloating[Any, Any]]: ... # type: ignore[misc]
@overload
- def __rmul__(self: _ArrayTD64_co, other: _ArrayLikeFloat_co) -> _ArrayND[timedelta64]: ...
+ def __rmul__(self: _ArrayTD64_co, other: _ArrayLikeFloat_co) -> NDArray[timedelta64]: ...
@overload
- def __rmul__(self: _ArrayFloat_co, other: _ArrayLikeTD64_co) -> _ArrayND[timedelta64]: ...
+ def __rmul__(self: _ArrayFloat_co, other: _ArrayLikeTD64_co) -> NDArray[timedelta64]: ...
@overload
- def __rmul__(self: _ArrayND[object_], other: Any) -> Any: ...
+ def __rmul__(self: NDArray[object_], other: Any) -> Any: ...
@overload
- def __rmul__(self: _ArrayND[Any], other: _ArrayLikeObject_co) -> Any: ...
+ def __rmul__(self: NDArray[Any], other: _ArrayLikeObject_co) -> Any: ...
@overload
def __rmul__(
- self: _ArrayND[Union[bool_, number[Any], timedelta64]],
+ self: NDArray[Union[bool_, number[Any], timedelta64]],
other: _RecursiveSequence,
) -> Any: ...
@overload
- def __floordiv__(self: _ArrayND[Any], other: _NestedSequence[Union[str, bytes]]) -> NoReturn: ...
+ def __floordiv__(self: NDArray[Any], other: _NestedSequence[Union[str, bytes]]) -> NoReturn: ...
@overload
- def __floordiv__(self: _ArrayND[bool_], other: _ArrayLikeBool_co) -> _ArrayND[int8]: ... # type: ignore[misc]
+ def __floordiv__(self: NDArray[bool_], other: _ArrayLikeBool_co) -> NDArray[int8]: ... # type: ignore[misc]
@overload
- def __floordiv__(self: _ArrayUInt_co, other: _ArrayLikeUInt_co) -> _ArrayND[unsignedinteger[Any]]: ... # type: ignore[misc]
+ def __floordiv__(self: _ArrayUInt_co, other: _ArrayLikeUInt_co) -> NDArray[unsignedinteger[Any]]: ... # type: ignore[misc]
@overload
- def __floordiv__(self: _ArrayInt_co, other: _ArrayLikeInt_co) -> _ArrayND[signedinteger[Any]]: ... # type: ignore[misc]
+ def __floordiv__(self: _ArrayInt_co, other: _ArrayLikeInt_co) -> NDArray[signedinteger[Any]]: ... # type: ignore[misc]
@overload
- def __floordiv__(self: _ArrayFloat_co, other: _ArrayLikeFloat_co) -> _ArrayND[floating[Any]]: ... # type: ignore[misc]
+ def __floordiv__(self: _ArrayFloat_co, other: _ArrayLikeFloat_co) -> NDArray[floating[Any]]: ... # type: ignore[misc]
@overload
- def __floordiv__(self: _ArrayComplex_co, other: _ArrayLikeComplex_co) -> _ArrayND[complexfloating[Any, Any]]: ... # type: ignore[misc]
+ def __floordiv__(self: _ArrayComplex_co, other: _ArrayLikeComplex_co) -> NDArray[complexfloating[Any, Any]]: ... # type: ignore[misc]
@overload
- def __floordiv__(self: _ArrayND[timedelta64], other: _NestedSequence[_SupportsArray[dtype[timedelta64]]]) -> _ArrayND[int64]: ...
+ def __floordiv__(self: NDArray[timedelta64], other: _NestedSequence[_SupportsArray[dtype[timedelta64]]]) -> NDArray[int64]: ...
@overload
- def __floordiv__(self: _ArrayND[timedelta64], other: _ArrayLikeBool_co) -> NoReturn: ...
+ def __floordiv__(self: NDArray[timedelta64], other: _ArrayLikeBool_co) -> NoReturn: ...
@overload
- def __floordiv__(self: _ArrayND[timedelta64], other: _ArrayLikeFloat_co) -> _ArrayND[timedelta64]: ...
+ def __floordiv__(self: NDArray[timedelta64], other: _ArrayLikeFloat_co) -> NDArray[timedelta64]: ...
@overload
- def __floordiv__(self: _ArrayND[object_], other: Any) -> Any: ...
+ def __floordiv__(self: NDArray[object_], other: Any) -> Any: ...
@overload
- def __floordiv__(self: _ArrayND[Any], other: _ArrayLikeObject_co) -> Any: ...
+ def __floordiv__(self: NDArray[Any], other: _ArrayLikeObject_co) -> Any: ...
@overload
def __floordiv__(
- self: _ArrayND[Union[bool_, number[Any], timedelta64]],
+ self: NDArray[Union[bool_, number[Any], timedelta64]],
other: _RecursiveSequence,
) -> Any: ...
@overload
- def __rfloordiv__(self: _ArrayND[Any], other: _NestedSequence[Union[str, bytes]]) -> NoReturn: ...
+ def __rfloordiv__(self: NDArray[Any], other: _NestedSequence[Union[str, bytes]]) -> NoReturn: ...
@overload
- def __rfloordiv__(self: _ArrayND[bool_], other: _ArrayLikeBool_co) -> _ArrayND[int8]: ... # type: ignore[misc]
+ def __rfloordiv__(self: NDArray[bool_], other: _ArrayLikeBool_co) -> NDArray[int8]: ... # type: ignore[misc]
@overload
- def __rfloordiv__(self: _ArrayUInt_co, other: _ArrayLikeUInt_co) -> _ArrayND[unsignedinteger[Any]]: ... # type: ignore[misc]
+ def __rfloordiv__(self: _ArrayUInt_co, other: _ArrayLikeUInt_co) -> NDArray[unsignedinteger[Any]]: ... # type: ignore[misc]
@overload
- def __rfloordiv__(self: _ArrayInt_co, other: _ArrayLikeInt_co) -> _ArrayND[signedinteger[Any]]: ... # type: ignore[misc]
+ def __rfloordiv__(self: _ArrayInt_co, other: _ArrayLikeInt_co) -> NDArray[signedinteger[Any]]: ... # type: ignore[misc]
@overload
- def __rfloordiv__(self: _ArrayFloat_co, other: _ArrayLikeFloat_co) -> _ArrayND[floating[Any]]: ... # type: ignore[misc]
+ def __rfloordiv__(self: _ArrayFloat_co, other: _ArrayLikeFloat_co) -> NDArray[floating[Any]]: ... # type: ignore[misc]
@overload
- def __rfloordiv__(self: _ArrayComplex_co, other: _ArrayLikeComplex_co) -> _ArrayND[complexfloating[Any, Any]]: ... # type: ignore[misc]
+ def __rfloordiv__(self: _ArrayComplex_co, other: _ArrayLikeComplex_co) -> NDArray[complexfloating[Any, Any]]: ... # type: ignore[misc]
@overload
- def __rfloordiv__(self: _ArrayND[timedelta64], other: _NestedSequence[_SupportsArray[dtype[timedelta64]]]) -> _ArrayND[int64]: ...
+ def __rfloordiv__(self: NDArray[timedelta64], other: _NestedSequence[_SupportsArray[dtype[timedelta64]]]) -> NDArray[int64]: ...
@overload
- def __rfloordiv__(self: _ArrayND[bool_], other: _ArrayLikeTD64_co) -> NoReturn: ...
+ def __rfloordiv__(self: NDArray[bool_], other: _ArrayLikeTD64_co) -> NoReturn: ...
@overload
- def __rfloordiv__(self: _ArrayFloat_co, other: _ArrayLikeTD64_co) -> _ArrayND[timedelta64]: ...
+ def __rfloordiv__(self: _ArrayFloat_co, other: _ArrayLikeTD64_co) -> NDArray[timedelta64]: ...
@overload
- def __rfloordiv__(self: _ArrayND[object_], other: Any) -> Any: ...
+ def __rfloordiv__(self: NDArray[object_], other: Any) -> Any: ...
@overload
- def __rfloordiv__(self: _ArrayND[Any], other: _ArrayLikeObject_co) -> Any: ...
+ def __rfloordiv__(self: NDArray[Any], other: _ArrayLikeObject_co) -> Any: ...
@overload
def __rfloordiv__(
- self: _ArrayND[Union[bool_, number[Any], timedelta64]],
+ self: NDArray[Union[bool_, number[Any], timedelta64]],
other: _RecursiveSequence,
) -> Any: ...
@overload
- def __pow__(self: _ArrayND[Any], other: _NestedSequence[Union[str, bytes]]) -> NoReturn: ...
+ def __pow__(self: NDArray[Any], other: _NestedSequence[Union[str, bytes]]) -> NoReturn: ...
@overload
- def __pow__(self: _ArrayND[bool_], other: _ArrayLikeBool_co) -> _ArrayND[int8]: ... # type: ignore[misc]
+ def __pow__(self: NDArray[bool_], other: _ArrayLikeBool_co) -> NDArray[int8]: ... # type: ignore[misc]
@overload
- def __pow__(self: _ArrayUInt_co, other: _ArrayLikeUInt_co) -> _ArrayND[unsignedinteger[Any]]: ... # type: ignore[misc]
+ def __pow__(self: _ArrayUInt_co, other: _ArrayLikeUInt_co) -> NDArray[unsignedinteger[Any]]: ... # type: ignore[misc]
@overload
- def __pow__(self: _ArrayInt_co, other: _ArrayLikeInt_co) -> _ArrayND[signedinteger[Any]]: ... # type: ignore[misc]
+ def __pow__(self: _ArrayInt_co, other: _ArrayLikeInt_co) -> NDArray[signedinteger[Any]]: ... # type: ignore[misc]
@overload
- def __pow__(self: _ArrayFloat_co, other: _ArrayLikeFloat_co) -> _ArrayND[floating[Any]]: ... # type: ignore[misc]
+ def __pow__(self: _ArrayFloat_co, other: _ArrayLikeFloat_co) -> NDArray[floating[Any]]: ... # type: ignore[misc]
@overload
- def __pow__(self: _ArrayComplex_co, other: _ArrayLikeComplex_co) -> _ArrayND[complexfloating[Any, Any]]: ...
+ def __pow__(self: _ArrayComplex_co, other: _ArrayLikeComplex_co) -> NDArray[complexfloating[Any, Any]]: ...
@overload
- def __pow__(self: _ArrayND[object_], other: Any) -> Any: ...
+ def __pow__(self: NDArray[object_], other: Any) -> Any: ...
@overload
- def __pow__(self: _ArrayND[Any], other: _ArrayLikeObject_co) -> Any: ...
+ def __pow__(self: NDArray[Any], other: _ArrayLikeObject_co) -> Any: ...
@overload
def __pow__(
- self: _ArrayND[Union[bool_, number[Any]]],
+ self: NDArray[Union[bool_, number[Any]]],
other: _RecursiveSequence,
) -> Any: ...
@overload
- def __rpow__(self: _ArrayND[Any], other: _NestedSequence[Union[str, bytes]]) -> NoReturn: ...
+ def __rpow__(self: NDArray[Any], other: _NestedSequence[Union[str, bytes]]) -> NoReturn: ...
@overload
- def __rpow__(self: _ArrayND[bool_], other: _ArrayLikeBool_co) -> _ArrayND[int8]: ... # type: ignore[misc]
+ def __rpow__(self: NDArray[bool_], other: _ArrayLikeBool_co) -> NDArray[int8]: ... # type: ignore[misc]
@overload
- def __rpow__(self: _ArrayUInt_co, other: _ArrayLikeUInt_co) -> _ArrayND[unsignedinteger[Any]]: ... # type: ignore[misc]
+ def __rpow__(self: _ArrayUInt_co, other: _ArrayLikeUInt_co) -> NDArray[unsignedinteger[Any]]: ... # type: ignore[misc]
@overload
- def __rpow__(self: _ArrayInt_co, other: _ArrayLikeInt_co) -> _ArrayND[signedinteger[Any]]: ... # type: ignore[misc]
+ def __rpow__(self: _ArrayInt_co, other: _ArrayLikeInt_co) -> NDArray[signedinteger[Any]]: ... # type: ignore[misc]
@overload
- def __rpow__(self: _ArrayFloat_co, other: _ArrayLikeFloat_co) -> _ArrayND[floating[Any]]: ... # type: ignore[misc]
+ def __rpow__(self: _ArrayFloat_co, other: _ArrayLikeFloat_co) -> NDArray[floating[Any]]: ... # type: ignore[misc]
@overload
- def __rpow__(self: _ArrayComplex_co, other: _ArrayLikeComplex_co) -> _ArrayND[complexfloating[Any, Any]]: ...
+ def __rpow__(self: _ArrayComplex_co, other: _ArrayLikeComplex_co) -> NDArray[complexfloating[Any, Any]]: ...
@overload
- def __rpow__(self: _ArrayND[object_], other: Any) -> Any: ...
+ def __rpow__(self: NDArray[object_], other: Any) -> Any: ...
@overload
- def __rpow__(self: _ArrayND[Any], other: _ArrayLikeObject_co) -> Any: ...
+ def __rpow__(self: NDArray[Any], other: _ArrayLikeObject_co) -> Any: ...
@overload
def __rpow__(
- self: _ArrayND[Union[bool_, number[Any]]],
+ self: NDArray[Union[bool_, number[Any]]],
other: _RecursiveSequence,
) -> Any: ...
@overload
- def __truediv__(self: _ArrayND[Any], other: _NestedSequence[Union[str, bytes]]) -> NoReturn: ...
+ def __truediv__(self: NDArray[Any], other: _NestedSequence[Union[str, bytes]]) -> NoReturn: ...
@overload
- def __truediv__(self: _ArrayInt_co, other: _ArrayInt_co) -> _ArrayND[float64]: ... # type: ignore[misc]
+ def __truediv__(self: _ArrayInt_co, other: _ArrayInt_co) -> NDArray[float64]: ... # type: ignore[misc]
@overload
- def __truediv__(self: _ArrayFloat_co, other: _ArrayLikeFloat_co) -> _ArrayND[floating[Any]]: ... # type: ignore[misc]
+ def __truediv__(self: _ArrayFloat_co, other: _ArrayLikeFloat_co) -> NDArray[floating[Any]]: ... # type: ignore[misc]
@overload
- def __truediv__(self: _ArrayComplex_co, other: _ArrayLikeComplex_co) -> _ArrayND[complexfloating[Any, Any]]: ... # type: ignore[misc]
+ def __truediv__(self: _ArrayComplex_co, other: _ArrayLikeComplex_co) -> NDArray[complexfloating[Any, Any]]: ... # type: ignore[misc]
@overload
- def __truediv__(self: _ArrayND[timedelta64], other: _NestedSequence[_SupportsArray[dtype[timedelta64]]]) -> _ArrayND[float64]: ...
+ def __truediv__(self: NDArray[timedelta64], other: _NestedSequence[_SupportsArray[dtype[timedelta64]]]) -> NDArray[float64]: ...
@overload
- def __truediv__(self: _ArrayND[timedelta64], other: _ArrayLikeBool_co) -> NoReturn: ...
+ def __truediv__(self: NDArray[timedelta64], other: _ArrayLikeBool_co) -> NoReturn: ...
@overload
- def __truediv__(self: _ArrayND[timedelta64], other: _ArrayLikeFloat_co) -> _ArrayND[timedelta64]: ...
+ def __truediv__(self: NDArray[timedelta64], other: _ArrayLikeFloat_co) -> NDArray[timedelta64]: ...
@overload
- def __truediv__(self: _ArrayND[object_], other: Any) -> Any: ...
+ def __truediv__(self: NDArray[object_], other: Any) -> Any: ...
@overload
- def __truediv__(self: _ArrayND[Any], other: _ArrayLikeObject_co) -> Any: ...
+ def __truediv__(self: NDArray[Any], other: _ArrayLikeObject_co) -> Any: ...
@overload
def __truediv__(
- self: _ArrayND[Union[bool_, number[Any], timedelta64]],
+ self: NDArray[Union[bool_, number[Any], timedelta64]],
other: _RecursiveSequence,
) -> Any: ...
@overload
- def __rtruediv__(self: _ArrayND[Any], other: _NestedSequence[Union[str, bytes]]) -> NoReturn: ...
+ def __rtruediv__(self: NDArray[Any], other: _NestedSequence[Union[str, bytes]]) -> NoReturn: ...
@overload
- def __rtruediv__(self: _ArrayInt_co, other: _ArrayInt_co) -> _ArrayND[float64]: ... # type: ignore[misc]
+ def __rtruediv__(self: _ArrayInt_co, other: _ArrayInt_co) -> NDArray[float64]: ... # type: ignore[misc]
@overload
- def __rtruediv__(self: _ArrayFloat_co, other: _ArrayLikeFloat_co) -> _ArrayND[floating[Any]]: ... # type: ignore[misc]
+ def __rtruediv__(self: _ArrayFloat_co, other: _ArrayLikeFloat_co) -> NDArray[floating[Any]]: ... # type: ignore[misc]
@overload
- def __rtruediv__(self: _ArrayComplex_co, other: _ArrayLikeComplex_co) -> _ArrayND[complexfloating[Any, Any]]: ... # type: ignore[misc]
+ def __rtruediv__(self: _ArrayComplex_co, other: _ArrayLikeComplex_co) -> NDArray[complexfloating[Any, Any]]: ... # type: ignore[misc]
@overload
- def __rtruediv__(self: _ArrayND[timedelta64], other: _NestedSequence[_SupportsArray[dtype[timedelta64]]]) -> _ArrayND[float64]: ...
+ def __rtruediv__(self: NDArray[timedelta64], other: _NestedSequence[_SupportsArray[dtype[timedelta64]]]) -> NDArray[float64]: ...
@overload
- def __rtruediv__(self: _ArrayND[bool_], other: _ArrayLikeTD64_co) -> NoReturn: ...
+ def __rtruediv__(self: NDArray[bool_], other: _ArrayLikeTD64_co) -> NoReturn: ...
@overload
- def __rtruediv__(self: _ArrayFloat_co, other: _ArrayLikeTD64_co) -> _ArrayND[timedelta64]: ...
+ def __rtruediv__(self: _ArrayFloat_co, other: _ArrayLikeTD64_co) -> NDArray[timedelta64]: ...
@overload
- def __rtruediv__(self: _ArrayND[object_], other: Any) -> Any: ...
+ def __rtruediv__(self: NDArray[object_], other: Any) -> Any: ...
@overload
- def __rtruediv__(self: _ArrayND[Any], other: _ArrayLikeObject_co) -> Any: ...
+ def __rtruediv__(self: NDArray[Any], other: _ArrayLikeObject_co) -> Any: ...
@overload
def __rtruediv__(
- self: _ArrayND[Union[bool_, number[Any], timedelta64]],
+ self: NDArray[Union[bool_, number[Any], timedelta64]],
other: _RecursiveSequence,
) -> Any: ...
@overload
- def __lshift__(self: _ArrayND[Any], other: _NestedSequence[Union[str, bytes]]) -> NoReturn: ...
+ def __lshift__(self: NDArray[Any], other: _NestedSequence[Union[str, bytes]]) -> NoReturn: ...
@overload
- def __lshift__(self: _ArrayND[bool_], other: _ArrayLikeBool_co) -> _ArrayND[int8]: ... # type: ignore[misc]
+ def __lshift__(self: NDArray[bool_], other: _ArrayLikeBool_co) -> NDArray[int8]: ... # type: ignore[misc]
@overload
- def __lshift__(self: _ArrayUInt_co, other: _ArrayLikeUInt_co) -> _ArrayND[unsignedinteger[Any]]: ... # type: ignore[misc]
+ def __lshift__(self: _ArrayUInt_co, other: _ArrayLikeUInt_co) -> NDArray[unsignedinteger[Any]]: ... # type: ignore[misc]
@overload
- def __lshift__(self: _ArrayInt_co, other: _ArrayLikeInt_co) -> _ArrayND[signedinteger[Any]]: ...
+ def __lshift__(self: _ArrayInt_co, other: _ArrayLikeInt_co) -> NDArray[signedinteger[Any]]: ...
@overload
- def __lshift__(self: _ArrayND[object_], other: Any) -> Any: ...
+ def __lshift__(self: NDArray[object_], other: Any) -> Any: ...
@overload
- def __lshift__(self: _ArrayND[Any], other: _ArrayLikeObject_co) -> Any: ...
+ def __lshift__(self: NDArray[Any], other: _ArrayLikeObject_co) -> Any: ...
@overload
def __lshift__(
- self: _ArrayND[Union[bool_, integer[Any]]],
+ self: NDArray[Union[bool_, integer[Any]]],
other: _RecursiveSequence,
) -> Any: ...
@overload
- def __rlshift__(self: _ArrayND[Any], other: _NestedSequence[Union[str, bytes]]) -> NoReturn: ...
+ def __rlshift__(self: NDArray[Any], other: _NestedSequence[Union[str, bytes]]) -> NoReturn: ...
@overload
- def __rlshift__(self: _ArrayND[bool_], other: _ArrayLikeBool_co) -> _ArrayND[int8]: ... # type: ignore[misc]
+ def __rlshift__(self: NDArray[bool_], other: _ArrayLikeBool_co) -> NDArray[int8]: ... # type: ignore[misc]
@overload
- def __rlshift__(self: _ArrayUInt_co, other: _ArrayLikeUInt_co) -> _ArrayND[unsignedinteger[Any]]: ... # type: ignore[misc]
+ def __rlshift__(self: _ArrayUInt_co, other: _ArrayLikeUInt_co) -> NDArray[unsignedinteger[Any]]: ... # type: ignore[misc]
@overload
- def __rlshift__(self: _ArrayInt_co, other: _ArrayLikeInt_co) -> _ArrayND[signedinteger[Any]]: ...
+ def __rlshift__(self: _ArrayInt_co, other: _ArrayLikeInt_co) -> NDArray[signedinteger[Any]]: ...
@overload
- def __rlshift__(self: _ArrayND[object_], other: Any) -> Any: ...
+ def __rlshift__(self: NDArray[object_], other: Any) -> Any: ...
@overload
- def __rlshift__(self: _ArrayND[Any], other: _ArrayLikeObject_co) -> Any: ...
+ def __rlshift__(self: NDArray[Any], other: _ArrayLikeObject_co) -> Any: ...
@overload
def __rlshift__(
- self: _ArrayND[Union[bool_, integer[Any]]],
+ self: NDArray[Union[bool_, integer[Any]]],
other: _RecursiveSequence,
) -> Any: ...
@overload
- def __rshift__(self: _ArrayND[Any], other: _NestedSequence[Union[str, bytes]]) -> NoReturn: ...
+ def __rshift__(self: NDArray[Any], other: _NestedSequence[Union[str, bytes]]) -> NoReturn: ...
@overload
- def __rshift__(self: _ArrayND[bool_], other: _ArrayLikeBool_co) -> _ArrayND[int8]: ... # type: ignore[misc]
+ def __rshift__(self: NDArray[bool_], other: _ArrayLikeBool_co) -> NDArray[int8]: ... # type: ignore[misc]
@overload
- def __rshift__(self: _ArrayUInt_co, other: _ArrayLikeUInt_co) -> _ArrayND[unsignedinteger[Any]]: ... # type: ignore[misc]
+ def __rshift__(self: _ArrayUInt_co, other: _ArrayLikeUInt_co) -> NDArray[unsignedinteger[Any]]: ... # type: ignore[misc]
@overload
- def __rshift__(self: _ArrayInt_co, other: _ArrayLikeInt_co) -> _ArrayND[signedinteger[Any]]: ...
+ def __rshift__(self: _ArrayInt_co, other: _ArrayLikeInt_co) -> NDArray[signedinteger[Any]]: ...
@overload
- def __rshift__(self: _ArrayND[object_], other: Any) -> Any: ...
+ def __rshift__(self: NDArray[object_], other: Any) -> Any: ...
@overload
- def __rshift__(self: _ArrayND[Any], other: _ArrayLikeObject_co) -> Any: ...
+ def __rshift__(self: NDArray[Any], other: _ArrayLikeObject_co) -> Any: ...
@overload
def __rshift__(
- self: _ArrayND[Union[bool_, integer[Any]]],
+ self: NDArray[Union[bool_, integer[Any]]],
other: _RecursiveSequence,
) -> Any: ...
@overload
- def __rrshift__(self: _ArrayND[Any], other: _NestedSequence[Union[str, bytes]]) -> NoReturn: ...
+ def __rrshift__(self: NDArray[Any], other: _NestedSequence[Union[str, bytes]]) -> NoReturn: ...
@overload
- def __rrshift__(self: _ArrayND[bool_], other: _ArrayLikeBool_co) -> _ArrayND[int8]: ... # type: ignore[misc]
+ def __rrshift__(self: NDArray[bool_], other: _ArrayLikeBool_co) -> NDArray[int8]: ... # type: ignore[misc]
@overload
- def __rrshift__(self: _ArrayUInt_co, other: _ArrayLikeUInt_co) -> _ArrayND[unsignedinteger[Any]]: ... # type: ignore[misc]
+ def __rrshift__(self: _ArrayUInt_co, other: _ArrayLikeUInt_co) -> NDArray[unsignedinteger[Any]]: ... # type: ignore[misc]
@overload
- def __rrshift__(self: _ArrayInt_co, other: _ArrayLikeInt_co) -> _ArrayND[signedinteger[Any]]: ...
+ def __rrshift__(self: _ArrayInt_co, other: _ArrayLikeInt_co) -> NDArray[signedinteger[Any]]: ...
@overload
- def __rrshift__(self: _ArrayND[object_], other: Any) -> Any: ...
+ def __rrshift__(self: NDArray[object_], other: Any) -> Any: ...
@overload
- def __rrshift__(self: _ArrayND[Any], other: _ArrayLikeObject_co) -> Any: ...
+ def __rrshift__(self: NDArray[Any], other: _ArrayLikeObject_co) -> Any: ...
@overload
def __rrshift__(
- self: _ArrayND[Union[bool_, integer[Any]]],
+ self: NDArray[Union[bool_, integer[Any]]],
other: _RecursiveSequence,
) -> Any: ...
@overload
- def __and__(self: _ArrayND[Any], other: _NestedSequence[Union[str, bytes]]) -> NoReturn: ...
+ def __and__(self: NDArray[Any], other: _NestedSequence[Union[str, bytes]]) -> NoReturn: ...
@overload
- def __and__(self: _ArrayND[bool_], other: _ArrayLikeBool_co) -> _ArrayND[bool_]: ... # type: ignore[misc]
+ def __and__(self: NDArray[bool_], other: _ArrayLikeBool_co) -> NDArray[bool_]: ... # type: ignore[misc]
@overload
- def __and__(self: _ArrayUInt_co, other: _ArrayLikeUInt_co) -> _ArrayND[unsignedinteger[Any]]: ... # type: ignore[misc]
+ def __and__(self: _ArrayUInt_co, other: _ArrayLikeUInt_co) -> NDArray[unsignedinteger[Any]]: ... # type: ignore[misc]
@overload
- def __and__(self: _ArrayInt_co, other: _ArrayLikeInt_co) -> _ArrayND[signedinteger[Any]]: ...
+ def __and__(self: _ArrayInt_co, other: _ArrayLikeInt_co) -> NDArray[signedinteger[Any]]: ...
@overload
- def __and__(self: _ArrayND[object_], other: Any) -> Any: ...
+ def __and__(self: NDArray[object_], other: Any) -> Any: ...
@overload
- def __and__(self: _ArrayND[Any], other: _ArrayLikeObject_co) -> Any: ...
+ def __and__(self: NDArray[Any], other: _ArrayLikeObject_co) -> Any: ...
@overload
def __and__(
- self: _ArrayND[Union[bool_, integer[Any]]],
+ self: NDArray[Union[bool_, integer[Any]]],
other: _RecursiveSequence,
) -> Any: ...
@overload
- def __rand__(self: _ArrayND[Any], other: _NestedSequence[Union[str, bytes]]) -> NoReturn: ...
+ def __rand__(self: NDArray[Any], other: _NestedSequence[Union[str, bytes]]) -> NoReturn: ...
@overload
- def __rand__(self: _ArrayND[bool_], other: _ArrayLikeBool_co) -> _ArrayND[bool_]: ... # type: ignore[misc]
+ def __rand__(self: NDArray[bool_], other: _ArrayLikeBool_co) -> NDArray[bool_]: ... # type: ignore[misc]
@overload
- def __rand__(self: _ArrayUInt_co, other: _ArrayLikeUInt_co) -> _ArrayND[unsignedinteger[Any]]: ... # type: ignore[misc]
+ def __rand__(self: _ArrayUInt_co, other: _ArrayLikeUInt_co) -> NDArray[unsignedinteger[Any]]: ... # type: ignore[misc]
@overload
- def __rand__(self: _ArrayInt_co, other: _ArrayLikeInt_co) -> _ArrayND[signedinteger[Any]]: ...
+ def __rand__(self: _ArrayInt_co, other: _ArrayLikeInt_co) -> NDArray[signedinteger[Any]]: ...
@overload
- def __rand__(self: _ArrayND[object_], other: Any) -> Any: ...
+ def __rand__(self: NDArray[object_], other: Any) -> Any: ...
@overload
- def __rand__(self: _ArrayND[Any], other: _ArrayLikeObject_co) -> Any: ...
+ def __rand__(self: NDArray[Any], other: _ArrayLikeObject_co) -> Any: ...
@overload
def __rand__(
- self: _ArrayND[Union[bool_, integer[Any]]],
+ self: NDArray[Union[bool_, integer[Any]]],
other: _RecursiveSequence,
) -> Any: ...
@overload
- def __xor__(self: _ArrayND[Any], other: _NestedSequence[Union[str, bytes]]) -> NoReturn: ...
+ def __xor__(self: NDArray[Any], other: _NestedSequence[Union[str, bytes]]) -> NoReturn: ...
@overload
- def __xor__(self: _ArrayND[bool_], other: _ArrayLikeBool_co) -> _ArrayND[bool_]: ... # type: ignore[misc]
+ def __xor__(self: NDArray[bool_], other: _ArrayLikeBool_co) -> NDArray[bool_]: ... # type: ignore[misc]
@overload
- def __xor__(self: _ArrayUInt_co, other: _ArrayLikeUInt_co) -> _ArrayND[unsignedinteger[Any]]: ... # type: ignore[misc]
+ def __xor__(self: _ArrayUInt_co, other: _ArrayLikeUInt_co) -> NDArray[unsignedinteger[Any]]: ... # type: ignore[misc]
@overload
- def __xor__(self: _ArrayInt_co, other: _ArrayLikeInt_co) -> _ArrayND[signedinteger[Any]]: ...
+ def __xor__(self: _ArrayInt_co, other: _ArrayLikeInt_co) -> NDArray[signedinteger[Any]]: ...
@overload
- def __xor__(self: _ArrayND[object_], other: Any) -> Any: ...
+ def __xor__(self: NDArray[object_], other: Any) -> Any: ...
@overload
- def __xor__(self: _ArrayND[Any], other: _ArrayLikeObject_co) -> Any: ...
+ def __xor__(self: NDArray[Any], other: _ArrayLikeObject_co) -> Any: ...
@overload
def __xor__(
- self: _ArrayND[Union[bool_, integer[Any]]],
+ self: NDArray[Union[bool_, integer[Any]]],
other: _RecursiveSequence,
) -> Any: ...
@overload
- def __rxor__(self: _ArrayND[Any], other: _NestedSequence[Union[str, bytes]]) -> NoReturn: ...
+ def __rxor__(self: NDArray[Any], other: _NestedSequence[Union[str, bytes]]) -> NoReturn: ...
@overload
- def __rxor__(self: _ArrayND[bool_], other: _ArrayLikeBool_co) -> _ArrayND[bool_]: ... # type: ignore[misc]
+ def __rxor__(self: NDArray[bool_], other: _ArrayLikeBool_co) -> NDArray[bool_]: ... # type: ignore[misc]
@overload
- def __rxor__(self: _ArrayUInt_co, other: _ArrayLikeUInt_co) -> _ArrayND[unsignedinteger[Any]]: ... # type: ignore[misc]
+ def __rxor__(self: _ArrayUInt_co, other: _ArrayLikeUInt_co) -> NDArray[unsignedinteger[Any]]: ... # type: ignore[misc]
@overload
- def __rxor__(self: _ArrayInt_co, other: _ArrayLikeInt_co) -> _ArrayND[signedinteger[Any]]: ...
+ def __rxor__(self: _ArrayInt_co, other: _ArrayLikeInt_co) -> NDArray[signedinteger[Any]]: ...
@overload
- def __rxor__(self: _ArrayND[object_], other: Any) -> Any: ...
+ def __rxor__(self: NDArray[object_], other: Any) -> Any: ...
@overload
- def __rxor__(self: _ArrayND[Any], other: _ArrayLikeObject_co) -> Any: ...
+ def __rxor__(self: NDArray[Any], other: _ArrayLikeObject_co) -> Any: ...
@overload
def __rxor__(
- self: _ArrayND[Union[bool_, integer[Any]]],
+ self: NDArray[Union[bool_, integer[Any]]],
other: _RecursiveSequence,
) -> Any: ...
@overload
- def __or__(self: _ArrayND[Any], other: _NestedSequence[Union[str, bytes]]) -> NoReturn: ...
+ def __or__(self: NDArray[Any], other: _NestedSequence[Union[str, bytes]]) -> NoReturn: ...
@overload
- def __or__(self: _ArrayND[bool_], other: _ArrayLikeBool_co) -> _ArrayND[bool_]: ... # type: ignore[misc]
+ def __or__(self: NDArray[bool_], other: _ArrayLikeBool_co) -> NDArray[bool_]: ... # type: ignore[misc]
@overload
- def __or__(self: _ArrayUInt_co, other: _ArrayLikeUInt_co) -> _ArrayND[unsignedinteger[Any]]: ... # type: ignore[misc]
+ def __or__(self: _ArrayUInt_co, other: _ArrayLikeUInt_co) -> NDArray[unsignedinteger[Any]]: ... # type: ignore[misc]
@overload
- def __or__(self: _ArrayInt_co, other: _ArrayLikeInt_co) -> _ArrayND[signedinteger[Any]]: ...
+ def __or__(self: _ArrayInt_co, other: _ArrayLikeInt_co) -> NDArray[signedinteger[Any]]: ...
@overload
- def __or__(self: _ArrayND[object_], other: Any) -> Any: ...
+ def __or__(self: NDArray[object_], other: Any) -> Any: ...
@overload
- def __or__(self: _ArrayND[Any], other: _ArrayLikeObject_co) -> Any: ...
+ def __or__(self: NDArray[Any], other: _ArrayLikeObject_co) -> Any: ...
@overload
def __or__(
- self: _ArrayND[Union[bool_, integer[Any]]],
+ self: NDArray[Union[bool_, integer[Any]]],
other: _RecursiveSequence,
) -> Any: ...
@overload
- def __ror__(self: _ArrayND[Any], other: _NestedSequence[Union[str, bytes]]) -> NoReturn: ...
+ def __ror__(self: NDArray[Any], other: _NestedSequence[Union[str, bytes]]) -> NoReturn: ...
@overload
- def __ror__(self: _ArrayND[bool_], other: _ArrayLikeBool_co) -> _ArrayND[bool_]: ... # type: ignore[misc]
+ def __ror__(self: NDArray[bool_], other: _ArrayLikeBool_co) -> NDArray[bool_]: ... # type: ignore[misc]
@overload
- def __ror__(self: _ArrayUInt_co, other: _ArrayLikeUInt_co) -> _ArrayND[unsignedinteger[Any]]: ... # type: ignore[misc]
+ def __ror__(self: _ArrayUInt_co, other: _ArrayLikeUInt_co) -> NDArray[unsignedinteger[Any]]: ... # type: ignore[misc]
@overload
- def __ror__(self: _ArrayInt_co, other: _ArrayLikeInt_co) -> _ArrayND[signedinteger[Any]]: ...
+ def __ror__(self: _ArrayInt_co, other: _ArrayLikeInt_co) -> NDArray[signedinteger[Any]]: ...
@overload
- def __ror__(self: _ArrayND[object_], other: Any) -> Any: ...
+ def __ror__(self: NDArray[object_], other: Any) -> Any: ...
@overload
- def __ror__(self: _ArrayND[Any], other: _ArrayLikeObject_co) -> Any: ...
+ def __ror__(self: NDArray[Any], other: _ArrayLikeObject_co) -> Any: ...
@overload
def __ror__(
- self: _ArrayND[Union[bool_, integer[Any]]],
+ self: NDArray[Union[bool_, integer[Any]]],
other: _RecursiveSequence,
) -> Any: ...
# `np.generic` does not support inplace operations
@overload # type: ignore[misc]
- def __iadd__(self: _ArrayND[Any], other: _NestedSequence[Union[str, bytes]]) -> NoReturn: ...
+ def __iadd__(self: NDArray[Any], other: _NestedSequence[Union[str, bytes]]) -> NoReturn: ...
@overload
- def __iadd__(self: _ArrayND[bool_], other: _ArrayLikeBool_co) -> _ArrayND[bool_]: ...
+ def __iadd__(self: NDArray[bool_], other: _ArrayLikeBool_co) -> NDArray[bool_]: ...
@overload
- def __iadd__(self: _ArrayND[unsignedinteger[_NBit1]], other: _ArrayLikeUInt_co) -> _ArrayND[unsignedinteger[_NBit1]]: ...
+ def __iadd__(self: NDArray[unsignedinteger[_NBit1]], other: _ArrayLikeUInt_co) -> NDArray[unsignedinteger[_NBit1]]: ...
@overload
- def __iadd__(self: _ArrayND[signedinteger[_NBit1]], other: _ArrayLikeInt_co) -> _ArrayND[signedinteger[_NBit1]]: ...
+ def __iadd__(self: NDArray[signedinteger[_NBit1]], other: _ArrayLikeInt_co) -> NDArray[signedinteger[_NBit1]]: ...
@overload
- def __iadd__(self: _ArrayND[floating[_NBit1]], other: _ArrayLikeFloat_co) -> _ArrayND[floating[_NBit1]]: ...
+ def __iadd__(self: NDArray[floating[_NBit1]], other: _ArrayLikeFloat_co) -> NDArray[floating[_NBit1]]: ...
@overload
- def __iadd__(self: _ArrayND[complexfloating[_NBit1, _NBit1]], other: _ArrayLikeComplex_co) -> _ArrayND[complexfloating[_NBit1, _NBit1]]: ...
+ def __iadd__(self: NDArray[complexfloating[_NBit1, _NBit1]], other: _ArrayLikeComplex_co) -> NDArray[complexfloating[_NBit1, _NBit1]]: ...
@overload
- def __iadd__(self: _ArrayND[timedelta64], other: _ArrayLikeTD64_co) -> _ArrayND[timedelta64]: ...
+ def __iadd__(self: NDArray[timedelta64], other: _ArrayLikeTD64_co) -> NDArray[timedelta64]: ...
@overload
- def __iadd__(self: _ArrayND[datetime64], other: _ArrayLikeTD64_co) -> _ArrayND[datetime64]: ...
+ def __iadd__(self: NDArray[datetime64], other: _ArrayLikeTD64_co) -> NDArray[datetime64]: ...
@overload
- def __iadd__(self: _ArrayND[object_], other: Any) -> _ArrayND[object_]: ...
+ def __iadd__(self: NDArray[object_], other: Any) -> NDArray[object_]: ...
@overload
- def __iadd__(self: _ArrayND[_ScalarType], other: _RecursiveSequence) -> _ArrayND[_ScalarType]: ...
+ def __iadd__(self: NDArray[_ScalarType], other: _RecursiveSequence) -> NDArray[_ScalarType]: ...
@overload # type: ignore[misc]
- def __isub__(self: _ArrayND[Any], other: _NestedSequence[Union[str, bytes]]) -> NoReturn: ...
+ def __isub__(self: NDArray[Any], other: _NestedSequence[Union[str, bytes]]) -> NoReturn: ...
@overload
- def __isub__(self: _ArrayND[unsignedinteger[_NBit1]], other: _ArrayLikeUInt_co) -> _ArrayND[unsignedinteger[_NBit1]]: ...
+ def __isub__(self: NDArray[unsignedinteger[_NBit1]], other: _ArrayLikeUInt_co) -> NDArray[unsignedinteger[_NBit1]]: ...
@overload
- def __isub__(self: _ArrayND[signedinteger[_NBit1]], other: _ArrayLikeInt_co) -> _ArrayND[signedinteger[_NBit1]]: ...
+ def __isub__(self: NDArray[signedinteger[_NBit1]], other: _ArrayLikeInt_co) -> NDArray[signedinteger[_NBit1]]: ...
@overload
- def __isub__(self: _ArrayND[floating[_NBit1]], other: _ArrayLikeFloat_co) -> _ArrayND[floating[_NBit1]]: ...
+ def __isub__(self: NDArray[floating[_NBit1]], other: _ArrayLikeFloat_co) -> NDArray[floating[_NBit1]]: ...
@overload
- def __isub__(self: _ArrayND[complexfloating[_NBit1, _NBit1]], other: _ArrayLikeComplex_co) -> _ArrayND[complexfloating[_NBit1, _NBit1]]: ...
+ def __isub__(self: NDArray[complexfloating[_NBit1, _NBit1]], other: _ArrayLikeComplex_co) -> NDArray[complexfloating[_NBit1, _NBit1]]: ...
@overload
- def __isub__(self: _ArrayND[timedelta64], other: _ArrayLikeTD64_co) -> _ArrayND[timedelta64]: ...
+ def __isub__(self: NDArray[timedelta64], other: _ArrayLikeTD64_co) -> NDArray[timedelta64]: ...
@overload
- def __isub__(self: _ArrayND[datetime64], other: _ArrayLikeTD64_co) -> _ArrayND[datetime64]: ...
+ def __isub__(self: NDArray[datetime64], other: _ArrayLikeTD64_co) -> NDArray[datetime64]: ...
@overload
- def __isub__(self: _ArrayND[object_], other: Any) -> _ArrayND[object_]: ...
+ def __isub__(self: NDArray[object_], other: Any) -> NDArray[object_]: ...
@overload
- def __isub__(self: _ArrayND[_ScalarType], other: _RecursiveSequence) -> _ArrayND[_ScalarType]: ...
+ def __isub__(self: NDArray[_ScalarType], other: _RecursiveSequence) -> NDArray[_ScalarType]: ...
@overload # type: ignore[misc]
- def __imul__(self: _ArrayND[Any], other: _NestedSequence[Union[str, bytes]]) -> NoReturn: ...
+ def __imul__(self: NDArray[Any], other: _NestedSequence[Union[str, bytes]]) -> NoReturn: ...
@overload
- def __imul__(self: _ArrayND[bool_], other: _ArrayLikeBool_co) -> _ArrayND[bool_]: ...
+ def __imul__(self: NDArray[bool_], other: _ArrayLikeBool_co) -> NDArray[bool_]: ...
@overload
- def __imul__(self: _ArrayND[unsignedinteger[_NBit1]], other: _ArrayLikeUInt_co) -> _ArrayND[unsignedinteger[_NBit1]]: ...
+ def __imul__(self: NDArray[unsignedinteger[_NBit1]], other: _ArrayLikeUInt_co) -> NDArray[unsignedinteger[_NBit1]]: ...
@overload
- def __imul__(self: _ArrayND[signedinteger[_NBit1]], other: _ArrayLikeInt_co) -> _ArrayND[signedinteger[_NBit1]]: ...
+ def __imul__(self: NDArray[signedinteger[_NBit1]], other: _ArrayLikeInt_co) -> NDArray[signedinteger[_NBit1]]: ...
@overload
- def __imul__(self: _ArrayND[floating[_NBit1]], other: _ArrayLikeFloat_co) -> _ArrayND[floating[_NBit1]]: ...
+ def __imul__(self: NDArray[floating[_NBit1]], other: _ArrayLikeFloat_co) -> NDArray[floating[_NBit1]]: ...
@overload
- def __imul__(self: _ArrayND[complexfloating[_NBit1, _NBit1]], other: _ArrayLikeComplex_co) -> _ArrayND[complexfloating[_NBit1, _NBit1]]: ...
+ def __imul__(self: NDArray[complexfloating[_NBit1, _NBit1]], other: _ArrayLikeComplex_co) -> NDArray[complexfloating[_NBit1, _NBit1]]: ...
@overload
- def __imul__(self: _ArrayND[timedelta64], other: _ArrayLikeFloat_co) -> _ArrayND[timedelta64]: ...
+ def __imul__(self: NDArray[timedelta64], other: _ArrayLikeFloat_co) -> NDArray[timedelta64]: ...
@overload
- def __imul__(self: _ArrayND[object_], other: Any) -> _ArrayND[object_]: ...
+ def __imul__(self: NDArray[object_], other: Any) -> NDArray[object_]: ...
@overload
- def __imul__(self: _ArrayND[_ScalarType], other: _RecursiveSequence) -> _ArrayND[_ScalarType]: ...
+ def __imul__(self: NDArray[_ScalarType], other: _RecursiveSequence) -> NDArray[_ScalarType]: ...
@overload # type: ignore[misc]
- def __itruediv__(self: _ArrayND[Any], other: _NestedSequence[Union[str, bytes]]) -> NoReturn: ...
+ def __itruediv__(self: NDArray[Any], other: _NestedSequence[Union[str, bytes]]) -> NoReturn: ...
@overload
- def __itruediv__(self: _ArrayND[floating[_NBit1]], other: _ArrayLikeFloat_co) -> _ArrayND[floating[_NBit1]]: ...
+ def __itruediv__(self: NDArray[floating[_NBit1]], other: _ArrayLikeFloat_co) -> NDArray[floating[_NBit1]]: ...
@overload
- def __itruediv__(self: _ArrayND[complexfloating[_NBit1, _NBit1]], other: _ArrayLikeComplex_co) -> _ArrayND[complexfloating[_NBit1, _NBit1]]: ...
+ def __itruediv__(self: NDArray[complexfloating[_NBit1, _NBit1]], other: _ArrayLikeComplex_co) -> NDArray[complexfloating[_NBit1, _NBit1]]: ...
@overload
- def __itruediv__(self: _ArrayND[timedelta64], other: _ArrayLikeBool_co) -> NoReturn: ...
+ def __itruediv__(self: NDArray[timedelta64], other: _ArrayLikeBool_co) -> NoReturn: ...
@overload
- def __itruediv__(self: _ArrayND[timedelta64], other: _ArrayLikeInt_co) -> _ArrayND[timedelta64]: ...
+ def __itruediv__(self: NDArray[timedelta64], other: _ArrayLikeInt_co) -> NDArray[timedelta64]: ...
@overload
- def __itruediv__(self: _ArrayND[object_], other: Any) -> _ArrayND[object_]: ...
+ def __itruediv__(self: NDArray[object_], other: Any) -> NDArray[object_]: ...
@overload
- def __itruediv__(self: _ArrayND[_ScalarType], other: _RecursiveSequence) -> _ArrayND[_ScalarType]: ...
+ def __itruediv__(self: NDArray[_ScalarType], other: _RecursiveSequence) -> NDArray[_ScalarType]: ...
@overload # type: ignore[misc]
- def __ifloordiv__(self: _ArrayND[Any], other: _NestedSequence[Union[str, bytes]]) -> NoReturn: ...
+ def __ifloordiv__(self: NDArray[Any], other: _NestedSequence[Union[str, bytes]]) -> NoReturn: ...
@overload
- def __ifloordiv__(self: _ArrayND[unsignedinteger[_NBit1]], other: _ArrayLikeUInt_co) -> _ArrayND[unsignedinteger[_NBit1]]: ...
+ def __ifloordiv__(self: NDArray[unsignedinteger[_NBit1]], other: _ArrayLikeUInt_co) -> NDArray[unsignedinteger[_NBit1]]: ...
@overload
- def __ifloordiv__(self: _ArrayND[signedinteger[_NBit1]], other: _ArrayLikeInt_co) -> _ArrayND[signedinteger[_NBit1]]: ...
+ def __ifloordiv__(self: NDArray[signedinteger[_NBit1]], other: _ArrayLikeInt_co) -> NDArray[signedinteger[_NBit1]]: ...
@overload
- def __ifloordiv__(self: _ArrayND[floating[_NBit1]], other: _ArrayLikeFloat_co) -> _ArrayND[floating[_NBit1]]: ...
+ def __ifloordiv__(self: NDArray[floating[_NBit1]], other: _ArrayLikeFloat_co) -> NDArray[floating[_NBit1]]: ...
@overload
- def __ifloordiv__(self: _ArrayND[complexfloating[_NBit1, _NBit1]], other: _ArrayLikeComplex_co) -> _ArrayND[complexfloating[_NBit1, _NBit1]]: ...
+ def __ifloordiv__(self: NDArray[complexfloating[_NBit1, _NBit1]], other: _ArrayLikeComplex_co) -> NDArray[complexfloating[_NBit1, _NBit1]]: ...
@overload
- def __ifloordiv__(self: _ArrayND[timedelta64], other: _ArrayLikeBool_co) -> NoReturn: ...
+ def __ifloordiv__(self: NDArray[timedelta64], other: _ArrayLikeBool_co) -> NoReturn: ...
@overload
- def __ifloordiv__(self: _ArrayND[timedelta64], other: _ArrayLikeInt_co) -> _ArrayND[timedelta64]: ...
+ def __ifloordiv__(self: NDArray[timedelta64], other: _ArrayLikeInt_co) -> NDArray[timedelta64]: ...
@overload
- def __ifloordiv__(self: _ArrayND[object_], other: Any) -> _ArrayND[object_]: ...
+ def __ifloordiv__(self: NDArray[object_], other: Any) -> NDArray[object_]: ...
@overload
- def __ifloordiv__(self: _ArrayND[_ScalarType], other: _RecursiveSequence) -> _ArrayND[_ScalarType]: ...
+ def __ifloordiv__(self: NDArray[_ScalarType], other: _RecursiveSequence) -> NDArray[_ScalarType]: ...
@overload # type: ignore[misc]
- def __ipow__(self: _ArrayND[Any], other: _NestedSequence[Union[str, bytes]]) -> NoReturn: ...
+ def __ipow__(self: NDArray[Any], other: _NestedSequence[Union[str, bytes]]) -> NoReturn: ...
@overload
- def __ipow__(self: _ArrayND[unsignedinteger[_NBit1]], other: _ArrayLikeUInt_co) -> _ArrayND[unsignedinteger[_NBit1]]: ...
+ def __ipow__(self: NDArray[unsignedinteger[_NBit1]], other: _ArrayLikeUInt_co) -> NDArray[unsignedinteger[_NBit1]]: ...
@overload
- def __ipow__(self: _ArrayND[signedinteger[_NBit1]], other: _ArrayLikeInt_co) -> _ArrayND[signedinteger[_NBit1]]: ...
+ def __ipow__(self: NDArray[signedinteger[_NBit1]], other: _ArrayLikeInt_co) -> NDArray[signedinteger[_NBit1]]: ...
@overload
- def __ipow__(self: _ArrayND[floating[_NBit1]], other: _ArrayLikeFloat_co) -> _ArrayND[floating[_NBit1]]: ...
+ def __ipow__(self: NDArray[floating[_NBit1]], other: _ArrayLikeFloat_co) -> NDArray[floating[_NBit1]]: ...
@overload
- def __ipow__(self: _ArrayND[complexfloating[_NBit1, _NBit1]], other: _ArrayLikeComplex_co) -> _ArrayND[complexfloating[_NBit1, _NBit1]]: ...
+ def __ipow__(self: NDArray[complexfloating[_NBit1, _NBit1]], other: _ArrayLikeComplex_co) -> NDArray[complexfloating[_NBit1, _NBit1]]: ...
@overload
- def __ipow__(self: _ArrayND[object_], other: Any) -> _ArrayND[object_]: ...
+ def __ipow__(self: NDArray[object_], other: Any) -> NDArray[object_]: ...
@overload
- def __ipow__(self: _ArrayND[_ScalarType], other: _RecursiveSequence) -> _ArrayND[_ScalarType]: ...
+ def __ipow__(self: NDArray[_ScalarType], other: _RecursiveSequence) -> NDArray[_ScalarType]: ...
@overload # type: ignore[misc]
- def __imod__(self: _ArrayND[Any], other: _NestedSequence[Union[str, bytes]]) -> NoReturn: ...
+ def __imod__(self: NDArray[Any], other: _NestedSequence[Union[str, bytes]]) -> NoReturn: ...
@overload
- def __imod__(self: _ArrayND[unsignedinteger[_NBit1]], other: _ArrayLikeUInt_co) -> _ArrayND[unsignedinteger[_NBit1]]: ...
+ def __imod__(self: NDArray[unsignedinteger[_NBit1]], other: _ArrayLikeUInt_co) -> NDArray[unsignedinteger[_NBit1]]: ...
@overload
- def __imod__(self: _ArrayND[signedinteger[_NBit1]], other: _ArrayLikeInt_co) -> _ArrayND[signedinteger[_NBit1]]: ...
+ def __imod__(self: NDArray[signedinteger[_NBit1]], other: _ArrayLikeInt_co) -> NDArray[signedinteger[_NBit1]]: ...
@overload
- def __imod__(self: _ArrayND[floating[_NBit1]], other: _ArrayLikeFloat_co) -> _ArrayND[floating[_NBit1]]: ...
+ def __imod__(self: NDArray[floating[_NBit1]], other: _ArrayLikeFloat_co) -> NDArray[floating[_NBit1]]: ...
@overload
- def __imod__(self: _ArrayND[timedelta64], other: _NestedSequence[_SupportsArray[dtype[timedelta64]]]) -> _ArrayND[timedelta64]: ...
+ def __imod__(self: NDArray[timedelta64], other: _NestedSequence[_SupportsArray[dtype[timedelta64]]]) -> NDArray[timedelta64]: ...
@overload
- def __imod__(self: _ArrayND[object_], other: Any) -> _ArrayND[object_]: ...
+ def __imod__(self: NDArray[object_], other: Any) -> NDArray[object_]: ...
@overload
- def __imod__(self: _ArrayND[_ScalarType], other: _RecursiveSequence) -> _ArrayND[_ScalarType]: ...
+ def __imod__(self: NDArray[_ScalarType], other: _RecursiveSequence) -> NDArray[_ScalarType]: ...
@overload # type: ignore[misc]
- def __ilshift__(self: _ArrayND[Any], other: _NestedSequence[Union[str, bytes]]) -> NoReturn: ...
+ def __ilshift__(self: NDArray[Any], other: _NestedSequence[Union[str, bytes]]) -> NoReturn: ...
@overload
- def __ilshift__(self: _ArrayND[unsignedinteger[_NBit1]], other: _ArrayLikeUInt_co) -> _ArrayND[unsignedinteger[_NBit1]]: ...
+ def __ilshift__(self: NDArray[unsignedinteger[_NBit1]], other: _ArrayLikeUInt_co) -> NDArray[unsignedinteger[_NBit1]]: ...
@overload
- def __ilshift__(self: _ArrayND[signedinteger[_NBit1]], other: _ArrayLikeInt_co) -> _ArrayND[signedinteger[_NBit1]]: ...
+ def __ilshift__(self: NDArray[signedinteger[_NBit1]], other: _ArrayLikeInt_co) -> NDArray[signedinteger[_NBit1]]: ...
@overload
- def __ilshift__(self: _ArrayND[object_], other: Any) -> _ArrayND[object_]: ...
+ def __ilshift__(self: NDArray[object_], other: Any) -> NDArray[object_]: ...
@overload
- def __ilshift__(self: _ArrayND[_ScalarType], other: _RecursiveSequence) -> _ArrayND[_ScalarType]: ...
+ def __ilshift__(self: NDArray[_ScalarType], other: _RecursiveSequence) -> NDArray[_ScalarType]: ...
@overload # type: ignore[misc]
- def __irshift__(self: _ArrayND[Any], other: _NestedSequence[Union[str, bytes]]) -> NoReturn: ...
+ def __irshift__(self: NDArray[Any], other: _NestedSequence[Union[str, bytes]]) -> NoReturn: ...
@overload
- def __irshift__(self: _ArrayND[unsignedinteger[_NBit1]], other: _ArrayLikeUInt_co) -> _ArrayND[unsignedinteger[_NBit1]]: ...
+ def __irshift__(self: NDArray[unsignedinteger[_NBit1]], other: _ArrayLikeUInt_co) -> NDArray[unsignedinteger[_NBit1]]: ...
@overload
- def __irshift__(self: _ArrayND[signedinteger[_NBit1]], other: _ArrayLikeInt_co) -> _ArrayND[signedinteger[_NBit1]]: ...
+ def __irshift__(self: NDArray[signedinteger[_NBit1]], other: _ArrayLikeInt_co) -> NDArray[signedinteger[_NBit1]]: ...
@overload
- def __irshift__(self: _ArrayND[object_], other: Any) -> _ArrayND[object_]: ...
+ def __irshift__(self: NDArray[object_], other: Any) -> NDArray[object_]: ...
@overload
- def __irshift__(self: _ArrayND[_ScalarType], other: _RecursiveSequence) -> _ArrayND[_ScalarType]: ...
+ def __irshift__(self: NDArray[_ScalarType], other: _RecursiveSequence) -> NDArray[_ScalarType]: ...
@overload # type: ignore[misc]
- def __iand__(self: _ArrayND[Any], other: _NestedSequence[Union[str, bytes]]) -> NoReturn: ...
+ def __iand__(self: NDArray[Any], other: _NestedSequence[Union[str, bytes]]) -> NoReturn: ...
@overload
- def __iand__(self: _ArrayND[bool_], other: _ArrayLikeBool_co) -> _ArrayND[bool_]: ...
+ def __iand__(self: NDArray[bool_], other: _ArrayLikeBool_co) -> NDArray[bool_]: ...
@overload
- def __iand__(self: _ArrayND[unsignedinteger[_NBit1]], other: _ArrayLikeUInt_co) -> _ArrayND[unsignedinteger[_NBit1]]: ...
+ def __iand__(self: NDArray[unsignedinteger[_NBit1]], other: _ArrayLikeUInt_co) -> NDArray[unsignedinteger[_NBit1]]: ...
@overload
- def __iand__(self: _ArrayND[signedinteger[_NBit1]], other: _ArrayLikeInt_co) -> _ArrayND[signedinteger[_NBit1]]: ...
+ def __iand__(self: NDArray[signedinteger[_NBit1]], other: _ArrayLikeInt_co) -> NDArray[signedinteger[_NBit1]]: ...
@overload
- def __iand__(self: _ArrayND[object_], other: Any) -> _ArrayND[object_]: ...
+ def __iand__(self: NDArray[object_], other: Any) -> NDArray[object_]: ...
@overload
- def __iand__(self: _ArrayND[_ScalarType], other: _RecursiveSequence) -> _ArrayND[_ScalarType]: ...
+ def __iand__(self: NDArray[_ScalarType], other: _RecursiveSequence) -> NDArray[_ScalarType]: ...
@overload # type: ignore[misc]
- def __ixor__(self: _ArrayND[Any], other: _NestedSequence[Union[str, bytes]]) -> NoReturn: ...
+ def __ixor__(self: NDArray[Any], other: _NestedSequence[Union[str, bytes]]) -> NoReturn: ...
@overload
- def __ixor__(self: _ArrayND[bool_], other: _ArrayLikeBool_co) -> _ArrayND[bool_]: ...
+ def __ixor__(self: NDArray[bool_], other: _ArrayLikeBool_co) -> NDArray[bool_]: ...
@overload
- def __ixor__(self: _ArrayND[unsignedinteger[_NBit1]], other: _ArrayLikeUInt_co) -> _ArrayND[unsignedinteger[_NBit1]]: ...
+ def __ixor__(self: NDArray[unsignedinteger[_NBit1]], other: _ArrayLikeUInt_co) -> NDArray[unsignedinteger[_NBit1]]: ...
@overload
- def __ixor__(self: _ArrayND[signedinteger[_NBit1]], other: _ArrayLikeInt_co) -> _ArrayND[signedinteger[_NBit1]]: ...
+ def __ixor__(self: NDArray[signedinteger[_NBit1]], other: _ArrayLikeInt_co) -> NDArray[signedinteger[_NBit1]]: ...
@overload
- def __ixor__(self: _ArrayND[object_], other: Any) -> _ArrayND[object_]: ...
+ def __ixor__(self: NDArray[object_], other: Any) -> NDArray[object_]: ...
@overload
- def __ixor__(self: _ArrayND[_ScalarType], other: _RecursiveSequence) -> _ArrayND[_ScalarType]: ...
+ def __ixor__(self: NDArray[_ScalarType], other: _RecursiveSequence) -> NDArray[_ScalarType]: ...
@overload # type: ignore[misc]
- def __ior__(self: _ArrayND[Any], other: _NestedSequence[Union[str, bytes]]) -> NoReturn: ...
+ def __ior__(self: NDArray[Any], other: _NestedSequence[Union[str, bytes]]) -> NoReturn: ...
@overload
- def __ior__(self: _ArrayND[bool_], other: _ArrayLikeBool_co) -> _ArrayND[bool_]: ...
+ def __ior__(self: NDArray[bool_], other: _ArrayLikeBool_co) -> NDArray[bool_]: ...
@overload
- def __ior__(self: _ArrayND[unsignedinteger[_NBit1]], other: _ArrayLikeUInt_co) -> _ArrayND[unsignedinteger[_NBit1]]: ...
+ def __ior__(self: NDArray[unsignedinteger[_NBit1]], other: _ArrayLikeUInt_co) -> NDArray[unsignedinteger[_NBit1]]: ...
@overload
- def __ior__(self: _ArrayND[signedinteger[_NBit1]], other: _ArrayLikeInt_co) -> _ArrayND[signedinteger[_NBit1]]: ...
+ def __ior__(self: NDArray[signedinteger[_NBit1]], other: _ArrayLikeInt_co) -> NDArray[signedinteger[_NBit1]]: ...
@overload
- def __ior__(self: _ArrayND[object_], other: Any) -> _ArrayND[object_]: ...
+ def __ior__(self: NDArray[object_], other: Any) -> NDArray[object_]: ...
@overload
- def __ior__(self: _ArrayND[_ScalarType], other: _RecursiveSequence) -> _ArrayND[_ScalarType]: ...
+ def __ior__(self: NDArray[_ScalarType], other: _RecursiveSequence) -> NDArray[_ScalarType]: ...
# Keep `dtype` at the bottom to avoid name conflicts with `np.dtype`
@property
@@ -2827,6 +2874,25 @@ class generic(_ArrayOrScalarCommon):
axis: Optional[SupportsIndex] = ...,
) -> ndarray[Any, dtype[_ScalarType]]: ...
+ def flatten(
+ self: _ScalarType,
+ order: _OrderKACF = ...,
+ ) -> ndarray[Any, dtype[_ScalarType]]: ...
+
+ def ravel(
+ self: _ScalarType,
+ order: _OrderKACF = ...,
+ ) -> ndarray[Any, dtype[_ScalarType]]: ...
+
+ @overload
+ def reshape(
+ self: _ScalarType, __shape: _ShapeLike, *, order: _OrderACF = ...
+ ) -> ndarray[Any, dtype[_ScalarType]]: ...
+ @overload
+ def reshape(
+ self: _ScalarType, *shape: SupportsIndex, order: _OrderACF = ...
+ ) -> ndarray[Any, dtype[_ScalarType]]: ...
+
def squeeze(
self: _ScalarType, axis: Union[Literal[0], Tuple[()]] = ...
) -> _ScalarType: ...
@@ -2919,6 +2985,11 @@ class object_(generic):
def real(self: _ArraySelf) -> _ArraySelf: ...
@property
def imag(self: _ArraySelf) -> _ArraySelf: ...
+ # The 3 protocols below may or may not raise,
+ # depending on the underlying object
+ def __int__(self) -> int: ...
+ def __float__(self) -> float: ...
+ def __complex__(self) -> complex: ...
object0 = object_
@@ -3043,6 +3114,9 @@ class timedelta64(generic):
__value: Union[None, int, _CharLike_co, dt.timedelta, timedelta64] = ...,
__format: Union[_CharLike_co, Tuple[_CharLike_co, _IntLike_co]] = ...,
) -> None: ...
+
+ # NOTE: Only a limited number of units support conversion
+ # to builtin scalar types: `Y`, `M`, `ns`, `ps`, `fs`, `as`
def __int__(self) -> int: ...
def __float__(self) -> float: ...
def __complex__(self) -> complex: ...
@@ -3527,7 +3601,7 @@ class errstate(Generic[_CallType], ContextDecorator):
) -> None: ...
class ndenumerate(Generic[_ScalarType]):
- iter: flatiter[_ArrayND[_ScalarType]]
+ iter: flatiter[NDArray[_ScalarType]]
@overload
def __new__(
cls, arr: _NestedSequence[_SupportsArray[dtype[_ScalarType]]],
@@ -3553,3 +3627,45 @@ class ndindex:
def __init__(self, *shape: SupportsIndex) -> None: ...
def __iter__(self: _T) -> _T: ...
def __next__(self) -> _Shape: ...
+
+class DataSource:
+ def __init__(
+ self,
+ destpath: Union[None, str, os.PathLike[str]] = ...,
+ ) -> None: ...
+ def __del__(self) -> None: ...
+ def abspath(self, path: str) -> str: ...
+ def exists(self, path: str) -> bool: ...
+
+ # Whether the file-object is opened in string or bytes mode (by default)
+ # depends on the file-extension of `path`
+ def open(
+ self,
+ path: str,
+ mode: str = ...,
+ encoding: Optional[str] = ...,
+ newline: Optional[str] = ...,
+ ) -> IO[Any]: ...
+
+# TODO: The type of each `__next__` and `iters` return-type depends
+# on the length and dtype of `args`; we can't describe this behavior yet
+# as we lack variadics (PEP 646).
+class broadcast:
+ def __new__(cls, *args: ArrayLike) -> broadcast: ...
+ @property
+ def index(self) -> int: ...
+ @property
+ def iters(self) -> Tuple[flatiter[Any], ...]: ...
+ @property
+ def nd(self) -> int: ...
+ @property
+ def ndim(self) -> int: ...
+ @property
+ def numiter(self) -> int: ...
+ @property
+ def shape(self) -> _Shape: ...
+ @property
+ def size(self) -> int: ...
+ def __next__(self) -> Tuple[Any, ...]: ...
+ def __iter__(self: _T) -> _T: ...
+ def reset(self) -> None: ...
diff --git a/numpy/core/_add_newdocs.py b/numpy/core/_add_newdocs.py
index f870dc8ad..538123149 100644
--- a/numpy/core/_add_newdocs.py
+++ b/numpy/core/_add_newdocs.py
@@ -2176,6 +2176,8 @@ add_newdoc('numpy.core.multiarray', 'ndarray',
empty : Create an array, but leave its allocated memory unchanged (i.e.,
it contains "garbage").
dtype : Create a data-type.
+ numpy.typing.NDArray : A :term:`generic <generic type>` version
+ of ndarray.
Notes
-----
@@ -5814,7 +5816,7 @@ add_newdoc('numpy.core.multiarray', 'dtype', ('metadata',
>>> (arr + arr).dtype.metadata
mappingproxy({'key': 'value'})
- But if the arrays have different dtype metadata, the metadata may be
+ But if the arrays have different dtype metadata, the metadata may be
dropped:
>>> dt2 = np.dtype(float, metadata={"key2": "value2"})
diff --git a/numpy/core/fromnumeric.py b/numpy/core/fromnumeric.py
index 5c7b3372b..65a42eb1e 100644
--- a/numpy/core/fromnumeric.py
+++ b/numpy/core/fromnumeric.py
@@ -2498,6 +2498,10 @@ def cumsum(a, axis=None, dtype=None, out=None):
Arithmetic is modular when using integer types, and no error is
raised on overflow.
+ ``cumsum(a)[-1]`` may not be equal to ``sum(a)`` for floating-point
+ values since ``sum`` may use a pairwise summation routine, reducing
+ the roundoff-error. See `sum` for more information.
+
Examples
--------
>>> a = np.array([[1,2,3], [4,5,6]])
@@ -2516,6 +2520,14 @@ def cumsum(a, axis=None, dtype=None, out=None):
array([[ 1, 3, 6],
[ 4, 9, 15]])
+ ``cumsum(b)[-1]`` may not be equal to ``sum(b)``
+
+ >>> b = np.array([1, 2e-9, 3e-9] * 1000000)
+ >>> b.cumsum()[-1]
+ 1000000.0050045159
+ >>> b.sum()
+ 1000000.0050000029
+
"""
return _wrapfunc(a, 'cumsum', axis=axis, dtype=dtype, out=out)
diff --git a/numpy/lib/index_tricks.pyi b/numpy/lib/index_tricks.pyi
index e486fe8f2..a3bfef6b6 100644
--- a/numpy/lib/index_tricks.pyi
+++ b/numpy/lib/index_tricks.pyi
@@ -33,7 +33,7 @@ from numpy.typing import (
ArrayLike,
_NestedSequence,
_RecursiveSequence,
- _ArrayND,
+ NDArray,
_ArrayLikeInt,
# DTypes
@@ -68,7 +68,7 @@ def unravel_index(
indices: _ArrayLikeInt,
shape: _ShapeLike,
order: _OrderCF = ...
-) -> Tuple[_ArrayND[intp], ...]: ...
+) -> Tuple[NDArray[intp], ...]: ...
@overload
def ravel_multi_index( # type: ignore[misc]
@@ -83,24 +83,24 @@ def ravel_multi_index(
dims: _ShapeLike,
mode: Union[_ModeKind, Tuple[_ModeKind, ...]] = ...,
order: _OrderCF = ...
-) -> _ArrayND[intp]: ...
+) -> NDArray[intp]: ...
@overload
def ix_(*args: _NestedSequence[_SupportsDType[_DType]]) -> Tuple[ndarray[Any, _DType], ...]: ...
@overload
-def ix_(*args: _NestedSequence[str]) -> Tuple[_ArrayND[str_], ...]: ...
+def ix_(*args: _NestedSequence[str]) -> Tuple[NDArray[str_], ...]: ...
@overload
-def ix_(*args: _NestedSequence[bytes]) -> Tuple[_ArrayND[bytes_], ...]: ...
+def ix_(*args: _NestedSequence[bytes]) -> Tuple[NDArray[bytes_], ...]: ...
@overload
-def ix_(*args: _NestedSequence[bool]) -> Tuple[_ArrayND[bool_], ...]: ...
+def ix_(*args: _NestedSequence[bool]) -> Tuple[NDArray[bool_], ...]: ...
@overload
-def ix_(*args: _NestedSequence[int]) -> Tuple[_ArrayND[int_], ...]: ...
+def ix_(*args: _NestedSequence[int]) -> Tuple[NDArray[int_], ...]: ...
@overload
-def ix_(*args: _NestedSequence[float]) -> Tuple[_ArrayND[float_], ...]: ...
+def ix_(*args: _NestedSequence[float]) -> Tuple[NDArray[float_], ...]: ...
@overload
-def ix_(*args: _NestedSequence[complex]) -> Tuple[_ArrayND[complex_], ...]: ...
+def ix_(*args: _NestedSequence[complex]) -> Tuple[NDArray[complex_], ...]: ...
@overload
-def ix_(*args: _RecursiveSequence) -> Tuple[_ArrayND[Any], ...]: ...
+def ix_(*args: _RecursiveSequence) -> Tuple[NDArray[Any], ...]: ...
class nd_grid(Generic[_BoolType]):
sparse: _BoolType
@@ -109,12 +109,12 @@ class nd_grid(Generic[_BoolType]):
def __getitem__(
self: nd_grid[Literal[False]],
key: Union[slice, Sequence[slice]],
- ) -> _ArrayND[Any]: ...
+ ) -> NDArray[Any]: ...
@overload
def __getitem__(
self: nd_grid[Literal[True]],
key: Union[slice, Sequence[slice]],
- ) -> List[_ArrayND[Any]]: ...
+ ) -> List[NDArray[Any]]: ...
class MGridClass(nd_grid[Literal[False]]):
def __init__(self) -> None: ...
@@ -142,7 +142,7 @@ class AxisConcatenator:
@overload
def concatenate( # type: ignore[misc]
*a: ArrayLike, axis: SupportsIndex = ..., out: None = ...
- ) -> _ArrayND[Any]: ...
+ ) -> NDArray[Any]: ...
@staticmethod
@overload
def concatenate(
@@ -188,7 +188,7 @@ index_exp: IndexExpression[Literal[True]]
s_: IndexExpression[Literal[False]]
def fill_diagonal(a: ndarray[Any, Any], val: Any, wrap: bool = ...) -> None: ...
-def diag_indices(n: int, ndim: int = ...) -> Tuple[_ArrayND[int_], ...]: ...
-def diag_indices_from(arr: ArrayLike) -> Tuple[_ArrayND[int_], ...]: ...
+def diag_indices(n: int, ndim: int = ...) -> Tuple[NDArray[int_], ...]: ...
+def diag_indices_from(arr: ArrayLike) -> Tuple[NDArray[int_], ...]: ...
# NOTE: see `numpy/__init__.pyi` for `ndenumerate` and `ndindex`
diff --git a/numpy/lib/ufunclike.pyi b/numpy/lib/ufunclike.pyi
index e97383af8..03f08ebff 100644
--- a/numpy/lib/ufunclike.pyi
+++ b/numpy/lib/ufunclike.pyi
@@ -2,7 +2,7 @@ from typing import Any, overload, TypeVar, List, Union
from numpy import floating, bool_, object_, ndarray
from numpy.typing import (
- _ArrayND,
+ NDArray,
_FloatLike_co,
_ArrayLikeFloat_co,
_ArrayLikeObject_co,
@@ -21,12 +21,12 @@ def fix( # type: ignore[misc]
def fix(
x: _ArrayLikeFloat_co,
out: None = ...,
-) -> _ArrayND[floating[Any]]: ...
+) -> NDArray[floating[Any]]: ...
@overload
def fix(
x: _ArrayLikeObject_co,
out: None = ...,
-) -> _ArrayND[object_]: ...
+) -> NDArray[object_]: ...
@overload
def fix(
x: Union[_ArrayLikeFloat_co, _ArrayLikeObject_co],
@@ -42,7 +42,7 @@ def isposinf( # type: ignore[misc]
def isposinf(
x: _ArrayLikeFloat_co,
out: None = ...,
-) -> _ArrayND[bool_]: ...
+) -> NDArray[bool_]: ...
@overload
def isposinf(
x: _ArrayLikeFloat_co,
@@ -58,7 +58,7 @@ def isneginf( # type: ignore[misc]
def isneginf(
x: _ArrayLikeFloat_co,
out: None = ...,
-) -> _ArrayND[bool_]: ...
+) -> NDArray[bool_]: ...
@overload
def isneginf(
x: _ArrayLikeFloat_co,
diff --git a/numpy/typing/__init__.py b/numpy/typing/__init__.py
index a2d4c60fb..4f0dc0cf1 100644
--- a/numpy/typing/__init__.py
+++ b/numpy/typing/__init__.py
@@ -339,7 +339,6 @@ from ._array_like import (
_NestedSequence,
_RecursiveSequence,
_SupportsArray,
- _ArrayND,
_ArrayLikeInt,
_ArrayLikeBool_co,
_ArrayLikeUInt_co,
@@ -354,6 +353,10 @@ from ._array_like import (
_ArrayLikeStr_co,
_ArrayLikeBytes_co,
)
+from ._generic_alias import (
+ NDArray as NDArray,
+ _GenericAlias,
+)
if __doc__ is not None:
from ._add_docstring import _docstrings
diff --git a/numpy/typing/_add_docstring.py b/numpy/typing/_add_docstring.py
index 8e39fe2c6..34dbdb0c6 100644
--- a/numpy/typing/_add_docstring.py
+++ b/numpy/typing/_add_docstring.py
@@ -3,14 +3,32 @@
import re
import textwrap
+from ._generic_alias import NDArray
+
_docstrings_list = []
-def add_newdoc(name, value, doc):
+def add_newdoc(name: str, value: str, doc: str) -> None:
+ """Append ``_docstrings_list`` with a docstring for `name`.
+
+ Parameters
+ ----------
+ name : str
+ The name of the object.
+ value : str
+ A string-representation of the object.
+ doc : str
+ The docstring of the object.
+
+ """
_docstrings_list.append((name, value, doc))
-def _parse_docstrings():
+def _parse_docstrings() -> str:
+ """Convert all docstrings in ``_docstrings_list`` into a single
+ sphinx-legible text block.
+
+ """
type_list_ret = []
for name, value, doc in _docstrings_list:
s = textwrap.dedent(doc).replace("\n", "\n ")
@@ -93,4 +111,33 @@ add_newdoc('DTypeLike', 'typing.Union[...]',
""")
+add_newdoc('NDArray', repr(NDArray),
+ """
+ A :term:`generic <generic type>` version of
+ `np.ndarray[Any, np.dtype[~ScalarType]] <numpy.ndarray>`.
+
+ Can be used during runtime for typing arrays with a given dtype
+ and unspecified shape.
+
+ Examples
+ --------
+ .. code-block:: python
+
+ >>> import numpy as np
+ >>> import numpy.typing as npt
+
+ >>> print(npt.NDArray)
+ numpy.ndarray[typing.Any, numpy.dtype[~ScalarType]]
+
+ >>> print(npt.NDArray[np.float64])
+ numpy.ndarray[typing.Any, numpy.dtype[numpy.float64]]
+
+ >>> NDArrayInt = npt.NDArray[np.int_]
+ >>> a: NDArrayInt = np.arange(10)
+
+ >>> def func(a: npt.ArrayLike) -> npt.NDArray[Any]:
+ ... return np.array(a)
+
+ """)
+
_docstrings = _parse_docstrings()
diff --git a/numpy/typing/_array_like.py b/numpy/typing/_array_like.py
index 582d3db9a..9f57b2295 100644
--- a/numpy/typing/_array_like.py
+++ b/numpy/typing/_array_like.py
@@ -129,8 +129,3 @@ _ArrayLikeInt = _ArrayLike[
"dtype[integer[Any]]",
int,
]
-
-if TYPE_CHECKING:
- _ArrayND = ndarray[Any, dtype[_ScalarType]]
-else:
- _ArrayND = Any
diff --git a/numpy/typing/_callable.py b/numpy/typing/_callable.py
index 30c210b62..d9cb0f157 100644
--- a/numpy/typing/_callable.py
+++ b/numpy/typing/_callable.py
@@ -47,7 +47,8 @@ from ._scalars import (
_NumberLike_co,
)
from . import NBitBase
-from ._array_like import ArrayLike, _ArrayND
+from ._array_like import ArrayLike
+from ._generic_alias import NDArray
if sys.version_info >= (3, 8):
from typing import Protocol
@@ -336,7 +337,7 @@ if TYPE_CHECKING or HAVE_PROTOCOL:
@overload
def __call__(self, __other: _T1) -> bool_: ...
@overload
- def __call__(self, __other: _T2) -> _ArrayND[bool_]: ...
+ def __call__(self, __other: _T2) -> NDArray[bool_]: ...
else:
_BoolOp = Any
diff --git a/numpy/typing/_generic_alias.py b/numpy/typing/_generic_alias.py
new file mode 100644
index 000000000..f98fca62e
--- /dev/null
+++ b/numpy/typing/_generic_alias.py
@@ -0,0 +1,207 @@
+from __future__ import annotations
+
+import sys
+import types
+from typing import (
+ Any,
+ ClassVar,
+ FrozenSet,
+ Generator,
+ Iterable,
+ Iterator,
+ List,
+ NoReturn,
+ Tuple,
+ Type,
+ TypeVar,
+ TYPE_CHECKING,
+)
+
+import numpy as np
+
+__all__ = ["_GenericAlias", "NDArray"]
+
+_T = TypeVar("_T", bound="_GenericAlias")
+
+
+def _to_str(obj: object) -> str:
+ """Helper function for `_GenericAlias.__repr__`."""
+ if obj is Ellipsis:
+ return '...'
+ elif isinstance(obj, type) and not isinstance(obj, _GENERIC_ALIAS_TYPE):
+ if obj.__module__ == 'builtins':
+ return obj.__qualname__
+ else:
+ return f'{obj.__module__}.{obj.__qualname__}'
+ else:
+ return repr(obj)
+
+
+def _parse_parameters(args: Iterable[Any]) -> Generator[TypeVar, None, None]:
+ """Search for all typevars and typevar-containing objects in `args`.
+
+ Helper function for `_GenericAlias.__init__`.
+
+ """
+ for i in args:
+ if hasattr(i, "__parameters__"):
+ yield from i.__parameters__
+ elif isinstance(i, TypeVar):
+ yield i
+
+
+def _reconstruct_alias(alias: _T, parameters: Iterator[TypeVar]) -> _T:
+ """Recursivelly replace all typevars with those from `parameters`.
+
+ Helper function for `_GenericAlias.__getitem__`.
+
+ """
+ args = []
+ for i in alias.__args__:
+ if isinstance(i, TypeVar):
+ value: Any = next(parameters)
+ elif isinstance(i, _GenericAlias):
+ value = _reconstruct_alias(i, parameters)
+ elif hasattr(i, "__parameters__"):
+ value = i[next(parameters)]
+ else:
+ value = i
+ args.append(value)
+
+ cls = type(alias)
+ return cls(alias.__origin__, tuple(args))
+
+
+class _GenericAlias:
+ """A python-based backport of the `types.GenericAlias` class.
+
+ E.g. for ``t = list[int]``, ``t.__origin__`` is ``list`` and
+ ``t.__args__`` is ``(int,)``.
+
+ See Also
+ --------
+ :pep:`585`
+ The PEP responsible for introducing `types.GenericAlias`.
+
+ """
+
+ __slots__ = ("__weakref__", "_origin", "_args", "_parameters", "_hash")
+
+ @property
+ def __origin__(self) -> type:
+ return super().__getattribute__("_origin")
+
+ @property
+ def __args__(self) -> Tuple[Any, ...]:
+ return super().__getattribute__("_args")
+
+ @property
+ def __parameters__(self) -> Tuple[TypeVar, ...]:
+ """Type variables in the ``GenericAlias``."""
+ return super().__getattribute__("_parameters")
+
+ def __init__(self, origin: type, args: Any) -> None:
+ self._origin = origin
+ self._args = args if isinstance(args, tuple) else (args,)
+ self._parameters = tuple(_parse_parameters(args))
+
+ @property
+ def __call__(self) -> type:
+ return self.__origin__
+
+ def __reduce__(self: _T) -> Tuple[Type[_T], Tuple[type, Tuple[Any, ...]]]:
+ cls = type(self)
+ return cls, (self.__origin__, self.__args__)
+
+ def __mro_entries__(self, bases: Iterable[object]) -> Tuple[type]:
+ return (self.__origin__,)
+
+ def __dir__(self) -> List[str]:
+ """Implement ``dir(self)``."""
+ cls = type(self)
+ dir_origin = set(dir(self.__origin__))
+ return sorted(cls._ATTR_EXCEPTIONS | dir_origin)
+
+ def __hash__(self) -> int:
+ """Return ``hash(self)``."""
+ # Attempt to use the cached hash
+ try:
+ return super().__getattribute__("_hash")
+ except AttributeError:
+ self._hash: int = hash(self.__origin__) ^ hash(self.__args__)
+ return super().__getattribute__("_hash")
+
+ def __instancecheck__(self, obj: object) -> NoReturn:
+ """Check if an `obj` is an instance."""
+ raise TypeError("isinstance() argument 2 cannot be a "
+ "parameterized generic")
+
+ def __subclasscheck__(self, cls: type) -> NoReturn:
+ """Check if a `cls` is a subclass."""
+ raise TypeError("issubclass() argument 2 cannot be a "
+ "parameterized generic")
+
+ def __repr__(self) -> str:
+ """Return ``repr(self)``."""
+ args = ", ".join(_to_str(i) for i in self.__args__)
+ origin = _to_str(self.__origin__)
+ return f"{origin}[{args}]"
+
+ def __getitem__(self: _T, key: Any) -> _T:
+ """Return ``self[key]``."""
+ key_tup = key if isinstance(key, tuple) else (key,)
+
+ if len(self.__parameters__) == 0:
+ raise TypeError(f"There are no type variables left in {self}")
+ elif len(key_tup) > len(self.__parameters__):
+ raise TypeError(f"Too many arguments for {self}")
+ elif len(key_tup) < len(self.__parameters__):
+ raise TypeError(f"Too few arguments for {self}")
+
+ key_iter = iter(key_tup)
+ return _reconstruct_alias(self, key_iter)
+
+ def __eq__(self, value: object) -> bool:
+ """Return ``self == value``."""
+ if not isinstance(value, _GENERIC_ALIAS_TYPE):
+ return NotImplemented
+ return (
+ self.__origin__ == value.__origin__ and
+ self.__args__ == value.__args__
+ )
+
+ _ATTR_EXCEPTIONS: ClassVar[FrozenSet[str]] = frozenset({
+ "__origin__",
+ "__args__",
+ "__parameters__",
+ "__mro_entries__",
+ "__reduce__",
+ "__reduce_ex__",
+ })
+
+ def __getattribute__(self, name: str) -> Any:
+ """Return ``getattr(self, name)``."""
+ # Pull the attribute from `__origin__` unless its
+ # name is in `_ATTR_EXCEPTIONS`
+ cls = type(self)
+ if name in cls._ATTR_EXCEPTIONS:
+ return super().__getattribute__(name)
+ return getattr(self.__origin__, name)
+
+
+# See `_GenericAlias.__eq__`
+if sys.version_info >= (3, 9):
+ _GENERIC_ALIAS_TYPE = (_GenericAlias, types.GenericAlias)
+else:
+ _GENERIC_ALIAS_TYPE = (_GenericAlias,)
+
+ScalarType = TypeVar("ScalarType", bound=np.generic)
+
+if TYPE_CHECKING:
+ NDArray = np.ndarray[Any, np.dtype[ScalarType]]
+elif sys.version_info >= (3, 9):
+ _DType = types.GenericAlias(np.dtype, (ScalarType,))
+ NDArray = types.GenericAlias(np.ndarray, (Any, _DType))
+else:
+ _DType = _GenericAlias(np.dtype, (ScalarType,))
+ NDArray = _GenericAlias(np.ndarray, (Any, _DType))
diff --git a/numpy/typing/tests/data/fail/datasource.py b/numpy/typing/tests/data/fail/datasource.py
new file mode 100644
index 000000000..345277d45
--- /dev/null
+++ b/numpy/typing/tests/data/fail/datasource.py
@@ -0,0 +1,15 @@
+from pathlib import Path
+import numpy as np
+
+path: Path
+d1: np.DataSource
+
+d1.abspath(path) # E: incompatible type
+d1.abspath(b"...") # E: incompatible type
+
+d1.exists(path) # E: incompatible type
+d1.exists(b"...") # E: incompatible type
+
+d1.open(path, "r") # E: incompatible type
+d1.open(b"...", encoding="utf8") # E: incompatible type
+d1.open(None, newline="/n") # E: incompatible type
diff --git a/numpy/typing/tests/data/fail/ndarray_misc.py b/numpy/typing/tests/data/fail/ndarray_misc.py
index 1e1496bfe..653b9267b 100644
--- a/numpy/typing/tests/data/fail/ndarray_misc.py
+++ b/numpy/typing/tests/data/fail/ndarray_misc.py
@@ -6,9 +6,13 @@ function-based counterpart in `../from_numeric.py`.
"""
+from typing import Any
import numpy as np
f8: np.float64
+AR_f8: np.ndarray[Any, np.dtype[np.float64]]
+AR_M: np.ndarray[Any, np.dtype[np.datetime64]]
+AR_b: np.ndarray[Any, np.dtype[np.bool_]]
f8.argpartition(0) # E: has no attribute
f8.diagonal() # E: has no attribute
@@ -19,3 +23,8 @@ f8.put(0, 2) # E: has no attribute
f8.setfield(2, np.float64) # E: has no attribute
f8.sort() # E: has no attribute
f8.trace() # E: has no attribute
+
+AR_M.__int__() # E: Invalid self argument
+AR_M.__float__() # E: Invalid self argument
+AR_M.__complex__() # E: Invalid self argument
+AR_b.__index__() # E: Invalid self argument
diff --git a/numpy/typing/tests/data/pass/multiarray.py b/numpy/typing/tests/data/pass/multiarray.py
new file mode 100644
index 000000000..e2b5d16a0
--- /dev/null
+++ b/numpy/typing/tests/data/pass/multiarray.py
@@ -0,0 +1,37 @@
+from __future__ import annotations
+
+from typing import Any
+import numpy as np
+
+AR_f8: np.ndarray[Any, np.dtype[np.float64]] = np.array([1.0])
+AR_i8: np.ndarray[Any, np.dtype[np.int_]] = np.array([1])
+
+b_f8 = np.broadcast(AR_f8)
+b_i8_f8_f8 = np.broadcast(AR_i8, AR_f8, AR_f8)
+
+next(b_f8)
+next(b_i8_f8_f8)
+
+b_f8.reset()
+b_i8_f8_f8.reset()
+
+b_f8.index
+b_i8_f8_f8.index
+
+b_f8.iters
+b_i8_f8_f8.iters
+
+b_f8.nd
+b_i8_f8_f8.nd
+
+b_f8.ndim
+b_i8_f8_f8.ndim
+
+b_f8.numiter
+b_i8_f8_f8.numiter
+
+b_f8.shape
+b_i8_f8_f8.shape
+
+b_f8.size
+b_i8_f8_f8.size
diff --git a/numpy/typing/tests/data/pass/ndarray_misc.py b/numpy/typing/tests/data/pass/ndarray_misc.py
index ba10ce974..62024603c 100644
--- a/numpy/typing/tests/data/pass/ndarray_misc.py
+++ b/numpy/typing/tests/data/pass/ndarray_misc.py
@@ -8,7 +8,9 @@ function-based counterpart in `../from_numeric.py`.
from __future__ import annotations
+import operator
from typing import cast, Any
+
import numpy as np
class SubClass(np.ndarray): ...
@@ -162,3 +164,22 @@ void.setfield(10, np.float64)
A.item(0)
C.item(0)
+
+A.ravel()
+C.ravel()
+
+A.flatten()
+C.flatten()
+
+A.reshape(1)
+C.reshape(3)
+
+int(np.array(1.0, dtype=np.float64))
+int(np.array("1", dtype=np.str_))
+
+float(np.array(1.0, dtype=np.float64))
+float(np.array("1", dtype=np.str_))
+
+complex(np.array(1.0, dtype=np.float64))
+
+operator.index(np.array(1, dtype=np.int64))
diff --git a/numpy/typing/tests/data/pass/scalars.py b/numpy/typing/tests/data/pass/scalars.py
index f7965e1c5..b258db49f 100644
--- a/numpy/typing/tests/data/pass/scalars.py
+++ b/numpy/typing/tests/data/pass/scalars.py
@@ -4,6 +4,14 @@ import datetime as dt
import pytest
import numpy as np
+b = np.bool_()
+u8 = np.uint64()
+i8 = np.int64()
+f8 = np.float64()
+c16 = np.complex128()
+U = np.str_()
+S = np.bytes_()
+
# Construction
class D:
@@ -205,18 +213,42 @@ np.clongdouble()
np.clongfloat()
np.longcomplex()
-np.bool_().item()
-np.int_().item()
-np.uint64().item()
-np.float32().item()
-np.complex128().item()
-np.str_().item()
-np.bytes_().item()
-
-np.bool_().tolist()
-np.int_().tolist()
-np.uint64().tolist()
-np.float32().tolist()
-np.complex128().tolist()
-np.str_().tolist()
-np.bytes_().tolist()
+b.item()
+i8.item()
+u8.item()
+f8.item()
+c16.item()
+U.item()
+S.item()
+
+b.tolist()
+i8.tolist()
+u8.tolist()
+f8.tolist()
+c16.tolist()
+U.tolist()
+S.tolist()
+
+b.ravel()
+i8.ravel()
+u8.ravel()
+f8.ravel()
+c16.ravel()
+U.ravel()
+S.ravel()
+
+b.flatten()
+i8.flatten()
+u8.flatten()
+f8.flatten()
+c16.flatten()
+U.flatten()
+S.flatten()
+
+b.reshape(1)
+i8.reshape(1)
+u8.reshape(1)
+f8.reshape(1)
+c16.reshape(1)
+U.reshape(1)
+S.reshape(1)
diff --git a/numpy/typing/tests/data/reveal/datasource.py b/numpy/typing/tests/data/reveal/datasource.py
new file mode 100644
index 000000000..245ac7649
--- /dev/null
+++ b/numpy/typing/tests/data/reveal/datasource.py
@@ -0,0 +1,21 @@
+from pathlib import Path
+import numpy as np
+
+path1: Path
+path2: str
+
+d1 = np.DataSource(path1)
+d2 = np.DataSource(path2)
+d3 = np.DataSource(None)
+
+reveal_type(d1.abspath("...")) # E: str
+reveal_type(d2.abspath("...")) # E: str
+reveal_type(d3.abspath("...")) # E: str
+
+reveal_type(d1.exists("...")) # E: bool
+reveal_type(d2.exists("...")) # E: bool
+reveal_type(d3.exists("...")) # E: bool
+
+reveal_type(d1.open("...", "r")) # E: IO[Any]
+reveal_type(d2.open("...", encoding="utf8")) # E: IO[Any]
+reveal_type(d3.open("...", newline="/n")) # E: IO[Any]
diff --git a/numpy/typing/tests/data/reveal/multiarray.py b/numpy/typing/tests/data/reveal/multiarray.py
new file mode 100644
index 000000000..33e9ede7c
--- /dev/null
+++ b/numpy/typing/tests/data/reveal/multiarray.py
@@ -0,0 +1,35 @@
+from typing import Any
+import numpy as np
+
+AR_f8: np.ndarray[Any, np.dtype[np.float64]]
+AR_i8: np.ndarray[Any, np.dtype[np.int64]]
+
+b_f8 = np.broadcast(AR_f8)
+b_i8_f8_f8 = np.broadcast(AR_i8, AR_f8, AR_f8)
+
+reveal_type(next(b_f8)) # E: tuple[Any]
+reveal_type(next(b_i8_f8_f8)) # E: tuple[Any]
+
+reveal_type(b_f8.reset()) # E: None
+reveal_type(b_i8_f8_f8.reset()) # E: None
+
+reveal_type(b_f8.index) # E: int
+reveal_type(b_i8_f8_f8.index) # E: int
+
+reveal_type(b_f8.iters) # E: tuple[numpy.flatiter[Any]]
+reveal_type(b_i8_f8_f8.iters) # E: tuple[numpy.flatiter[Any]]
+
+reveal_type(b_f8.nd) # E: int
+reveal_type(b_i8_f8_f8.nd) # E: int
+
+reveal_type(b_f8.ndim) # E: int
+reveal_type(b_i8_f8_f8.ndim) # E: int
+
+reveal_type(b_f8.numiter) # E: int
+reveal_type(b_i8_f8_f8.numiter) # E: int
+
+reveal_type(b_f8.shape) # E: tuple[builtins.int]
+reveal_type(b_i8_f8_f8.shape) # E: tuple[builtins.int]
+
+reveal_type(b_f8.size) # E: int
+reveal_type(b_i8_f8_f8.size) # E: int
diff --git a/numpy/typing/tests/data/reveal/ndarray_misc.py b/numpy/typing/tests/data/reveal/ndarray_misc.py
index 8c45eb6f3..ecc322251 100644
--- a/numpy/typing/tests/data/reveal/ndarray_misc.py
+++ b/numpy/typing/tests/data/reveal/ndarray_misc.py
@@ -6,14 +6,17 @@ function-based counterpart in `../from_numeric.py`.
"""
+import operator
from typing import Any
+
import numpy as np
class SubClass(np.ndarray): ...
f8: np.float64
-AR_f8: np.ndarray[Any, np.dtype[np.float64]]
B: SubClass
+AR_f8: np.ndarray[Any, np.dtype[np.float64]]
+AR_i8: np.ndarray[Any, np.dtype[np.int64]]
AR_U: np.ndarray[Any, np.dtype[np.str_]]
reveal_type(f8.all()) # E: numpy.bool_
@@ -137,19 +140,40 @@ reveal_type(AR_f8.var(axis=0)) # E: Any
reveal_type(AR_f8.var(keepdims=True)) # E: Any
reveal_type(AR_f8.var(out=B)) # E: SubClass
-reveal_type(AR_f8.argpartition([0])) # E: numpy.ndarray[Any, Any]
+reveal_type(AR_f8.argpartition([0])) # E: numpy.ndarray[Any, numpy.dtype[{intp}]]
reveal_type(AR_f8.diagonal()) # E: numpy.ndarray[Any, numpy.dtype[{float64}]]
-reveal_type(AR_f8.dot(1)) # E: Any
+reveal_type(AR_f8.dot(1)) # E: numpy.ndarray[Any, Any]
+reveal_type(AR_f8.dot([1])) # E: Any
reveal_type(AR_f8.dot(1, out=B)) # E: SubClass
-reveal_type(AR_f8.nonzero()) # E: tuple[numpy.ndarray[Any, Any]]
+reveal_type(AR_f8.nonzero()) # E: tuple[numpy.ndarray[Any, numpy.dtype[{intp}]]]
-reveal_type(AR_f8.searchsorted([1])) # E: numpy.ndarray[Any, Any]
+reveal_type(AR_f8.searchsorted(1)) # E: {intp}
+reveal_type(AR_f8.searchsorted([1])) # E: numpy.ndarray[Any, numpy.dtype[{intp}]]
reveal_type(AR_f8.trace()) # E: Any
reveal_type(AR_f8.trace(out=B)) # E: SubClass
reveal_type(AR_f8.item()) # E: float
reveal_type(AR_U.item()) # E: str
+
+reveal_type(AR_f8.ravel()) # E: numpy.ndarray[Any, numpy.dtype[{float64}]]
+reveal_type(AR_U.ravel()) # E: numpy.ndarray[Any, numpy.dtype[numpy.str_]]
+
+reveal_type(AR_f8.flatten()) # E: numpy.ndarray[Any, numpy.dtype[{float64}]]
+reveal_type(AR_U.flatten()) # E: numpy.ndarray[Any, numpy.dtype[numpy.str_]]
+
+reveal_type(AR_f8.reshape(1)) # E: numpy.ndarray[Any, numpy.dtype[{float64}]]
+reveal_type(AR_U.reshape(1)) # E: numpy.ndarray[Any, numpy.dtype[numpy.str_]]
+
+reveal_type(int(AR_f8)) # E: int
+reveal_type(int(AR_U)) # E: int
+
+reveal_type(float(AR_f8)) # E: float
+reveal_type(float(AR_U)) # E: float
+
+reveal_type(complex(AR_f8)) # E: complex
+
+reveal_type(operator.index(AR_i8)) # E: int
diff --git a/numpy/typing/tests/data/reveal/scalars.py b/numpy/typing/tests/data/reveal/scalars.py
index f50c46c43..d98388422 100644
--- a/numpy/typing/tests/data/reveal/scalars.py
+++ b/numpy/typing/tests/data/reveal/scalars.py
@@ -1,28 +1,35 @@
import numpy as np
-x = np.complex64(3 + 2j)
+b: np.bool_
+u8: np.uint64
+i8: np.int64
+f8: np.float64
+c8: np.complex64
+c16: np.complex128
+U: np.str_
+S: np.bytes_
-reveal_type(x.real) # E: {float32}
-reveal_type(x.imag) # E: {float32}
+reveal_type(c8.real) # E: {float32}
+reveal_type(c8.imag) # E: {float32}
-reveal_type(x.real.real) # E: {float32}
-reveal_type(x.real.imag) # E: {float32}
+reveal_type(c8.real.real) # E: {float32}
+reveal_type(c8.real.imag) # E: {float32}
-reveal_type(x.itemsize) # E: int
-reveal_type(x.shape) # E: Tuple[]
-reveal_type(x.strides) # E: Tuple[]
+reveal_type(c8.itemsize) # E: int
+reveal_type(c8.shape) # E: Tuple[]
+reveal_type(c8.strides) # E: Tuple[]
-reveal_type(x.ndim) # E: Literal[0]
-reveal_type(x.size) # E: Literal[1]
+reveal_type(c8.ndim) # E: Literal[0]
+reveal_type(c8.size) # E: Literal[1]
-reveal_type(x.squeeze()) # E: {complex64}
-reveal_type(x.byteswap()) # E: {complex64}
-reveal_type(x.transpose()) # E: {complex64}
+reveal_type(c8.squeeze()) # E: {complex64}
+reveal_type(c8.byteswap()) # E: {complex64}
+reveal_type(c8.transpose()) # E: {complex64}
-reveal_type(x.dtype) # E: numpy.dtype[{complex64}]
+reveal_type(c8.dtype) # E: numpy.dtype[{complex64}]
-reveal_type(np.complex64().real) # E: {float32}
-reveal_type(np.complex128().imag) # E: {float64}
+reveal_type(c8.real) # E: {float32}
+reveal_type(c16.imag) # E: {float64}
reveal_type(np.unicode_('foo')) # E: numpy.str_
reveal_type(np.str0('foo')) # E: numpy.str_
@@ -68,18 +75,42 @@ reveal_type(np.clongdouble()) # E: {clongdouble}
reveal_type(np.clongfloat()) # E: {clongdouble}
reveal_type(np.longcomplex()) # E: {clongdouble}
-reveal_type(np.bool_().item()) # E: bool
-reveal_type(np.int_().item()) # E: int
-reveal_type(np.uint64().item()) # E: int
-reveal_type(np.float32().item()) # E: float
-reveal_type(np.complex128().item()) # E: complex
-reveal_type(np.str_().item()) # E: str
-reveal_type(np.bytes_().item()) # E: bytes
-
-reveal_type(np.bool_().tolist()) # E: bool
-reveal_type(np.int_().tolist()) # E: int
-reveal_type(np.uint64().tolist()) # E: int
-reveal_type(np.float32().tolist()) # E: float
-reveal_type(np.complex128().tolist()) # E: complex
-reveal_type(np.str_().tolist()) # E: str
-reveal_type(np.bytes_().tolist()) # E: bytes
+reveal_type(b.item()) # E: bool
+reveal_type(i8.item()) # E: int
+reveal_type(u8.item()) # E: int
+reveal_type(f8.item()) # E: float
+reveal_type(c16.item()) # E: complex
+reveal_type(U.item()) # E: str
+reveal_type(S.item()) # E: bytes
+
+reveal_type(b.tolist()) # E: bool
+reveal_type(i8.tolist()) # E: int
+reveal_type(u8.tolist()) # E: int
+reveal_type(f8.tolist()) # E: float
+reveal_type(c16.tolist()) # E: complex
+reveal_type(U.tolist()) # E: str
+reveal_type(S.tolist()) # E: bytes
+
+reveal_type(b.ravel()) # E: numpy.ndarray[Any, numpy.dtype[numpy.bool_]]
+reveal_type(i8.ravel()) # E: numpy.ndarray[Any, numpy.dtype[{int64}]]
+reveal_type(u8.ravel()) # E: numpy.ndarray[Any, numpy.dtype[{uint64}]]
+reveal_type(f8.ravel()) # E: numpy.ndarray[Any, numpy.dtype[{float64}]]
+reveal_type(c16.ravel()) # E: numpy.ndarray[Any, numpy.dtype[{complex128}]]
+reveal_type(U.ravel()) # E: numpy.ndarray[Any, numpy.dtype[numpy.str_]]
+reveal_type(S.ravel()) # E: numpy.ndarray[Any, numpy.dtype[numpy.bytes_]]
+
+reveal_type(b.flatten()) # E: numpy.ndarray[Any, numpy.dtype[numpy.bool_]]
+reveal_type(i8.flatten()) # E: numpy.ndarray[Any, numpy.dtype[{int64}]]
+reveal_type(u8.flatten()) # E: numpy.ndarray[Any, numpy.dtype[{uint64}]]
+reveal_type(f8.flatten()) # E: numpy.ndarray[Any, numpy.dtype[{float64}]]
+reveal_type(c16.flatten()) # E: numpy.ndarray[Any, numpy.dtype[{complex128}]]
+reveal_type(U.flatten()) # E: numpy.ndarray[Any, numpy.dtype[numpy.str_]]
+reveal_type(S.flatten()) # E: numpy.ndarray[Any, numpy.dtype[numpy.bytes_]]
+
+reveal_type(b.reshape(1)) # E: numpy.ndarray[Any, numpy.dtype[numpy.bool_]]
+reveal_type(i8.reshape(1)) # E: numpy.ndarray[Any, numpy.dtype[{int64}]]
+reveal_type(u8.reshape(1)) # E: numpy.ndarray[Any, numpy.dtype[{uint64}]]
+reveal_type(f8.reshape(1)) # E: numpy.ndarray[Any, numpy.dtype[{float64}]]
+reveal_type(c16.reshape(1)) # E: numpy.ndarray[Any, numpy.dtype[{complex128}]]
+reveal_type(U.reshape(1)) # E: numpy.ndarray[Any, numpy.dtype[numpy.str_]]
+reveal_type(S.reshape(1)) # E: numpy.ndarray[Any, numpy.dtype[numpy.bytes_]]
diff --git a/numpy/typing/tests/test_generic_alias.py b/numpy/typing/tests/test_generic_alias.py
new file mode 100644
index 000000000..13072051a
--- /dev/null
+++ b/numpy/typing/tests/test_generic_alias.py
@@ -0,0 +1,112 @@
+from __future__ import annotations
+
+import sys
+import types
+import pickle
+import weakref
+from typing import TypeVar, Any, Callable, Tuple, Type, Union
+
+import pytest
+import numpy as np
+from numpy.typing._generic_alias import _GenericAlias
+
+ScalarType = TypeVar("ScalarType", bound=np.generic)
+DType = _GenericAlias(np.dtype, (ScalarType,))
+NDArray = _GenericAlias(np.ndarray, (Any, DType))
+
+if sys.version_info >= (3, 9):
+ DType_ref = types.GenericAlias(np.dtype, (ScalarType,))
+ NDArray_ref = types.GenericAlias(np.ndarray, (Any, DType_ref))
+ FuncType = Callable[[Union[_GenericAlias, types.GenericAlias]], Any]
+else:
+ DType_ref = NotImplemented
+ NDArray_ref = NotImplemented
+ FuncType = Callable[[_GenericAlias], Any]
+
+GETATTR_NAMES = sorted(set(dir(np.ndarray)) - _GenericAlias._ATTR_EXCEPTIONS)
+
+BUFFER = np.array([1], dtype=np.int64)
+BUFFER.setflags(write=False)
+
+def _get_subclass_mro(base: type) -> Tuple[type, ...]:
+ class Subclass(base): # type: ignore[misc,valid-type]
+ pass
+ return Subclass.__mro__[1:]
+
+
+class TestGenericAlias:
+ """Tests for `numpy.typing._generic_alias._GenericAlias`."""
+
+ @pytest.mark.parametrize("name,func", [
+ ("__init__", lambda n: n),
+ ("__origin__", lambda n: n.__origin__),
+ ("__args__", lambda n: n.__args__),
+ ("__parameters__", lambda n: n.__parameters__),
+ ("__reduce__", lambda n: n.__reduce__()[1:]),
+ ("__reduce_ex__", lambda n: n.__reduce_ex__(1)[1:]),
+ ("__mro_entries__", lambda n: n.__mro_entries__([object])),
+ ("__hash__", lambda n: hash(n)),
+ ("__repr__", lambda n: repr(n)),
+ ("__getitem__", lambda n: n[np.float64]),
+ ("__getitem__", lambda n: n[ScalarType][np.float64]),
+ ("__getitem__", lambda n: n[Union[np.int64, ScalarType]][np.float64]),
+ ("__eq__", lambda n: n == n),
+ ("__ne__", lambda n: n != np.ndarray),
+ ("__dir__", lambda n: dir(n)),
+ ("__call__", lambda n: n((1,), np.int64, BUFFER)),
+ ("__call__", lambda n: n(shape=(1,), dtype=np.int64, buffer=BUFFER)),
+ ("subclassing", lambda n: _get_subclass_mro(n)),
+ ("pickle", lambda n: n == pickle.loads(pickle.dumps(n))),
+ ("__weakref__", lambda n: n == weakref.ref(n)()),
+ ])
+ def test_pass(self, name: str, func: FuncType) -> None:
+ """Compare `types.GenericAlias` with its numpy-based backport.
+
+ Checker whether ``func`` runs as intended and that both `GenericAlias`
+ and `_GenericAlias` return the same result.
+
+ """
+ value = func(NDArray)
+
+ if sys.version_info >= (3, 9):
+ value_ref = func(NDArray_ref)
+ assert value == value_ref
+
+ @pytest.mark.parametrize("name", GETATTR_NAMES)
+ def test_getattr(self, name: str) -> None:
+ """Test that `getattr` wraps around the underlying type,
+ aka ``__origin__``.
+
+ """
+ value = getattr(NDArray, name)
+ value_ref1 = getattr(np.ndarray, name)
+
+ if sys.version_info >= (3, 9):
+ value_ref2 = getattr(NDArray_ref, name)
+ assert value == value_ref1 == value_ref2
+ else:
+ assert value == value_ref1
+
+ @pytest.mark.parametrize("name,exc_type,func", [
+ ("__getitem__", TypeError, lambda n: n[()]),
+ ("__getitem__", TypeError, lambda n: n[Any, Any]),
+ ("__getitem__", TypeError, lambda n: n[Any][Any]),
+ ("isinstance", TypeError, lambda n: isinstance(np.array(1), n)),
+ ("issublass", TypeError, lambda n: issubclass(np.ndarray, n)),
+ ("setattr", AttributeError, lambda n: setattr(n, "__origin__", int)),
+ ("setattr", AttributeError, lambda n: setattr(n, "test", int)),
+ ("getattr", AttributeError, lambda n: getattr(n, "test")),
+ ])
+ def test_raise(
+ self,
+ name: str,
+ exc_type: Type[BaseException],
+ func: FuncType,
+ ) -> None:
+ """Test operations that are supposed to raise."""
+ with pytest.raises(exc_type):
+ func(NDArray)
+
+ if sys.version_info >= (3, 9):
+ with pytest.raises(exc_type):
+ func(NDArray_ref)
diff --git a/test_requirements.txt b/test_requirements.txt
index bba27a7b1..e23ec0333 100644
--- a/test_requirements.txt
+++ b/test_requirements.txt
@@ -4,7 +4,7 @@ setuptools<49.2.0
hypothesis==6.12.0
pytest==6.2.4
pytz==2021.1
-pytest-cov==2.11.1
+pytest-cov==2.12.0
pickle5; python_version == '3.7' and platform_python_implementation != 'PyPy'
# for numpy.random.test.test_extending
cffi