summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBas van Beek <b.f.van.beek@vu.nl>2021-05-12 15:16:11 +0200
committerBas van Beek <b.f.van.beek@vu.nl>2021-05-12 15:35:19 +0200
commita307f98aa724c4d0aead7dd2629e696fe670cc35 (patch)
treeb93a152cb361f98d0af3d33a9d3eed8d4846c0c0
parent888ffb0a97ecedd73d07ee2935434412f76c277e (diff)
downloadnumpy-a307f98aa724c4d0aead7dd2629e696fe670cc35.tar.gz
MAINT: Remove two duplicate (redundant) type aliases
-rw-r--r--numpy/__init__.pyi38
-rw-r--r--numpy/core/fromnumeric.pyi28
2 files changed, 29 insertions, 37 deletions
diff --git a/numpy/__init__.pyi b/numpy/__init__.pyi
index 46b320158..f0f0e2ba1 100644
--- a/numpy/__init__.pyi
+++ b/numpy/__init__.pyi
@@ -1207,14 +1207,6 @@ _PartitionKind = Literal["introselect"]
_SortKind = Literal["quicksort", "mergesort", "heapsort", "stable"]
_SortSide = Literal["left", "right"]
-_ArrayLikeBool = Union[_BoolLike_co, Sequence[_BoolLike_co], ndarray]
-_ArrayLikeIntOrBool = Union[
- _IntLike_co,
- ndarray,
- Sequence[_IntLike_co],
- Sequence[Sequence[Any]], # TODO: wait for support for recursive types
-]
-
_ArraySelf = TypeVar("_ArraySelf", bound=_ArrayOrScalarCommon)
class _ArrayOrScalarCommon:
@@ -1482,7 +1474,7 @@ class _ArrayOrScalarCommon:
out: None = ...,
keepdims: bool = ...,
initial: _NumberLike_co = ...,
- where: _ArrayLikeBool = ...,
+ where: _ArrayLikeBool_co = ...,
) -> Any: ...
@overload
def max(
@@ -1491,7 +1483,7 @@ class _ArrayOrScalarCommon:
out: _NdArraySubClass = ...,
keepdims: bool = ...,
initial: _NumberLike_co = ...,
- where: _ArrayLikeBool = ...,
+ where: _ArrayLikeBool_co = ...,
) -> _NdArraySubClass: ...
@overload
@@ -1518,7 +1510,7 @@ class _ArrayOrScalarCommon:
out: None = ...,
keepdims: bool = ...,
initial: _NumberLike_co = ...,
- where: _ArrayLikeBool = ...,
+ where: _ArrayLikeBool_co = ...,
) -> Any: ...
@overload
def min(
@@ -1527,7 +1519,7 @@ class _ArrayOrScalarCommon:
out: _NdArraySubClass = ...,
keepdims: bool = ...,
initial: _NumberLike_co = ...,
- where: _ArrayLikeBool = ...,
+ where: _ArrayLikeBool_co = ...,
) -> _NdArraySubClass: ...
def newbyteorder(
@@ -1543,7 +1535,7 @@ class _ArrayOrScalarCommon:
out: None = ...,
keepdims: bool = ...,
initial: _NumberLike_co = ...,
- where: _ArrayLikeBool = ...,
+ where: _ArrayLikeBool_co = ...,
) -> Any: ...
@overload
def prod(
@@ -1553,7 +1545,7 @@ class _ArrayOrScalarCommon:
out: _NdArraySubClass = ...,
keepdims: bool = ...,
initial: _NumberLike_co = ...,
- where: _ArrayLikeBool = ...,
+ where: _ArrayLikeBool_co = ...,
) -> _NdArraySubClass: ...
@overload
@@ -1573,7 +1565,7 @@ class _ArrayOrScalarCommon:
def repeat(
self,
- repeats: _ArrayLikeIntOrBool,
+ repeats: _ArrayLikeInt_co,
axis: Optional[SupportsIndex] = ...,
) -> ndarray: ...
@@ -1617,7 +1609,7 @@ class _ArrayOrScalarCommon:
out: None = ...,
keepdims: bool = ...,
initial: _NumberLike_co = ...,
- where: _ArrayLikeBool = ...,
+ where: _ArrayLikeBool_co = ...,
) -> Any: ...
@overload
def sum(
@@ -1627,7 +1619,7 @@ class _ArrayOrScalarCommon:
out: _NdArraySubClass = ...,
keepdims: bool = ...,
initial: _NumberLike_co = ...,
- where: _ArrayLikeBool = ...,
+ where: _ArrayLikeBool_co = ...,
) -> _NdArraySubClass: ...
@overload
@@ -1641,7 +1633,7 @@ class _ArrayOrScalarCommon:
@overload
def take(
self,
- indices: _ArrayLikeIntOrBool,
+ indices: _ArrayLikeInt_co,
axis: Optional[SupportsIndex] = ...,
out: None = ...,
mode: _ModeKind = ...,
@@ -1649,7 +1641,7 @@ class _ArrayOrScalarCommon:
@overload
def take(
self,
- indices: _ArrayLikeIntOrBool,
+ indices: _ArrayLikeInt_co,
axis: Optional[SupportsIndex] = ...,
out: _NdArraySubClass = ...,
mode: _ModeKind = ...,
@@ -1761,7 +1753,7 @@ class ndarray(_ArrayOrScalarCommon, Generic[_ShapeType, _DType_co]):
def transpose(self: _ArraySelf, *axes: SupportsIndex) -> _ArraySelf: ...
def argpartition(
self,
- kth: _ArrayLikeIntOrBool,
+ kth: _ArrayLikeInt_co,
axis: Optional[SupportsIndex] = ...,
kind: _PartitionKind = ...,
order: Union[None, str, Sequence[str]] = ...,
@@ -1780,7 +1772,7 @@ class ndarray(_ArrayOrScalarCommon, Generic[_ShapeType, _DType_co]):
def nonzero(self) -> Tuple[ndarray, ...]: ...
def partition(
self,
- kth: _ArrayLikeIntOrBool,
+ kth: _ArrayLikeInt_co,
axis: SupportsIndex = ...,
kind: _PartitionKind = ...,
order: Union[None, str, Sequence[str]] = ...,
@@ -1788,13 +1780,13 @@ class ndarray(_ArrayOrScalarCommon, Generic[_ShapeType, _DType_co]):
# `put` is technically available to `generic`,
# but is pointless as `generic`s are immutable
def put(
- self, ind: _ArrayLikeIntOrBool, v: ArrayLike, mode: _ModeKind = ...
+ self, ind: _ArrayLikeInt_co, v: ArrayLike, mode: _ModeKind = ...
) -> None: ...
def searchsorted(
self, # >= 1D array
v: ArrayLike,
side: _SortSide = ...,
- sorter: Optional[_ArrayLikeIntOrBool] = ..., # 1D int array
+ sorter: Optional[_ArrayLikeInt_co] = ..., # 1D int array
) -> ndarray: ...
def setfield(
self, val: ArrayLike, dtype: DTypeLike, offset: SupportsIndex = ...
diff --git a/numpy/core/fromnumeric.pyi b/numpy/core/fromnumeric.pyi
index 26a43c1a0..3342ec3ac 100644
--- a/numpy/core/fromnumeric.pyi
+++ b/numpy/core/fromnumeric.pyi
@@ -11,8 +11,6 @@ from numpy import (
generic,
_OrderKACF,
_OrderACF,
- _ArrayLikeBool,
- _ArrayLikeIntOrBool,
_ModeKind,
_PartitionKind,
_SortKind,
@@ -23,6 +21,8 @@ from numpy.typing import (
ArrayLike,
_ShapeLike,
_Shape,
+ _ArrayLikeBool_co,
+ _ArrayLikeInt_co,
_NumberLike_co,
)
@@ -52,7 +52,7 @@ _Number = TypeVar("_Number", bound=number)
# 4. An array-like object comes in; an ndarray or generic comes out
def take(
a: ArrayLike,
- indices: _ArrayLikeIntOrBool,
+ indices: _ArrayLikeInt_co,
axis: Optional[int] = ...,
out: Optional[ndarray] = ...,
mode: _ModeKind = ...,
@@ -65,7 +65,7 @@ def reshape(
) -> ndarray: ...
def choose(
- a: _ArrayLikeIntOrBool,
+ a: _ArrayLikeInt_co,
choices: ArrayLike,
out: Optional[ndarray] = ...,
mode: _ModeKind = ...,
@@ -73,13 +73,13 @@ def choose(
def repeat(
a: ArrayLike,
- repeats: _ArrayLikeIntOrBool,
+ repeats: _ArrayLikeInt_co,
axis: Optional[int] = ...,
) -> ndarray: ...
def put(
a: ndarray,
- ind: _ArrayLikeIntOrBool,
+ ind: _ArrayLikeInt_co,
v: ArrayLike,
mode: _ModeKind = ...,
) -> None: ...
@@ -97,7 +97,7 @@ def transpose(
def partition(
a: ArrayLike,
- kth: _ArrayLikeIntOrBool,
+ kth: _ArrayLikeInt_co,
axis: Optional[int] = ...,
kind: _PartitionKind = ...,
order: Union[None, str, Sequence[str]] = ...,
@@ -105,7 +105,7 @@ def partition(
def argpartition(
a: ArrayLike,
- kth: _ArrayLikeIntOrBool,
+ kth: _ArrayLikeInt_co,
axis: Optional[int] = ...,
kind: _PartitionKind = ...,
order: Union[None, str, Sequence[str]] = ...,
@@ -156,14 +156,14 @@ def searchsorted(
a: ArrayLike,
v: _Scalar,
side: _SortSide = ...,
- sorter: Optional[_ArrayLikeIntOrBool] = ..., # 1D int array
+ sorter: Optional[_ArrayLikeInt_co] = ..., # 1D int array
) -> intp: ...
@overload
def searchsorted(
a: ArrayLike,
v: ArrayLike,
side: _SortSide = ...,
- sorter: Optional[_ArrayLikeIntOrBool] = ..., # 1D int array
+ sorter: Optional[_ArrayLikeInt_co] = ..., # 1D int array
) -> ndarray: ...
def resize(
@@ -235,7 +235,7 @@ def sum(
out: Optional[ndarray] = ...,
keepdims: bool = ...,
initial: _NumberLike_co = ...,
- where: _ArrayLikeBool = ...,
+ where: _ArrayLikeBool_co = ...,
) -> Any: ...
@overload
@@ -288,7 +288,7 @@ def amax(
out: Optional[ndarray] = ...,
keepdims: bool = ...,
initial: _NumberLike_co = ...,
- where: _ArrayLikeBool = ...,
+ where: _ArrayLikeBool_co = ...,
) -> Any: ...
def amin(
@@ -297,7 +297,7 @@ def amin(
out: Optional[ndarray] = ...,
keepdims: bool = ...,
initial: _NumberLike_co = ...,
- where: _ArrayLikeBool = ...,
+ where: _ArrayLikeBool_co = ...,
) -> Any: ...
# TODO: `np.prod()``: For object arrays `initial` does not necessarily
@@ -314,7 +314,7 @@ def prod(
out: Optional[ndarray] = ...,
keepdims: bool = ...,
initial: _NumberLike_co = ...,
- where: _ArrayLikeBool = ...,
+ where: _ArrayLikeBool_co = ...,
) -> Any: ...
def cumprod(