Skip to content

Commit 399fce5

Browse files
committed
Add type overloads and test for unstack
1 parent cb89976 commit 399fce5

File tree

2 files changed

+9
-0
lines changed

2 files changed

+9
-0
lines changed

numpy/_core/shape_base.pyi

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -117,6 +117,12 @@ def stack(
117117
casting: _CastingKind = ...
118118
) -> _ArrayType: ...
119119

120+
@overload
121+
def unstack(
122+
array: _ArrayLike[_SCT],
123+
axis: int = 0
124+
) -> tuple[NDArray[_SCT], ...]: ...
125+
120126
@overload
121127
def block(arrays: _ArrayLike[_SCT]) -> NDArray[_SCT]: ...
122128
@overload

numpy/typing/tests/data/reveal/shape_base.pyi

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,3 +53,6 @@ assert_type(np.kron(AR_f8, AR_f8), npt.NDArray[np.floating[Any]])
5353

5454
assert_type(np.tile(AR_i8, 5), npt.NDArray[np.int64])
5555
assert_type(np.tile(AR_LIKE_f8, [2, 2]), npt.NDArray[Any])
56+
57+
assert_type(np.unstack(AR_i8, 5), list[npt.NDArray[np.int64]])
58+
assert_type(np.unstack(AR_LIKE_f8, 5), list[npt.NDArray[Any]])

0 commit comments

Comments
 (0)