summaryrefslogtreecommitdiff
path: root/numpy/core
diff options
context:
space:
mode:
authorBas van Beek <b.f.van.beek@vu.nl>2022-01-24 17:17:35 +0100
committerBas van Beek <b.f.van.beek@vu.nl>2022-01-24 17:29:03 +0100
commit5264dc220dc208e533bdbdcafa9f4f06ddb04aab (patch)
tree5c3035d8acba53fe3a4efe9600f7a88eceefa055 /numpy/core
parent6218e76bc590e9253ed8d4c4b18c74aa81332b15 (diff)
downloadnumpy-5264dc220dc208e533bdbdcafa9f4f06ddb04aab.tar.gz
MAINT: Create the `_DTypeLike` type-alias in `numpy.typing`
Represents a subset of `npt.DTypeLike` that can be parametrized w.r.t. `np.generic`
Diffstat (limited to 'numpy/core')
-rw-r--r--numpy/core/function_base.pyi14
-rw-r--r--numpy/core/multiarray.pyi10
-rw-r--r--numpy/core/numeric.pyi8
-rw-r--r--numpy/core/numerictypes.pyi9
4 files changed, 5 insertions, 36 deletions
diff --git a/numpy/core/function_base.pyi b/numpy/core/function_base.pyi
index b21892177..520046c19 100644
--- a/numpy/core/function_base.pyi
+++ b/numpy/core/function_base.pyi
@@ -1,32 +1,22 @@
from typing import (
Literal as L,
overload,
- Union,
Any,
SupportsIndex,
TypeVar,
)
-from numpy import floating, complexfloating, generic, dtype
+from numpy import floating, complexfloating, generic
from numpy.typing import (
NDArray,
- ArrayLike,
DTypeLike,
- _SupportsDType,
- _SupportsArray,
- _NumberLike_co,
+ _DTypeLike,
_ArrayLikeFloat_co,
_ArrayLikeComplex_co,
)
_SCT = TypeVar("_SCT", bound=generic)
-_DTypeLike = Union[
- dtype[_SCT],
- type[_SCT],
- _SupportsDType[dtype[_SCT]],
-]
-
__all__: list[str]
@overload
diff --git a/numpy/core/multiarray.pyi b/numpy/core/multiarray.pyi
index f2d3622d2..21af904b9 100644
--- a/numpy/core/multiarray.pyi
+++ b/numpy/core/multiarray.pyi
@@ -8,11 +8,9 @@ from typing import (
Any,
overload,
TypeVar,
- Union,
SupportsIndex,
final,
Final,
- Protocol,
)
from numpy import (
@@ -55,7 +53,7 @@ from numpy.typing import (
# DTypes
DTypeLike,
- _SupportsDType,
+ _DTypeLike,
# Arrays
NDArray,
@@ -83,12 +81,6 @@ from numpy.typing import (
_SCT = TypeVar("_SCT", bound=generic)
_ArrayType = TypeVar("_ArrayType", bound=NDArray[Any])
-# Subscriptable subsets of `npt.DTypeLike` and `npt.ArrayLike`
-_DTypeLike = Union[
- dtype[_SCT],
- type[_SCT],
- _SupportsDType[dtype[_SCT]],
-]
_ArrayLike = _FiniteNestedSequence[_SupportsArray[dtype[_SCT]]]
# Valid time units
diff --git a/numpy/core/numeric.pyi b/numpy/core/numeric.pyi
index d5e28d24c..367a2bff8 100644
--- a/numpy/core/numeric.pyi
+++ b/numpy/core/numeric.pyi
@@ -1,7 +1,6 @@
from collections.abc import Callable, Sequence
from typing import (
Any,
- Union,
overload,
TypeVar,
Literal,
@@ -34,7 +33,7 @@ from numpy.typing import (
NDArray,
DTypeLike,
_ShapeLike,
- _SupportsDType,
+ _DTypeLike,
_FiniteNestedSequence,
_SupportsArray,
_SupportsArrayFunc,
@@ -52,11 +51,6 @@ _T = TypeVar("_T")
_SCT = TypeVar("_SCT", bound=generic)
_ArrayType = TypeVar("_ArrayType", bound=NDArray[Any])
-_DTypeLike = Union[
- dtype[_SCT],
- type[_SCT],
- _SupportsDType[dtype[_SCT]],
-]
_ArrayLike = _FiniteNestedSequence[_SupportsArray[dtype[_SCT]]]
_CorrelateMode = Literal["valid", "same", "full"]
diff --git a/numpy/core/numerictypes.pyi b/numpy/core/numerictypes.pyi
index 09c180a0f..eef4fef72 100644
--- a/numpy/core/numerictypes.pyi
+++ b/numpy/core/numerictypes.pyi
@@ -46,18 +46,11 @@ from numpy.core._type_aliases import (
sctypes as sctypes,
)
-from numpy.typing import DTypeLike, ArrayLike, _SupportsDType
+from numpy.typing import DTypeLike, ArrayLike, _DTypeLike
_T = TypeVar("_T")
_SCT = TypeVar("_SCT", bound=generic)
-# A paramtrizable subset of `npt.DTypeLike`
-_DTypeLike = Union[
- type[_SCT],
- dtype[_SCT],
- _SupportsDType[dtype[_SCT]],
-]
-
class _CastFunc(Protocol):
def __call__(
self, x: ArrayLike, k: DTypeLike = ...