Skip to content

Commit 8c665e4

Browse files
🚚 port numpy.ma.min
Co-Authored-By: Marco Edward Gorelli <[email protected]>
1 parent b37e58b commit 8c665e4

File tree

2 files changed

+44
-7
lines changed

2 files changed

+44
-7
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
import numpy as np
2+
3+
m: np.ma.MaskedArray[tuple[int], np.dtype[np.float64]]
4+
5+
np.amin(m, axis=1.0) # type: ignore[call-overload] # pyright: ignore[reportArgumentType, reportCallIssue]
6+
np.amin(m, keepdims=1.0) # type: ignore[call-overload] # pyright: ignore[reportArgumentType, reportCallIssue]
7+
np.amin(m, out=1.0) # type: ignore[call-overload] # pyright: ignore[reportArgumentType, reportCallIssue]
8+
np.amin(m, fill_value=lambda x: 27) # type: ignore[call-overload] # pyright: ignore[reportCallIssue, reportUnknownLambdaType]

‎src/numpy-stubs/ma/core.pyi

+36-7
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,8 @@ from typing_extensions import Never, Self, TypeVar, deprecated, overload, overri
55
import numpy as np
66
from _numtype import Array, ToGeneric_0d, ToGeneric_1nd, ToGeneric_nd
77
from numpy import _OrderACF, _OrderKACF, amax, amin, bool_, expand_dims # noqa: ICN003
8-
from numpy._typing import _BoolCodes
8+
from numpy._globals import _NoValueType
9+
from numpy._typing import ArrayLike, _ArrayLike, _BoolCodes, _ScalarLike_co, _ShapeLike
910

1011
__all__ = [
1112
"MAError",
@@ -195,6 +196,8 @@ _DTypeT = TypeVar("_DTypeT", bound=np.dtype)
195196
_DTypeT_co = TypeVar("_DTypeT_co", bound=np.dtype, default=np.dtype, covariant=True)
196197

197198
_DTypeLikeBool: TypeAlias = type[bool | np.bool] | np.dtype[np.bool] | _BoolCodes
199+
_ArrayType = TypeVar("_ArrayType", bound=np.ndarray[Any, Any])
200+
_SCT = TypeVar("_SCT", bound=np.generic)
198201

199202
###
200203

@@ -824,13 +827,39 @@ def array(
824827
) -> Incomplete: ...
825828

826829
#
830+
@overload
827831
def min(
828-
obj: Incomplete,
829-
axis: Incomplete = ...,
830-
out: Incomplete = ...,
831-
fill_value: Incomplete = ...,
832-
keepdims: Incomplete = ...,
833-
) -> Incomplete: ...
832+
obj: _ArrayLike[_SCT],
833+
axis: None = None,
834+
out: None = None,
835+
fill_value: _ScalarLike_co | None = None,
836+
keepdims: L[False] | _NoValueType = ...,
837+
) -> _SCT: ...
838+
@overload
839+
def min(
840+
obj: ArrayLike,
841+
axis: _ShapeLike | None = None,
842+
out: None = None,
843+
fill_value: _ScalarLike_co | None = None,
844+
keepdims: bool | _NoValueType = ...,
845+
) -> Any: ...
846+
@overload
847+
def min(
848+
obj: ArrayLike,
849+
axis: None,
850+
out: _ArrayType,
851+
fill_value: _ScalarLike_co | None = None,
852+
keepdims: bool | _NoValueType = ...,
853+
) -> _ArrayType: ...
854+
@overload
855+
def min(
856+
obj: ArrayLike,
857+
axis: _ShapeLike | None = None,
858+
*,
859+
out: _ArrayType,
860+
fill_value: _ScalarLike_co | None = None,
861+
keepdims: bool | _NoValueType = ...,
862+
) -> _ArrayType: ...
834863
def max(
835864
obj: Incomplete,
836865
axis: Incomplete = ...,

0 commit comments

Comments
 (0)