summaryrefslogtreecommitdiff
path: root/numpy/lib
diff options
context:
space:
mode:
authorBas van Beek <b.f.van.beek@vu.nl>2022-01-24 17:28:33 +0100
committerBas van Beek <b.f.van.beek@vu.nl>2022-01-24 17:29:37 +0100
commit03dc8bfbc809b43b91b4ecb8f481be1ce2644d66 (patch)
treeb9f69cdb9da160293a6d1fc095e13a8a4e22296e /numpy/lib
parent3fbe9852265220c77d8808210539b736be75c8c1 (diff)
downloadnumpy-03dc8bfbc809b43b91b4ecb8f481be1ce2644d66.tar.gz
MAINT: Create the `_ArrayLike` type-alias in `numpy.typing`
Represents a subset of `npt.ArrayLike` that can be parametrized w.r.t. `np.generic`
Diffstat (limited to 'numpy/lib')
-rw-r--r--numpy/lib/arraypad.pyi7
-rw-r--r--numpy/lib/arraysetops.pyi6
-rw-r--r--numpy/lib/function_base.pyi5
-rw-r--r--numpy/lib/shape_base.pyi18
-rw-r--r--numpy/lib/stride_tricks.pyi6
-rw-r--r--numpy/lib/twodim_base.pyi7
-rw-r--r--numpy/lib/type_check.pyi5
7 files changed, 15 insertions, 39 deletions
diff --git a/numpy/lib/arraypad.pyi b/numpy/lib/arraypad.pyi
index 1f74f2506..d88224dd2 100644
--- a/numpy/lib/arraypad.pyi
+++ b/numpy/lib/arraypad.pyi
@@ -6,14 +6,13 @@ from typing import (
Protocol,
)
-from numpy import ndarray, dtype, generic
+from numpy import generic
from numpy.typing import (
ArrayLike,
NDArray,
_ArrayLikeInt,
- _FiniteNestedSequence,
- _SupportsArray,
+ _ArrayLike,
)
_SCT = TypeVar("_SCT", bound=generic)
@@ -42,8 +41,6 @@ _ModeKind = L[
"empty",
]
-_ArrayLike = _FiniteNestedSequence[_SupportsArray[dtype[_SCT]]]
-
__all__: list[str]
# TODO: In practice each keyword argument is exclusive to one or more
diff --git a/numpy/lib/arraysetops.pyi b/numpy/lib/arraysetops.pyi
index e7e230bf1..c3c759d5b 100644
--- a/numpy/lib/arraysetops.pyi
+++ b/numpy/lib/arraysetops.pyi
@@ -7,7 +7,6 @@ from typing import (
)
from numpy import (
- dtype,
generic,
number,
bool_,
@@ -41,8 +40,7 @@ from numpy import (
from numpy.typing import (
ArrayLike,
NDArray,
- _FiniteNestedSequence,
- _SupportsArray,
+ _ArrayLike,
_ArrayLikeBool_co,
_ArrayLikeDT64_co,
_ArrayLikeTD64_co,
@@ -87,8 +85,6 @@ _SCTNoCast = TypeVar(
void,
)
-_ArrayLike = _FiniteNestedSequence[_SupportsArray[dtype[_SCT]]]
-
__all__: list[str]
@overload
diff --git a/numpy/lib/function_base.pyi b/numpy/lib/function_base.pyi
index d99672169..bba4c0297 100644
--- a/numpy/lib/function_base.pyi
+++ b/numpy/lib/function_base.pyi
@@ -18,7 +18,6 @@ else:
from numpy import (
vectorize as vectorize,
ufunc,
- dtype,
generic,
floating,
complexfloating,
@@ -38,8 +37,7 @@ from numpy.typing import (
_ShapeLike,
_ScalarLike_co,
_DTypeLike,
- _FiniteNestedSequence,
- _SupportsArray,
+ _ArrayLike,
_ArrayLikeInt_co,
_ArrayLikeFloat_co,
_ArrayLikeComplex_co,
@@ -67,7 +65,6 @@ _SCT = TypeVar("_SCT", bound=generic)
_ArrayType = TypeVar("_ArrayType", bound=NDArray[Any])
_2Tuple = tuple[_T, _T]
-_ArrayLike = _FiniteNestedSequence[_SupportsArray[dtype[_SCT]]]
class _TrimZerosSequence(Protocol[_T_co]):
def __len__(self) -> int: ...
diff --git a/numpy/lib/shape_base.pyi b/numpy/lib/shape_base.pyi
index 82702e67c..4c81462bb 100644
--- a/numpy/lib/shape_base.pyi
+++ b/numpy/lib/shape_base.pyi
@@ -4,7 +4,6 @@ from typing import TypeVar, Any, overload, SupportsIndex, Protocol
from numpy import (
generic,
integer,
- dtype,
ufunc,
bool_,
unsignedinteger,
@@ -18,22 +17,19 @@ from numpy.typing import (
ArrayLike,
NDArray,
_ShapeLike,
- _FiniteNestedSequence,
- _SupportsArray,
- _ArrayLikeBool_co,
- _ArrayLikeUInt_co,
- _ArrayLikeInt_co,
- _ArrayLikeFloat_co,
- _ArrayLikeComplex_co,
- _ArrayLikeObject_co,
+ _ArrayLike,
+ _ArrayLikeBool_co,
+ _ArrayLikeUInt_co,
+ _ArrayLikeInt_co,
+ _ArrayLikeFloat_co,
+ _ArrayLikeComplex_co,
+ _ArrayLikeObject_co,
)
from numpy.core.shape_base import vstack
_SCT = TypeVar("_SCT", bound=generic)
-_ArrayLike = _FiniteNestedSequence[_SupportsArray[dtype[_SCT]]]
-
# The signatures of `__array_wrap__` and `__array_prepare__` are the same;
# give them unique names for the sake of clarity
class _ArrayWrap(Protocol):
diff --git a/numpy/lib/stride_tricks.pyi b/numpy/lib/stride_tricks.pyi
index e05a9f74c..84dcd12e7 100644
--- a/numpy/lib/stride_tricks.pyi
+++ b/numpy/lib/stride_tricks.pyi
@@ -1,18 +1,16 @@
from collections.abc import Iterable
from typing import Any, TypeVar, overload, SupportsIndex
-from numpy import dtype, generic
+from numpy import generic
from numpy.typing import (
NDArray,
ArrayLike,
_ShapeLike,
_Shape,
- _FiniteNestedSequence,
- _SupportsArray,
+ _ArrayLike
)
_SCT = TypeVar("_SCT", bound=generic)
-_ArrayLike = _FiniteNestedSequence[_SupportsArray[dtype[_SCT]]]
__all__: list[str]
diff --git a/numpy/lib/twodim_base.pyi b/numpy/lib/twodim_base.pyi
index 1ac510ac2..b08cf8383 100644
--- a/numpy/lib/twodim_base.pyi
+++ b/numpy/lib/twodim_base.pyi
@@ -7,8 +7,6 @@ from typing import (
)
from numpy import (
- ndarray,
- dtype,
generic,
number,
bool_,
@@ -28,9 +26,8 @@ from numpy.typing import (
DTypeLike,
_DTypeLike,
ArrayLike,
+ _ArrayLike,
NDArray,
- _FiniteNestedSequence,
- _SupportsArray,
_SupportsArrayFunc,
_ArrayLikeInt_co,
_ArrayLikeFloat_co,
@@ -47,8 +44,6 @@ _MaskFunc = Callable[
NDArray[Union[number[Any], bool_, timedelta64, datetime64, object_]],
]
-_ArrayLike = _FiniteNestedSequence[_SupportsArray[dtype[_SCT]]]
-
__all__: list[str]
@overload
diff --git a/numpy/lib/type_check.pyi b/numpy/lib/type_check.pyi
index 72eb777be..0d8eeb1bd 100644
--- a/numpy/lib/type_check.pyi
+++ b/numpy/lib/type_check.pyi
@@ -25,8 +25,7 @@ from numpy.typing import (
_64Bit,
_SupportsDType,
_ScalarLike_co,
- _FiniteNestedSequence,
- _SupportsArray,
+ _ArrayLike,
_DTypeLikeComplex,
)
@@ -36,8 +35,6 @@ _SCT = TypeVar("_SCT", bound=generic)
_NBit1 = TypeVar("_NBit1", bound=NBitBase)
_NBit2 = TypeVar("_NBit2", bound=NBitBase)
-_ArrayLike = _FiniteNestedSequence[_SupportsArray[dtype[_SCT]]]
-
class _SupportsReal(Protocol[_T_co]):
@property
def real(self) -> _T_co: ...