Skip to content

Commit 89a0a3d

Browse files
committed
👽️ pad accept dict for pad_width
1 parent 116a9c2 commit 89a0a3d

File tree

1 file changed

+7
-4
lines changed

1 file changed

+7
-4
lines changed

src/numpy-stubs/lib/_arraypad_impl.pyi

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -27,10 +27,13 @@ class _ModeFunc(Protocol):
2727

2828
# TODO: In practice each keyword argument is exclusive to one or more
2929
# specific modes. Consider adding more overloads to express this in the future.
30+
31+
_PadWidth: TypeAlias = _ArrayLikeInt | dict[int, int] | dict[int, tuple[int, int]] | dict[int, int | tuple[int, int]]
32+
3033
@overload
3134
def pad(
3235
array: _ArrayLike[_ScalarT],
33-
pad_width: _ArrayLikeInt,
36+
pad_width: _PadWidth,
3437
mode: _ModeKind = ...,
3538
*,
3639
stat_length: _ArrayLikeInt | None = ...,
@@ -41,7 +44,7 @@ def pad(
4144
@overload
4245
def pad(
4346
array: ArrayLike,
44-
pad_width: _ArrayLikeInt,
47+
pad_width: _PadWidth,
4548
mode: _ModeKind = ...,
4649
*,
4750
stat_length: _ArrayLikeInt | None = ...,
@@ -51,7 +54,7 @@ def pad(
5154
) -> _nt.Array[Incomplete]: ...
5255
@overload
5356
def pad(
54-
array: _ArrayLike[_ScalarT], pad_width: _ArrayLikeInt, mode: _ModeFunc, **kwargs: object
57+
array: _ArrayLike[_ScalarT], pad_width: _PadWidth, mode: _ModeFunc, **kwargs: object
5558
) -> _nt.Array[_ScalarT]: ...
5659
@overload
57-
def pad(array: ArrayLike, pad_width: _ArrayLikeInt, mode: _ModeFunc, **kwargs: object) -> _nt.Array[Incomplete]: ...
60+
def pad(array: ArrayLike, pad_width: _PadWidth, mode: _ModeFunc, **kwargs: object) -> _nt.Array[Incomplete]: ...

0 commit comments

Comments
 (0)