summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCharles Harris <charlesr.harris@gmail.com>2021-05-17 11:55:19 -0600
committerGitHub <noreply@github.com>2021-05-17 11:55:19 -0600
commit1fcded9e2b89a9c6e5f31b3cae7c11b3a3293a76 (patch)
treed70b7268b3c4291d328a57f768d729ec1b6dac8c
parentacd291454aa9cbba476bd5e0d991604a18e633fe (diff)
parentc96f6255da38116590fa573e8a45973121c6b390 (diff)
downloadnumpy-1fcded9e2b89a9c6e5f31b3cae7c11b3a3293a76.tar.gz
Merge pull request #18935 from BvB93/generic-alias
API: Add `npt.NDArray`, a runtime-subscriptable alias for `np.ndarray`
-rw-r--r--doc/release/upcoming_changes/18935.new_feature.rst28
-rw-r--r--numpy/__init__.pyi780
-rw-r--r--numpy/core/_add_newdocs.py4
-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/test_generic_alias.py112
11 files changed, 816 insertions, 421 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/numpy/__init__.pyi b/numpy/__init__.pyi
index 3287e007c..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,
@@ -1629,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: ...
@@ -1895,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,
@@ -2024,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,
@@ -2046,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
@@ -3601,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]]],
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/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/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)