diff --git a/numpy/ma/core.pyi b/numpy/ma/core.pyi index 9c8c9db2c1ec..a0325ab3983e 100644 --- a/numpy/ma/core.pyi +++ b/numpy/ma/core.pyi @@ -1,19 +1,13 @@ -from collections.abc import Callable -from typing import Any, TypeVar - -from numpy import ( - amax, - amin, - bool_, - expand_dims, - clip, - indices, - squeeze, - angle, - ndarray, - dtype, - float64, -) +# pyright: reportIncompatibleMethodOverride=false +# ruff: noqa: ANN001, ANN002, ANN003, ANN201, ANN202 ANN204 + +from typing import Any, SupportsIndex, TypeVar + +from _typeshed import Incomplete +from typing_extensions import deprecated + +from numpy import _OrderKACF, amax, amin, bool_, dtype, expand_dims, float64, ndarray +from numpy._typing import ArrayLike, _DTypeLikeBool __all__ = [ "MAError", @@ -111,8 +105,8 @@ __all__ = [ "less", "less_equal", "log", - "log10", "log2", + "log10", "logical_and", "logical_not", "logical_or", @@ -256,6 +250,7 @@ cosh: _MaskedUnaryOperation tanh: _MaskedUnaryOperation abs: _MaskedUnaryOperation absolute: _MaskedUnaryOperation +angle: _MaskedUnaryOperation fabs: _MaskedUnaryOperation negative: _MaskedUnaryOperation floor: _MaskedUnaryOperation @@ -283,20 +278,21 @@ greater_equal: _MaskedBinaryOperation less: _MaskedBinaryOperation greater: _MaskedBinaryOperation logical_and: _MaskedBinaryOperation -alltrue: _MaskedBinaryOperation +def alltrue(target: ArrayLike, axis: SupportsIndex | None = 0, dtype: _DTypeLikeBool | None = None) -> Incomplete: ... logical_or: _MaskedBinaryOperation -sometrue: Callable[..., Any] +def sometrue(target: ArrayLike, axis: SupportsIndex | None = 0, dtype: _DTypeLikeBool | None = None) -> Incomplete: ... logical_xor: _MaskedBinaryOperation bitwise_and: _MaskedBinaryOperation bitwise_or: _MaskedBinaryOperation bitwise_xor: _MaskedBinaryOperation hypot: _MaskedBinaryOperation -divide: _MaskedBinaryOperation -true_divide: _MaskedBinaryOperation -floor_divide: _MaskedBinaryOperation -remainder: _MaskedBinaryOperation -fmod: _MaskedBinaryOperation -mod: _MaskedBinaryOperation + +divide: _DomainedBinaryOperation +true_divide: _DomainedBinaryOperation +floor_divide: _DomainedBinaryOperation +remainder: _DomainedBinaryOperation +fmod: _DomainedBinaryOperation +mod: _DomainedBinaryOperation def make_mask_descr(ndtype): ... def getmask(a): ... @@ -447,16 +443,17 @@ class MaskedArray(ndarray[_ShapeType_co, _DType_co]): def var(self, axis=..., dtype=..., out=..., ddof=..., keepdims=...): ... def std(self, axis=..., dtype=..., out=..., ddof=..., keepdims=...): ... def round(self, decimals=..., out=...): ... - def argsort(self, axis=..., kind=..., order=..., endwith=..., fill_value=..., stable=...): ... + def argsort(self, axis=..., kind=..., order=..., endwith=..., fill_value=..., *, stable=...): ... def argmin(self, axis=..., fill_value=..., out=..., *, keepdims=...): ... def argmax(self, axis=..., fill_value=..., out=..., *, keepdims=...): ... - def sort(self, axis=..., kind=..., order=..., endwith=..., fill_value=..., stable=...): ... + def sort(self, axis=..., kind=..., order=..., endwith=..., fill_value=..., *, stable=...): ... def min(self, axis=..., out=..., fill_value=..., keepdims=...): ... def max(self, axis=..., out=..., fill_value=..., keepdims=...): ... def ptp(self, axis=..., out=..., fill_value=..., keepdims=...): ... def partition(self, *args, **kwargs): ... def argpartition(self, *args, **kwargs): ... def take(self, indices, axis=..., out=..., mode=...): ... + copy: Any diagonal: Any flatten: Any @@ -465,19 +462,26 @@ class MaskedArray(ndarray[_ShapeType_co, _DType_co]): swapaxes: Any T: Any transpose: Any + @property # type: ignore[misc] def mT(self): ... - def tolist(self, fill_value=...): ... - def tobytes(self, fill_value=..., order=...): ... - def tofile(self, fid, sep=..., format=...): ... - def toflex(self): ... - torecords: Any + + # + def toflex(self) -> Incomplete: ... + def torecords(self) -> Incomplete: ... + def tolist(self, fill_value: Incomplete | None = None) -> Incomplete: ... + @deprecated("tostring() is deprecated. Use tobytes() instead.") + def tostring(self, /, fill_value: Incomplete | None = None, order: _OrderKACF = "C") -> bytes: ... # type: ignore[override] # pyright: ignore[reportIncompatibleMethodOverride] + def tobytes(self, /, fill_value: Incomplete | None = None, order: _OrderKACF = "C") -> bytes: ... # type: ignore[override] # pyright: ignore[reportIncompatibleMethodOverride] + def tofile(self, /, fid: Incomplete, sep: str = "", format: str = "%s") -> Incomplete: ... + + # def __reduce__(self): ... def __deepcopy__(self, memo=...): ... class mvoid(MaskedArray[_ShapeType_co, _DType_co]): def __new__( - self, + self, # pyright: ignore[reportSelfClsParameterName] data, mask=..., dtype=..., @@ -590,8 +594,8 @@ maximum: _extrema_operation def take(a, indices, axis=..., out=..., mode=...): ... def power(a, b, third=...): ... -def argsort(a, axis=..., kind=..., order=..., endwith=..., fill_value=..., stable=...): ... -def sort(a, axis=..., kind=..., order=..., endwith=..., fill_value=..., stable=...): ... +def argsort(a, axis=..., kind=..., order=..., endwith=..., fill_value=..., *, stable=...): ... +def sort(a, axis=..., kind=..., order=..., endwith=..., fill_value=..., *, stable=...): ... def compressed(x): ... def concatenate(arrays, axis=...): ... def diag(v, k=...): ... @@ -626,19 +630,21 @@ def asanyarray(a, dtype=...): ... def fromflex(fxarray): ... class _convert2ma: - __doc__: Any - def __init__(self, funcname, params=...): ... - def getdoc(self): ... - def __call__(self, *args, **params): ... + def __init__(self, /, funcname: str, np_ret: str, np_ma_ret: str, params: dict[str, Any] | None = None) -> None: ... + def __call__(self, /, *args: object, **params: object) -> Any: ... # noqa: ANN401 + def getdoc(self, /, np_ret: str, np_ma_ret: str) -> str | None: ... arange: _convert2ma +clip: _convert2ma empty: _convert2ma empty_like: _convert2ma frombuffer: _convert2ma fromfunction: _convert2ma identity: _convert2ma +indices: _convert2ma ones: _convert2ma ones_like: _convert2ma +squeeze: _convert2ma zeros: _convert2ma zeros_like: _convert2ma diff --git a/numpy/ma/extras.pyi b/numpy/ma/extras.pyi index 580309cc679d..ba76f3517526 100644 --- a/numpy/ma/extras.pyi +++ b/numpy/ma/extras.pyi @@ -1,9 +1,10 @@ -from typing import Any +from _typeshed import Incomplete +import numpy as np from numpy.lib._function_base_impl import average from numpy.lib._index_tricks_impl import AxisConcatenator -from .core import dot, mask_rowcols +from .core import MaskedArray, dot __all__ = [ "apply_along_axis", @@ -19,8 +20,8 @@ __all__ = [ "compress_nd", "compress_rowcols", "compress_rows", - "count_masked", "corrcoef", + "count_masked", "cov", "diagflat", "dot", @@ -30,9 +31,9 @@ __all__ = [ "flatnotmasked_edges", "hsplit", "hstack", - "isin", "in1d", "intersect1d", + "isin", "mask_cols", "mask_rowcols", "mask_rows", @@ -48,8 +49,8 @@ __all__ = [ "setdiff1d", "setxor1d", "stack", - "unique", "union1d", + "unique", "vander", "vstack", ] @@ -59,9 +60,9 @@ def masked_all(shape, dtype = ...): ... def masked_all_like(arr): ... class _fromnxfunction: - __name__: Any - __doc__: Any - def __init__(self, funcname): ... + __name__: Incomplete + __doc__: Incomplete + def __init__(self, funcname) -> None: ... def getdoc(self): ... def __call__(self, *args, **params): ... @@ -109,13 +110,13 @@ def cov(x, y=..., rowvar=..., bias=..., allow_masked=..., ddof=...): ... def corrcoef(x, y=..., rowvar=..., bias = ..., allow_masked=..., ddof = ...): ... class MAxisConcatenator(AxisConcatenator): - concatenate: Any + @staticmethod + def concatenate(arrays: Incomplete, axis: int = 0) -> Incomplete: ... # type: ignore[override] # pyright: ignore[reportIncompatibleMethodOverride] @classmethod - def makemat(cls, arr): ... - def __getitem__(self, key): ... + def makemat(cls, arr: Incomplete) -> Incomplete: ... # type: ignore[override] # pyright: ignore[reportIncompatibleVariableOverride] class mr_class(MAxisConcatenator): - def __init__(self): ... + def __init__(self) -> None: ... mr_: mr_class @@ -128,3 +129,6 @@ def clump_unmasked(a): ... def clump_masked(a): ... def vander(x, n=...): ... def polyfit(x, y, deg, rcond=..., full=..., w=..., cov=...): ... + +# +def mask_rowcols(a: Incomplete, axis: Incomplete | None = None) -> MaskedArray[Incomplete, np.dtype[Incomplete]]: ...