Skip to content

Commit dc6b3c8

Browse files
committed
TYP: Type MaskedArray.__deepcopy__ and MaskedArray.argsort
1 parent 8f68377 commit dc6b3c8

File tree

4 files changed

+20
-3
lines changed

4 files changed

+20
-3
lines changed

numpy/ma/core.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5628,7 +5628,7 @@ def argsort(self, axis=np._NoValue, kind=None, order=None, endwith=True,
56285628
is used.
56295629
kind : {'quicksort', 'mergesort', 'heapsort', 'stable'}, optional
56305630
The sorting algorithm used.
5631-
order : list, optional
5631+
order : str or list of str, optional
56325632
When `a` is an array with fields defined, this argument specifies
56335633
which fields to compare first, second, etc. Not all fields need be
56345634
specified.

numpy/ma/core.pyi

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1398,7 +1398,16 @@ class MaskedArray(ndarray[_ShapeT_co, _DTypeT_co]):
13981398
@overload
13991399
def round(self, /, decimals: SupportsIndex = 0, *, out: _ArrayT) -> _ArrayT: ...
14001400

1401-
def argsort(self, axis=..., kind=..., order=..., endwith=..., fill_value=..., *, stable=...): ...
1401+
def argsort(
1402+
self,
1403+
axis: SupportsIndex | _NoValueType = ...,
1404+
kind: _SortKind | None = None,
1405+
order: str | Sequence[str] | None = None,
1406+
endwith: bool = True,
1407+
fill_value: _ScalarLike_co | None = None,
1408+
*,
1409+
stable: bool = ...,
1410+
) -> _MaskedArray[Any]: ...
14021411

14031412
# Keep in-sync with np.ma.argmin
14041413
@overload # type: ignore[override]
@@ -1703,7 +1712,7 @@ class MaskedArray(ndarray[_ShapeT_co, _DTypeT_co]):
17031712

17041713
#
17051714
def __reduce__(self): ...
1706-
def __deepcopy__(self, memo=...): ...
1715+
def __deepcopy__(self, memo: dict[int, Any] | None = None) -> Self: ...
17071716

17081717
# Keep `dtype` at the bottom to avoid name conflicts with `np.dtype`
17091718
@property

numpy/typing/tests/data/fail/ma.pyi

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -141,3 +141,5 @@ MAR_c //= 2 # type: ignore[misc]
141141
MAR_td64 **= 2 # type: ignore[misc]
142142

143143
MAR_1d_f8.swapaxes(axis1=1, axis2=0) # type: ignore[call-arg]
144+
145+
MAR_1d_f8.argsort(axis=(1,0)) # type: ignore[arg-type]

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

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -405,6 +405,12 @@ assert_type(MAR_f8.cumprod(out=MAR_subclass), MaskedArraySubclass)
405405
assert_type(MAR_f8.cumsum(), MaskedArray[Any])
406406
assert_type(MAR_f8.cumsum(out=MAR_subclass), MaskedArraySubclass)
407407

408+
assert_type(MAR_f8.__deepcopy__(), MaskedArray[np.float64])
409+
410+
assert_type(MAR_f8.argsort(), MaskedArray[Any])
411+
assert_type(MAR_f8.argsort(axis=0, kind='heap', order=('x', 'y')), MaskedArray[Any])
412+
assert_type(MAR_f8.argsort(endwith=True, fill_value=1.5, stable=False), MaskedArray[Any])
413+
408414
def invalid_resize() -> None:
409415
assert_type(MAR_f8.resize((1,1)), NoReturn) # type: ignore[arg-type]
410416

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy