summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBas van Beek <b.f.van.beek@vu.nl>2021-01-18 16:11:05 +0100
committerBas van Beek <b.f.van.beek@vu.nl>2021-01-18 17:00:33 +0100
commit2a5647a8e82f5a604f9101a02e82bf287cba1bc8 (patch)
tree1469255f3f221ae79673cf3b9317feb17522e9b0
parent7081c2eb2522ac22c4e26a5a6e8a35c4cf498d88 (diff)
downloadnumpy-2a5647a8e82f5a604f9101a02e82bf287cba1bc8.tar.gz
MAINT: Simplify a union
`_BoolLike_co` is already a subtype of `_IntLike_co`, no nead the use an explicit union here
-rw-r--r--numpy/__init__.pyi16
-rw-r--r--numpy/core/fromnumeric.pyi3
-rw-r--r--numpy/typing/_callable.py24
3 files changed, 21 insertions, 22 deletions
diff --git a/numpy/__init__.pyi b/numpy/__init__.pyi
index afb85e7b4..be87a166e 100644
--- a/numpy/__init__.pyi
+++ b/numpy/__init__.pyi
@@ -25,7 +25,7 @@ from numpy.typing import (
_IntLike_co,
_FloatLike_co,
_ComplexLike_co,
- _FloatLike_co,
+ _TD64Like_co,
_NumberLike_co,
# `number` precision
@@ -1653,12 +1653,12 @@ class datetime64(generic):
__value: int,
__format: Union[_CharLike_co, Tuple[_CharLike_co, _IntLike_co]]
) -> None: ...
- def __add__(self, other: _FloatLike_co) -> datetime64: ...
- def __radd__(self, other: _FloatLike_co) -> datetime64: ...
+ def __add__(self, other: _TD64Like_co) -> datetime64: ...
+ def __radd__(self, other: _TD64Like_co) -> datetime64: ...
@overload
def __sub__(self, other: datetime64) -> timedelta64: ...
@overload
- def __sub__(self, other: _FloatLike_co) -> datetime64: ...
+ def __sub__(self, other: _TD64Like_co) -> datetime64: ...
def __rsub__(self, other: datetime64) -> timedelta64: ...
__lt__: _ComparisonOp[datetime64]
__le__: _ComparisonOp[datetime64]
@@ -1748,10 +1748,10 @@ class timedelta64(generic):
def __neg__(self: _ArraySelf) -> _ArraySelf: ...
def __pos__(self: _ArraySelf) -> _ArraySelf: ...
def __abs__(self: _ArraySelf) -> _ArraySelf: ...
- def __add__(self, other: _FloatLike_co) -> timedelta64: ...
- def __radd__(self, other: _FloatLike_co) -> timedelta64: ...
- def __sub__(self, other: _FloatLike_co) -> timedelta64: ...
- def __rsub__(self, other: _FloatLike_co) -> timedelta64: ...
+ def __add__(self, other: _TD64Like_co) -> timedelta64: ...
+ def __radd__(self, other: _TD64Like_co) -> timedelta64: ...
+ def __sub__(self, other: _TD64Like_co) -> timedelta64: ...
+ def __rsub__(self, other: _TD64Like_co) -> timedelta64: ...
def __mul__(self, other: _FloatLike_co) -> timedelta64: ...
def __rmul__(self, other: _FloatLike_co) -> timedelta64: ...
__truediv__: _TD64Div[float64]
diff --git a/numpy/core/fromnumeric.pyi b/numpy/core/fromnumeric.pyi
index 87c85e26b..fc7f28a59 100644
--- a/numpy/core/fromnumeric.pyi
+++ b/numpy/core/fromnumeric.pyi
@@ -24,7 +24,6 @@ from numpy.typing import (
_ShapeLike,
_Shape,
_IntLike_co,
- _BoolLike_co,
_NumberLike_co,
)
@@ -98,7 +97,7 @@ def choose(
) -> _ScalarIntOrBool: ...
@overload
def choose(
- a: Union[_IntLike_co, _BoolLike_co], choices: ArrayLike, out: Optional[ndarray] = ..., mode: _ModeKind = ...
+ a: _IntLike_co, choices: ArrayLike, out: Optional[ndarray] = ..., mode: _ModeKind = ...
) -> Union[integer, bool_]: ...
@overload
def choose(
diff --git a/numpy/typing/_callable.py b/numpy/typing/_callable.py
index 8f464cc75..693b6dfed 100644
--- a/numpy/typing/_callable.py
+++ b/numpy/typing/_callable.py
@@ -37,11 +37,11 @@ from numpy import (
)
from ._nbit import _NBitInt
from ._scalars import (
- _BoolLike,
- _IntLike,
- _FloatLike,
- _ComplexLike,
- _NumberLike,
+ _BoolLike_co,
+ _IntLike_co,
+ _FloatLike_co,
+ _ComplexLike_co,
+ _NumberLike_co,
)
from . import NBitBase
from ._array_like import ArrayLike
@@ -72,7 +72,7 @@ if TYPE_CHECKING or HAVE_PROTOCOL:
class _BoolOp(Protocol[_GenericType_co]):
@overload
- def __call__(self, __other: _BoolLike) -> _GenericType_co: ...
+ def __call__(self, __other: _BoolLike_co) -> _GenericType_co: ...
@overload # platform dependent
def __call__(self, __other: int) -> int_: ...
@overload
@@ -84,7 +84,7 @@ if TYPE_CHECKING or HAVE_PROTOCOL:
class _BoolBitOp(Protocol[_GenericType_co]):
@overload
- def __call__(self, __other: _BoolLike) -> _GenericType_co: ...
+ def __call__(self, __other: _BoolLike_co) -> _GenericType_co: ...
@overload # platform dependent
def __call__(self, __other: int) -> int_: ...
@overload
@@ -105,7 +105,7 @@ if TYPE_CHECKING or HAVE_PROTOCOL:
class _BoolTrueDiv(Protocol):
@overload
- def __call__(self, __other: Union[float, _IntLike]) -> float64: ...
+ def __call__(self, __other: Union[float, _IntLike_co]) -> float64: ...
@overload
def __call__(self, __other: complex) -> complex128: ...
@overload
@@ -113,7 +113,7 @@ if TYPE_CHECKING or HAVE_PROTOCOL:
class _BoolMod(Protocol):
@overload
- def __call__(self, __other: _BoolLike) -> int8: ...
+ def __call__(self, __other: _BoolLike_co) -> int8: ...
@overload # platform dependent
def __call__(self, __other: int) -> int_: ...
@overload
@@ -125,7 +125,7 @@ if TYPE_CHECKING or HAVE_PROTOCOL:
class _BoolDivMod(Protocol):
@overload
- def __call__(self, __other: _BoolLike) -> _2Tuple[int8]: ...
+ def __call__(self, __other: _BoolLike_co) -> _2Tuple[int8]: ...
@overload # platform dependent
def __call__(self, __other: int) -> _2Tuple[int_]: ...
@overload
@@ -139,7 +139,7 @@ if TYPE_CHECKING or HAVE_PROTOCOL:
@overload
def __call__(self, __other: timedelta64) -> _NumberType_co: ...
@overload
- def __call__(self, __other: _FloatLike) -> timedelta64: ...
+ def __call__(self, __other: _FloatLike_co) -> timedelta64: ...
class _IntTrueDiv(Protocol[_NBit_co]):
@overload
@@ -314,7 +314,7 @@ if TYPE_CHECKING or HAVE_PROTOCOL:
) -> complexfloating[Union[_NBit_co, _NBit], Union[_NBit_co, _NBit]]: ...
class _NumberOp(Protocol):
- def __call__(self, __other: _NumberLike) -> number: ...
+ def __call__(self, __other: _NumberLike_co) -> number: ...
class _ComparisonOp(Protocol[_T]):
@overload