Skip to content

🚚 port type masked array shape, dtype, __int__, and __float__ #472

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 1 commit into from
Apr 7, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
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
12 changes: 12 additions & 0 deletions src/numpy-stubs/@test/static/accept/ma.pyi
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
from typing_extensions import assert_type

import numpy as np

m: np.ma.MaskedArray[tuple[int], np.dtype[np.float64]]

assert_type(m.shape, tuple[int])

assert_type(m.dtype, np.dtype[np.float64])

assert_type(int(m), int)
assert_type(float(m), float)
6 changes: 6 additions & 0 deletions src/numpy-stubs/@test/static/reject/ma.pyi
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
import numpy as np

m: np.ma.MaskedArray[tuple[int], np.dtype[np.float64]]

m.shape = (3, 1) # type: ignore[assignment]
m.dtype = np.bool # type: ignore[assignment] # pyright: ignore[reportAttributeAccessIssue]
6 changes: 0 additions & 6 deletions src/numpy-stubs/ma/core.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -466,12 +466,6 @@ class MaskedArray(np.ndarray[_ShapeT_co, _DTypeT_co]):
@override
def __ipow__(self, other: Incomplete, /) -> Self: ... # type: ignore[override]

#
@override
def __int__(self) -> int: ...
@override
def __float__(self) -> float: ...

#
@override
def __reduce__(self) -> Incomplete: ...
Expand Down