From 587253b81973968b3f45c209358fad544848dc64 Mon Sep 17 00:00:00 2001 From: GUAN MING Date: Tue, 8 Apr 2025 01:15:02 +0800 Subject: [PATCH] =?UTF-8?q?=F0=9F=9A=9A=20port=20type=20masked=20array=20`?= =?UTF-8?q?shape`,=20`dtype`,`=5F=5Fint=5F=5F`,=20and=20`=5F=5Ffloat=5F=5F?= =?UTF-8?q?`?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-Authored-By: Marco Edward Gorelli <33491632+marcogorelli@users.noreply.github.com> Co-Authored-By: Joren Hammudoglu --- src/numpy-stubs/@test/static/accept/ma.pyi | 12 ++++++++++++ src/numpy-stubs/@test/static/reject/ma.pyi | 6 ++++++ src/numpy-stubs/ma/core.pyi | 6 ------ 3 files changed, 18 insertions(+), 6 deletions(-) create mode 100644 src/numpy-stubs/@test/static/accept/ma.pyi create mode 100644 src/numpy-stubs/@test/static/reject/ma.pyi diff --git a/src/numpy-stubs/@test/static/accept/ma.pyi b/src/numpy-stubs/@test/static/accept/ma.pyi new file mode 100644 index 00000000..edc8c10b --- /dev/null +++ b/src/numpy-stubs/@test/static/accept/ma.pyi @@ -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) diff --git a/src/numpy-stubs/@test/static/reject/ma.pyi b/src/numpy-stubs/@test/static/reject/ma.pyi new file mode 100644 index 00000000..aef6d21b --- /dev/null +++ b/src/numpy-stubs/@test/static/reject/ma.pyi @@ -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] diff --git a/src/numpy-stubs/ma/core.pyi b/src/numpy-stubs/ma/core.pyi index f1c3337c..870d0d88 100644 --- a/src/numpy-stubs/ma/core.pyi +++ b/src/numpy-stubs/ma/core.pyi @@ -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: ...