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

Commit6ebc810

Browse files
committed
TYP: add type-tests for ndarraycharacter ops
1 parentee56537 commit6ebc810

File tree

1 file changed

+45
-0
lines changed

1 file changed

+45
-0
lines changed

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

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,9 @@ AR_c: npt.NDArray[np.complex128]
4848
AR_m:npt.NDArray[np.timedelta64]
4949
AR_M:npt.NDArray[np.datetime64]
5050
AR_O:npt.NDArray[np.object_]
51+
AR_S:npt.NDArray[np.bytes_]
52+
AR_U:npt.NDArray[np.str_]
53+
AR_T:np.ndarray[tuple[Any, ...],np.dtypes.StringDType]
5154
AR_floating:npt.NDArray[np.floating]
5255
AR_number:npt.NDArray[np.number]
5356
AR_Any:npt.NDArray[Any]
@@ -673,3 +676,45 @@ assert_type(f / AR_floating, npt.NDArray[np.floating])
673676
assert_type(f//AR_floating,npt.NDArray[np.floating])
674677
assert_type(f%AR_floating,npt.NDArray[np.floating])
675678
assert_type(divmod(f,AR_floating),tuple[npt.NDArray[np.floating],npt.NDArray[np.floating]])
679+
680+
# character-like
681+
682+
assert_type(AR_S+b"",npt.NDArray[np.bytes_])
683+
assert_type(AR_S+ [b""],npt.NDArray[np.bytes_])
684+
assert_type([b""]+AR_S,npt.NDArray[np.bytes_])
685+
assert_type(AR_S+AR_S,npt.NDArray[np.bytes_])
686+
687+
assert_type(AR_U+"",npt.NDArray[np.str_])
688+
assert_type(AR_U+ [""],npt.NDArray[np.str_])
689+
assert_type(""+AR_U,npt.NDArray[np.str_])
690+
assert_type([""]+AR_U,npt.NDArray[np.str_])
691+
assert_type(AR_U+AR_U,npt.NDArray[np.str_])
692+
693+
assert_type(AR_T+"",np.ndarray[tuple[Any, ...],np.dtypes.StringDType])
694+
assert_type(AR_T+ [""],np.ndarray[tuple[Any, ...],np.dtypes.StringDType])
695+
assert_type(""+AR_T,np.ndarray[tuple[Any, ...],np.dtypes.StringDType])
696+
assert_type([""]+AR_T,np.ndarray[tuple[Any, ...],np.dtypes.StringDType])
697+
assert_type(AR_T+AR_T,np.ndarray[tuple[Any, ...],np.dtypes.StringDType])
698+
assert_type(AR_T+AR_U,np.ndarray[tuple[Any, ...],np.dtypes.StringDType])
699+
assert_type(AR_U+AR_T,np.ndarray[tuple[Any, ...],np.dtypes.StringDType])
700+
701+
assert_type(AR_S*i,np.ndarray[tuple[Any, ...],np.dtype[np.bytes_]])
702+
assert_type(AR_S*AR_LIKE_i,np.ndarray[tuple[Any, ...],np.dtype[np.bytes_]])
703+
assert_type(AR_S*AR_i,np.ndarray[tuple[Any, ...],np.dtype[np.bytes_]])
704+
assert_type(i*AR_S,np.ndarray[tuple[Any, ...],np.dtype[np.bytes_]])
705+
# mypy incorrectly infers `AR_LIKE_i * AR_S` as `list[int]`
706+
assert_type(AR_i*AR_S,np.ndarray[tuple[Any, ...],np.dtype[np.bytes_]])
707+
708+
assert_type(AR_U*i,np.ndarray[tuple[Any, ...],np.dtype[np.str_]])
709+
assert_type(AR_U*AR_LIKE_i,np.ndarray[tuple[Any, ...],np.dtype[np.str_]])
710+
assert_type(AR_U*AR_i,np.ndarray[tuple[Any, ...],np.dtype[np.str_]])
711+
assert_type(i*AR_U,np.ndarray[tuple[Any, ...],np.dtype[np.str_]])
712+
# mypy incorrectly infers `AR_LIKE_i * AR_U` as `list[int]`
713+
assert_type(AR_i*AR_U,np.ndarray[tuple[Any, ...],np.dtype[np.str_]])
714+
715+
assert_type(AR_T*i,np.ndarray[tuple[Any, ...],np.dtypes.StringDType])
716+
assert_type(AR_T*AR_LIKE_i,np.ndarray[tuple[Any, ...],np.dtypes.StringDType])
717+
assert_type(AR_T*AR_i,np.ndarray[tuple[Any, ...],np.dtypes.StringDType])
718+
assert_type(i*AR_T,np.ndarray[tuple[Any, ...],np.dtypes.StringDType])
719+
# mypy incorrectly infers `AR_LIKE_i * AR_T` as `list[int]`
720+
assert_type(AR_i*AR_T,np.ndarray[tuple[Any, ...],np.dtypes.StringDType])

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp