Skip to content

Commit 839467f

Browse files
jorenhamcharris
authored andcommitted
TYP: ma.getmaskarray: accept array-likes (#32934)
1 parent 64b721b commit 839467f

2 files changed

Lines changed: 4 additions & 0 deletions

File tree

‎numpy/ma/core.pyi‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -620,6 +620,8 @@ get_mask = getmask
620620
def getmaskarray(arr: _ScalarLike_co) -> _MaskArray[tuple[()]]: ...
621621
@overload
622622
def getmaskarray[ShapeT: _Shape](arr: np.ndarray[ShapeT, Any]) -> _MaskArray[ShapeT]: ...
623+
@overload
624+
def getmaskarray(arr: ArrayLike) -> _MaskArray[_AnyShape]: ...
623625

624626
# It's sufficient for `m` to have dtype with type: `type[np.bool_]`,
625627
# which isn't necessarily an ndarray. Please open an issue if this causes issues.

‎numpy/typing/tests/data/reveal/ma.pyi‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -363,6 +363,8 @@ assert_type(np.ma.getmask(MAR_2d_f4), np.ndarray[tuple[int, int], np.dtype[np.bo
363363
assert_type(np.ma.getmask([1, 2]), NDArray[np.bool] | _NoMaskType)
364364
assert_type(np.ma.getmask(np.int64(1)), _NoMaskType)
365365

366+
assert_type(np.ma.getmaskarray([1, 2]), NDArray[np.bool])
367+
366368
assert_type(np.ma.is_mask(MAR_1d), bool)
367369
assert_type(np.ma.is_mask(AR_b), bool)
368370

0 commit comments

Comments
 (0)