Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commitd1ffd4f

Browse files
committed
TYP: np.argmin changes
1 parent00f2733 commitd1ffd4f

File tree

2 files changed

+14
-15
lines changed

2 files changed

+14
-15
lines changed

‎numpy/_core/fromnumeric.pyi

Lines changed: 9 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -111,6 +111,7 @@ _NumberOrObjectT = TypeVar("_NumberOrObjectT", bound=np.number | np.object_)
111111
_ArrayT=TypeVar("_ArrayT",bound=np.ndarray[Any,Any])
112112
_ShapeT=TypeVar("_ShapeT",bound=tuple[int, ...])
113113
_ShapeT_co=TypeVar("_ShapeT_co",bound=tuple[int, ...],covariant=True)
114+
_BoolOrIntArrayT=TypeVar("_BoolOrIntArrayT",bound=NDArray[np.integer|np.bool])
114115

115116
@type_check_only
116117
class_SupportsShape(Protocol[_ShapeT_co]):
@@ -418,18 +419,18 @@ def argmax(
418419
defargmax(
419420
a:ArrayLike,
420421
axis:SupportsIndex|None,
421-
out:_ArrayT,
422+
out:_BoolOrIntArrayT,
422423
*,
423424
keepdims:bool= ...,
424-
)->_ArrayT: ...
425+
)->_BoolOrIntArrayT: ...
425426
@overload
426427
defargmax(
427428
a:ArrayLike,
428429
axis:SupportsIndex|None= ...,
429430
*,
430-
out:_ArrayT,
431+
out:_BoolOrIntArrayT,
431432
keepdims:bool= ...,
432-
)->_ArrayT: ...
433+
)->_BoolOrIntArrayT: ...
433434

434435
@overload
435436
defargmin(
@@ -451,26 +452,19 @@ def argmin(
451452
defargmin(
452453
a:ArrayLike,
453454
axis:SupportsIndex|None,
454-
out:_ArrayT,
455+
out:_BoolOrIntArrayT,
455456
*,
456457
keepdims:bool= ...,
457-
)->_ArrayT: ...
458+
)->_BoolOrIntArrayT: ...
458459
@overload
459460
defargmin(
460461
a:ArrayLike,
461462
axis:SupportsIndex|None= ...,
462463
*,
463-
out:_ArrayT,
464+
out:_BoolOrIntArrayT,
464465
keepdims:bool= ...,
465-
)->_ArrayT: ...
466+
)->_BoolOrIntArrayT: ...
466467

467-
@overload
468-
defsearchsorted(
469-
a:ArrayLike,
470-
v:_ScalarLike_co,
471-
side:_SortSide= ...,
472-
sorter:_ArrayLikeInt_co|None= ...,# 1D int array
473-
)->intp: ...
474468
@overload
475469
defsearchsorted(
476470
a:ArrayLike,

‎numpy/typing/tests/data/reveal/fromnumeric.pyi

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,11 @@ assert_type(np.argmin(AR_b, axis=0), Any)
9797
assert_type(np.argmin(AR_f4,axis=0),Any)
9898
assert_type(np.argmin(AR_f4,out=AR_subclass),NDArraySubclass)
9999

100+
OUT_I=np.empty((),dtype=np.intp)
101+
OUT_F=np.empty((),dtype=np.float64)
102+
assert_type(np.argmin(AR_f4,out=OUT_I),npt.NDArray[np.intp])
103+
assert_type(np.argmax(AR_f4,out=OUT_I),npt.NDArray[np.intp])
104+
100105
assert_type(np.searchsorted(AR_b[0],0),np.intp)
101106
assert_type(np.searchsorted(AR_f4[0],0),np.intp)
102107
assert_type(np.searchsorted(AR_b[0], [0]),npt.NDArray[np.intp])

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp