8000 TYP: Type ``MaskedArray.put``, ``np.ma.put``, ``np.ma.putmask`` by MarcoGorelli · Pull Request #28745 · numpy/numpy · GitHub
[go: up one dir, main page]

Skip to content

TYP: Type MaskedArray.put, np.ma.put, np.ma.putmask #28745

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Apr 17, 2025
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
TYP: Type MaskedArray.put and np.ma.put
  • Loading branch information
MarcoGorelli committed Apr 17, 2025
commit a7008556a64b8f66423390331c4adb9d4b0fece9
4 changes: 2 additions & 2 deletions numpy/ma/core.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -467,7 +467,7 @@ class MaskedArray(ndarray[_ShapeT_co, _DTypeT_co]):
def ravel(self, order=...): ...
def reshape(self, *s, **kwargs): ...
def resize(self, newshape, refcheck=..., order=...): ...
def put(self, indices, values, mode=...): ...
def put(self, indices: _ArrayLikeInt_co, values: ArrayLike, mode: _ModeKind = "raise") -> None: ...
def ids(self) -> tuple[int, int]: ...
def iscontiguous(self) -> bool: ...
def all(self, axis=..., out=..., keepdims=...): ...
Expand Down Expand Up @@ -1127,7 +1127,7 @@ def concatenate(arrays, axis=...): ...
def diag(v, k=...): ...
def left_shift(a, n): ...
def right_shift(a, n): ...
def put(a, indices, values, mode=...): ...
def put(a: ArrayLike, indices: _ArrayLikeInt_co, values: ArrayLike, mode: _ModeKind = 'raise') -> None: ...
def putmask(a, mask, values): ...
def transpose(a, axes=...): ...
def reshape(a, new_shape, order=...): ...
Expand Down
4 changes: 4 additions & 0 deletions numpy/typing/tests/data/fail/ma.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -108,3 +108,7 @@ m < (lambda x: 'mango') # E: No overload variant
m.count(axis=0.) # E: No overload variant

np.ma.count(m, axis=0.) # E: No overload variant

m.put(4, 999, mode='flip') # E: No overload variant

np.ma.put(m, 4, 999, mode='flip') # E: No overload variant
8 changes: 8 additions & 0 deletions numpy/typing/tests/data/reveal/ma.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -247,3 +247,11 @@ assert_type(np.ma.count(MAR_b, axis=(0,1)), NDArray[np.int_])
assert_type(np.ma.count(MAR_o, keepdims=True), NDArray[np.int_])
assert_type(np.ma.count(MAR_o, axis=None, keepdims=True), NDArray[np.int_])
assert_type(np.ma.count(MAR_o, None, True), NDArray[np.int_])

assert_type(MAR_f4.put([0,4,8], [10,20,30]), None)
assert_type(MAR_f4.put(4, 999), None)
assert_type(MAR_f4.put(4, 999, mode='clip'), None)

assert_type(np.ma.put(MAR_f4, [0,4,8], [10,20,30]), None)
assert_type(np.ma.put(MAR_f4, 4, 999), None)
assert_type(np.ma.put(MAR_f4, 4, 999, mode='clip'), None)
Loading
0