diff options
author | BvB93 <43369155+BvB93@users.noreply.github.com> | 2022-10-06 13:37:50 +0200 |
---|---|---|
committer | BvB93 <43369155+BvB93@users.noreply.github.com> | 2022-11-14 17:43:37 +0100 |
commit | 473b80f9b6cecdef0e26b0c9396e194353d92719 (patch) | |
tree | 365c5d6c433848e71ded7d754661112426fb8cca /numpy/core/shape_base.pyi | |
parent | 8205e5d295d2844f603c31523968804468c9f101 (diff) | |
download | numpy-473b80f9b6cecdef0e26b0c9396e194353d92719.tar.gz |
TYP,ENH: Improve the `dtype`-overload of `stack`, `hstack` and `vstack`
Xref https://github.com/numpy/numpy/pull/21627
Diffstat (limited to 'numpy/core/shape_base.pyi')
-rw-r--r-- | numpy/core/shape_base.pyi | 51 |
1 files changed, 40 insertions, 11 deletions
diff --git a/numpy/core/shape_base.pyi b/numpy/core/shape_base.pyi index 82541b55b..10116f1ee 100644 --- a/numpy/core/shape_base.pyi +++ b/numpy/core/shape_base.pyi @@ -2,7 +2,13 @@ from collections.abc import Sequence from typing import TypeVar, overload, Any, SupportsIndex from numpy import generic, _CastingKind -from numpy._typing import ArrayLike, NDArray, _ArrayLike, DTypeLike +from numpy._typing import ( + NDArray, + ArrayLike, + DTypeLike, + _ArrayLike, + _DTypeLike, +) _SCT = TypeVar("_SCT", bound=generic) _ArrayType = TypeVar("_ArrayType", bound=NDArray[Any]) @@ -34,29 +40,43 @@ def atleast_3d(*arys: ArrayLike) -> list[NDArray[Any]]: ... def vstack( tup: Sequence[_ArrayLike[_SCT]], *, - dtype: DTypeLike = ..., + dtype: None = ..., casting: _CastingKind = ... ) -> NDArray[_SCT]: ... @overload def vstack( tup: Sequence[ArrayLike], *, - dtype: DTypeLike = ..., + dtype: _DTypeLike[_SCT], + casting: _CastingKind = ... +) -> NDArray[_SCT]: ... +@overload +def vstack( + tup: Sequence[ArrayLike], + *, + dtype: DTypeLike = ..., casting: _CastingKind = ... ) -> NDArray[Any]: ... @overload def hstack( - tup: Sequence[_ArrayLike[_SCT]], + tup: Sequence[_ArrayLike[_SCT]], + *, + dtype: None = ..., + casting: _CastingKind = ... +) -> NDArray[_SCT]: ... +@overload +def hstack( + tup: Sequence[ArrayLike], *, - dtype: DTypeLike = ..., + dtype: _DTypeLike[_SCT], casting: _CastingKind = ... ) -> NDArray[_SCT]: ... @overload def hstack( - tup: Sequence[ArrayLike], + tup: Sequence[ArrayLike], *, - dtype: DTypeLike = ..., + dtype: DTypeLike = ..., casting: _CastingKind = ... ) -> NDArray[Any]: ... @@ -64,9 +84,18 @@ def hstack( def stack( arrays: Sequence[_ArrayLike[_SCT]], axis: SupportsIndex = ..., - out: None = ..., + out: None = ..., *, - dtype: DTypeLike = ..., + dtype: None = ..., + casting: _CastingKind = ... +) -> NDArray[_SCT]: ... +@overload +def stack( + arrays: Sequence[ArrayLike], + axis: SupportsIndex = ..., + out: None = ..., + *, + dtype: _DTypeLike[_SCT], casting: _CastingKind = ... ) -> NDArray[_SCT]: ... @overload @@ -75,7 +104,7 @@ def stack( axis: SupportsIndex = ..., out: None = ..., *, - dtype: DTypeLike = ..., + dtype: DTypeLike = ..., casting: _CastingKind = ... ) -> NDArray[Any]: ... @overload @@ -84,7 +113,7 @@ def stack( axis: SupportsIndex = ..., out: _ArrayType = ..., *, - dtype: DTypeLike = ..., + dtype: DTypeLike = ..., casting: _CastingKind = ... ) -> _ArrayType: ... |