diff options
-rw-r--r-- | numpy/__init__.pyi | 5 | ||||
-rw-r--r-- | numpy/core/multiarray.pyi | 31 | ||||
-rw-r--r-- | numpy/core/numeric.pyi | 17 |
3 files changed, 35 insertions, 18 deletions
diff --git a/numpy/__init__.pyi b/numpy/__init__.pyi index c6cf0aacf..d5efe19bb 100644 --- a/numpy/__init__.pyi +++ b/numpy/__init__.pyi @@ -294,11 +294,14 @@ from numpy.core.einsumfunc import ( einsum_path as einsum_path, ) +from numpy.core.multiarray import ( + empty_like as empty_like, +) + from numpy.core.numeric import ( zeros_like as zeros_like, ones as ones, ones_like as ones_like, - empty_like as empty_like, full as full, full_like as full_like, count_nonzero as count_nonzero, diff --git a/numpy/core/multiarray.pyi b/numpy/core/multiarray.pyi new file mode 100644 index 000000000..cd8518ed6 --- /dev/null +++ b/numpy/core/multiarray.pyi @@ -0,0 +1,31 @@ +from typing import Any, Optional, overload, TypeVar, List, Type, Union + +from numpy import dtype, generic, _OrderKACF +from numpy.typing import ArrayLike, NDArray, DTypeLike, _ShapeLike, _SupportsDType + +_SCT = TypeVar("_SCT", bound=generic) + +_DTypeLike = Union[ + dtype[_SCT], + Type[_SCT], + _SupportsDType[dtype[_SCT]], +] + +__all__: List[str] + +@overload +def empty_like( + a: ArrayLike, + dtype: _DTypeLike[_SCT], + order: _OrderKACF = ..., + subok: bool = ..., + shape: Optional[_ShapeLike] = ..., +) -> NDArray[_SCT]: ... +@overload +def empty_like( + a: ArrayLike, + dtype: DTypeLike = ..., + order: _OrderKACF = ..., + subok: bool = ..., + shape: Optional[_ShapeLike] = ..., +) -> NDArray[Any]: ... diff --git a/numpy/core/numeric.pyi b/numpy/core/numeric.pyi index f57951434..3c2b553ec 100644 --- a/numpy/core/numeric.pyi +++ b/numpy/core/numeric.pyi @@ -67,23 +67,6 @@ def ones_like( shape: Optional[_ShapeLike] = ..., ) -> ndarray: ... -@overload -def empty_like( - a: _ArrayType, - dtype: None = ..., - order: _OrderKACF = ..., - subok: Literal[True] = ..., - shape: None = ..., -) -> _ArrayType: ... -@overload -def empty_like( - a: ArrayLike, - dtype: DTypeLike = ..., - order: _OrderKACF = ..., - subok: bool = ..., - shape: Optional[_ShapeLike] = ..., -) -> ndarray: ... - def full( shape: _ShapeLike, fill_value: Any, |