diff --git a/numpy/_typing/_callable.pyi b/numpy/_typing/_callable.pyi index 56e24fb73911..75af1ae8efba 100644 --- a/numpy/_typing/_callable.pyi +++ b/numpy/_typing/_callable.pyi @@ -151,19 +151,15 @@ class _IntTrueDiv(Protocol[_NBit1]): class _UnsignedIntOp(Protocol[_NBit1]): # NOTE: `uint64 + signedinteger -> float64` @overload - def __call__(self, other: bool, /) -> unsignedinteger[_NBit1]: ... + def __call__(self, other: int, /) -> unsignedinteger[_NBit1]: ... @overload - def __call__(self, other: int | signedinteger[Any], /) -> Any: ... + def __call__(self, other: float, /) -> float64: ... @overload - def __call__(self, other: float, /) -> floating[_NBit1] | float64: ... + def __call__(self, other: complex, /) -> complex128: ... @overload - def __call__( - self, other: complex, / - ) -> complexfloating[_NBit1, _NBit1] | complex128: ... + def __call__(self, other: unsignedinteger[_NBit2], /) -> unsignedinteger[_NBit1] | unsignedinteger[_NBit2]: ... @overload - def __call__( - self, other: unsignedinteger[_NBit2], / - ) -> unsignedinteger[_NBit1] | unsignedinteger[_NBit2]: ... + def __call__(self, other: signedinteger, /) -> Any: ... @type_check_only class _UnsignedIntBitOp(Protocol[_NBit1]): @@ -207,19 +203,13 @@ class _UnsignedIntDivMod(Protocol[_NBit1]): @type_check_only class _SignedIntOp(Protocol[_NBit1]): @overload - def __call__(self, other: bool, /) -> signedinteger[_NBit1]: ... - @overload - def __call__(self, other: int, /) -> signedinteger[_NBit1] | int_: ... + def __call__(self, other: int, /) -> signedinteger[_NBit1]: ... @overload - def __call__(self, other: float, /) -> floating[_NBit1] | float64: ... + def __call__(self, other: float, /) -> float64: ... @overload - def __call__( - self, other: complex, / - ) -> complexfloating[_NBit1, _NBit1] | complex128: ... + def __call__(self, other: complex, /) -> complex128: ... @overload - def __call__( - self, other: signedinteger[_NBit2], / - ) -> signedinteger[_NBit1] | signedinteger[_NBit2]: ... + def __call__(self, other: signedinteger[_NBit2], /) -> signedinteger[_NBit1] | signedinteger[_NBit2]: ... @type_check_only class _SignedIntBitOp(Protocol[_NBit1]): @@ -261,9 +251,7 @@ class _SignedIntDivMod(Protocol[_NBit1]): @type_check_only class _FloatOp(Protocol[_NBit1]): @overload - def __call__(self, other: bool, /) -> floating[_NBit1]: ... - @overload - def __call__(self, other: int, /) -> floating[_NBit1] | floating[_NBitInt]: ... + def __call__(self, other: int, /) -> floating[_NBit1]: ... @overload def __call__(self, other: float, /) -> floating[_NBit1] | float64: ... @overload diff --git a/numpy/typing/tests/data/reveal/arithmetic.pyi b/numpy/typing/tests/data/reveal/arithmetic.pyi index dbb7d16bcd2e..d5025c6c1763 100644 --- a/numpy/typing/tests/data/reveal/arithmetic.pyi +++ b/numpy/typing/tests/data/reveal/arithmetic.pyi @@ -412,10 +412,10 @@ assert_type(c16 + AR_f, npt.NDArray[np.complexfloating[Any, Any]]) assert_type(f16 + c16, np.complex128 | np.complexfloating[_128Bit, _128Bit]) assert_type(c16 + c16, np.complex128) assert_type(f8 + c16, np.complex128) -assert_type(i8 + c16, np.complexfloating[_64Bit, _64Bit]) +assert_type(i8 + c16, np.complex128) assert_type(c8 + c16, np.complex128 | np.complex64) assert_type(f4 + c16, np.complex128 | np.complex64) -assert_type(i4 + c16, np.complex128 | np.complex64) +assert_type(i4 + c16, np.complex128) assert_type(b_ + c16, np.complex128) assert_type(b + c16, np.complex128) assert_type(c + c16, np.complex128) @@ -463,9 +463,9 @@ assert_type(f8 + AR_f, npt.NDArray[np.floating[Any]]) assert_type(f16 + f8, np.floating[_128Bit] | np.float64) assert_type(f8 + f8, np.float64) -assert_type(i8 + f8, np.floating[_64Bit]) +assert_type(i8 + f8, np.float64) assert_type(f4 + f8, np.floating[_32Bit] | np.float64) -assert_type(i4 + f8, np.floating[_32Bit] | np.float64) +assert_type(i4 + f8,np.float64) assert_type(b_ + f8, np.float64) assert_type(b + f8, np.float64) assert_type(c + f8, np.complex128 | np.float64) @@ -502,8 +502,8 @@ assert_type(i8 + i4, np.signedinteger[_32Bit] | np.signedinteger[_64Bit]) assert_type(i8 + u4, Any) assert_type(i8 + b_, np.int64) assert_type(i8 + b, np.int64) -assert_type(i8 + c, np.complexfloating[_64Bit, _64Bit]) -assert_type(i8 + f, np.floating[_64Bit]) +assert_type(i8 + c, np.complex128) +assert_type(i8 + f, np.float64) assert_type(i8 + AR_f, npt.NDArray[np.floating[Any]]) assert_type(u8 + u8, np.uint64) @@ -511,8 +511,8 @@ assert_type(u8 + i4, Any) assert_type(u8 + u4, np.unsignedinteger[_32Bit] | np.unsignedinteger[_64Bit]) assert_type(u8 + b_, np.uint64) assert_type(u8 + b, np.uint64) -assert_type(u8 + c, np.complexfloating[_64Bit, _64Bit]) -assert_type(u8 + f, np.floating[_64Bit]) +assert_type(u8 + c, np.complex128) +assert_type(u8 + f, np.float64) assert_type(u8 + AR_f, npt.NDArray[np.floating[Any]]) assert_type(i8 + i8, np.int64) @@ -521,8 +521,8 @@ assert_type(i4 + i8, np.signedinteger[_32Bit] | np.signedinteger[_64Bit]) assert_type(u4 + i8, Any) assert_type(b_ + i8, np.int64) assert_type(b + i8, np.int64) -assert_type(c + i8, np.complexfloating[_64Bit, _64Bit]) -assert_type(f + i8, np.floating[_64Bit]) +assert_type(c + i8, np.complex128) +assert_type(f + i8, np.float64) assert_type(AR_f + i8, npt.NDArray[np.floating[Any]]) assert_type(u8 + u8, np.uint64) @@ -530,8 +530,8 @@ assert_type(i4 + u8, Any) assert_type(u4 + u8, np.unsignedinteger[_32Bit] | np.unsignedinteger[_64Bit]) assert_type(b_ + u8, np.uint64) assert_type(b + u8, np.uint64) -assert_type(c + u8, np.complexfloating[_64Bit, _64Bit]) -assert_type(f + u8, np.floating[_64Bit]) +assert_type(c + u8, np.complex128) +assert_type(f + u8, np.float64) assert_type(AR_f + u8, npt.NDArray[np.floating[Any]]) assert_type(i4 + i8, np.signedinteger[_32Bit] | np.signedinteger[_64Bit])