Skip to content

Commit 1bcb9f3

Browse files
committed
TYP: Concrete float64 scalar type with builtins.float as a base class
1 parent c7f7e7f commit 1bcb9f3

File tree

8 files changed

+178
-68
lines changed

8 files changed

+178
-68
lines changed

numpy/__init__.pyi

Lines changed: 118 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -2854,6 +2854,8 @@ class ndarray(_ArrayOrScalarCommon, Generic[_ShapeType_co, _DType_co]):
28542854
@overload
28552855
def __iadd__(self: NDArray[signedinteger[_NBit1]], other: _ArrayLikeInt_co, /) -> NDArray[signedinteger[_NBit1]]: ...
28562856
@overload
2857+
def __iadd__(self: NDArray[float64], other: _ArrayLikeFloat_co, /) -> NDArray[float64]: ...
2858+
@overload
28572859
def __iadd__(self: NDArray[floating[_NBit1]], other: _ArrayLikeFloat_co, /) -> NDArray[floating[_NBit1]]: ...
28582860
@overload
28592861
def __iadd__(self: NDArray[complexfloating[_NBit1, _NBit1]], other: _ArrayLikeComplex_co, /) -> NDArray[complexfloating[_NBit1, _NBit1]]: ...
@@ -2871,6 +2873,8 @@ class ndarray(_ArrayOrScalarCommon, Generic[_ShapeType_co, _DType_co]):
28712873
@overload
28722874
def __isub__(self: NDArray[signedinteger[_NBit1]], other: _ArrayLikeInt_co, /) -> NDArray[signedinteger[_NBit1]]: ...
28732875
@overload
2876+
def __isub__(self: NDArray[float64], other: _ArrayLikeFloat_co, /) -> NDArray[float64]: ...
2877+
@overload
28742878
def __isub__(self: NDArray[floating[_NBit1]], other: _ArrayLikeFloat_co, /) -> NDArray[floating[_NBit1]]: ...
28752879
@overload
28762880
def __isub__(self: NDArray[complexfloating[_NBit1, _NBit1]], other: _ArrayLikeComplex_co, /) -> NDArray[complexfloating[_NBit1, _NBit1]]: ...
@@ -2890,6 +2894,8 @@ class ndarray(_ArrayOrScalarCommon, Generic[_ShapeType_co, _DType_co]):
28902894
@overload
28912895
def __imul__(self: NDArray[signedinteger[_NBit1]], other: _ArrayLikeInt_co, /) -> NDArray[signedinteger[_NBit1]]: ...
28922896
@overload
2897+
def __imul__(self: NDArray[float64], other: _ArrayLikeFloat_co, /) -> NDArray[float64]: ...
2898+
@overload
28932899
def __imul__(self: NDArray[floating[_NBit1]], other: _ArrayLikeFloat_co, /) -> NDArray[floating[_NBit1]]: ...
28942900
@overload
28952901
def __imul__(self: NDArray[complexfloating[_NBit1, _NBit1]], other: _ArrayLikeComplex_co, /) -> NDArray[complexfloating[_NBit1, _NBit1]]: ...
@@ -2901,6 +2907,8 @@ class ndarray(_ArrayOrScalarCommon, Generic[_ShapeType_co, _DType_co]):
29012907
@overload
29022908
def __itruediv__(self: NDArray[_UnknownType], other: _ArrayLikeUnknown, /) -> NDArray[Any]: ...
29032909
@overload
2910+
def __itruediv__(self: NDArray[float64], other: _ArrayLikeFloat_co, /) -> NDArray[float64]: ...
2911+
@overload
29042912
def __itruediv__(self: NDArray[floating[_NBit1]], other: _ArrayLikeFloat_co, /) -> NDArray[floating[_NBit1]]: ...
29052913
@overload
29062914
def __itruediv__(self: NDArray[complexfloating[_NBit1, _NBit1]], other: _ArrayLikeComplex_co, /) -> NDArray[complexfloating[_NBit1, _NBit1]]: ...
@@ -2918,6 +2926,8 @@ class ndarray(_ArrayOrScalarCommon, Generic[_ShapeType_co, _DType_co]):
29182926
@overload
29192927
def __ifloordiv__(self: NDArray[signedinteger[_NBit1]], other: _ArrayLikeInt_co, /) -> NDArray[signedinteger[_NBit1]]: ...
29202928
@overload
2929+
def __ifloordiv__(self: NDArray[float64], other: _ArrayLikeFloat_co, /) -> NDArray[float64]: ...
2930+
@overload
29212931
def __ifloordiv__(self: NDArray[floating[_NBit1]], other: _ArrayLikeFloat_co, /) -> NDArray[floating[_NBit1]]: ...
29222932
@overload
29232933
def __ifloordiv__(self: NDArray[complexfloating[_NBit1, _NBit1]], other: _ArrayLikeComplex_co, /) -> NDArray[complexfloating[_NBit1, _NBit1]]: ...
@@ -2935,6 +2945,8 @@ class ndarray(_ArrayOrScalarCommon, Generic[_ShapeType_co, _DType_co]):
29352945
@overload
29362946
def __ipow__(self: NDArray[signedinteger[_NBit1]], other: _ArrayLikeInt_co, /) -> NDArray[signedinteger[_NBit1]]: ...
29372947
@overload
2948+
def __ipow__(self: NDArray[float64], other: _ArrayLikeFloat_co, /) -> NDArray[float64]: ...
2949+
@overload
29382950
def __ipow__(self: NDArray[floating[_NBit1]], other: _ArrayLikeFloat_co, /) -> NDArray[floating[_NBit1]]: ...
29392951
@overload
29402952
def __ipow__(self: NDArray[complexfloating[_NBit1, _NBit1]], other: _ArrayLikeComplex_co, /) -> NDArray[complexfloating[_NBit1, _NBit1]]: ...
@@ -2948,6 +2960,8 @@ class ndarray(_ArrayOrScalarCommon, Generic[_ShapeType_co, _DType_co]):
29482960
@overload
29492961
def __imod__(self: NDArray[signedinteger[_NBit1]], other: _ArrayLikeInt_co, /) -> NDArray[signedinteger[_NBit1]]: ...
29502962
@overload
2963+
def __imod__(self: NDArray[float64], other: _ArrayLikeFloat_co, /) -> NDArray[float64]: ...
2964+
@overload
29512965
def __imod__(self: NDArray[floating[_NBit1]], other: _ArrayLikeFloat_co, /) -> NDArray[floating[_NBit1]]: ...
29522966
@overload
29532967
def __imod__(self: NDArray[timedelta64], other: _SupportsArray[_dtype[timedelta64]] | _NestedSequence[_SupportsArray[_dtype[timedelta64]]], /) -> NDArray[timedelta64]: ...
@@ -3014,6 +3028,8 @@ class ndarray(_ArrayOrScalarCommon, Generic[_ShapeType_co, _DType_co]):
30143028
@overload
30153029
def __imatmul__(self: NDArray[signedinteger[_NBit1]], other: _ArrayLikeInt_co, /) -> NDArray[signedinteger[_NBit1]]: ...
30163030
@overload
3031+
def __imatmul__(self: NDArray[float64], other: _ArrayLikeFloat_co, /) -> NDArray[float64]: ...
3032+
@overload
30173033
def __imatmul__(self: NDArray[floating[_NBit1]], other: _ArrayLikeFloat_co, /) -> NDArray[floating[_NBit1]]: ...
30183034
@overload
30193035
def __imatmul__(self: NDArray[complexfloating[_NBit1, _NBit1]], other: _ArrayLikeComplex_co, /) -> NDArray[complexfloating[_NBit1, _NBit1]]: ...
@@ -3525,21 +3541,10 @@ _IntType = TypeVar("_IntType", bound=integer[Any])
35253541

35263542
class floating(inexact[_NBit1]):
35273543
def __init__(self, value: _FloatValue = ..., /) -> None: ...
3528-
def item(
3529-
self, args: L[0] | tuple[()] | tuple[L[0]] = ...,
3530-
/,
3531-
) -> float: ...
3544+
def item(self, args: L[0] | tuple[()] | tuple[L[0]] = ..., /) -> float: ...
35323545
def tolist(self) -> float: ...
35333546
def is_integer(self) -> builtins.bool: ...
3534-
def hex(self: float64) -> str: ...
3535-
@classmethod
3536-
def fromhex(cls: type[float64], string: str, /) -> float64: ...
35373547
def as_integer_ratio(self) -> tuple[int, int]: ...
3538-
def __ceil__(self: float64) -> int: ...
3539-
def __floor__(self: float64) -> int: ...
3540-
def __trunc__(self: float64) -> int: ...
3541-
def __getnewargs__(self: float64) -> tuple[float]: ...
3542-
def __getformat__(self: float64, typestr: L["double", "float"], /) -> str: ...
35433548
@overload
35443549
def __round__(self, ndigits: None = ..., /) -> int: ...
35453550
@overload
@@ -3563,7 +3568,107 @@ class floating(inexact[_NBit1]):
35633568

35643569
float16: TypeAlias = floating[_16Bit]
35653570
float32: TypeAlias = floating[_32Bit]
3566-
float64: TypeAlias = floating[_64Bit]
3571+
3572+
# NOTE: `_64Bit` is equivalent to `_64Bit | _32Bit | _16Bit | _8Bit`
3573+
_Float64_co: TypeAlias = float | floating[_64Bit] | integer[_64Bit] | np.bool
3574+
3575+
# either a C `double`, `float`, or `longdouble`
3576+
class float64(floating[_64Bit], float): # type: ignore[misc]
3577+
def __getformat__(self, typestr: L["double", "float"], /) -> str: ...
3578+
def __getnewargs__(self, /) -> tuple[float]: ...
3579+
3580+
# overrides for `floating` and `builtins.float` compatibility
3581+
@property
3582+
def real(self) -> Self: ...
3583+
@property
3584+
def imag(self) -> Self: ...
3585+
def conjugate(self) -> Self: ...
3586+
3587+
# float64-specific operator overrides
3588+
@overload
3589+
def __add__(self, other: _Float64_co, /) -> float64: ...
3590+
@overload
3591+
def __add__(self, other: complexfloating[_NBit1, _NBit2], /) -> complexfloating[_NBit1 | _64Bit, _NBit2 | _64Bit]: ...
3592+
@overload
3593+
def __add__(self, other: complex, /) -> float64 | complex128: ...
3594+
@overload
3595+
def __radd__(self, other: _Float64_co, /) -> float64: ...
3596+
@overload
3597+
def __radd__(self, other: complexfloating[_NBit1, _NBit2], /) -> complexfloating[_NBit1 | _64Bit, _NBit2 | _64Bit]: ...
3598+
@overload
3599+
def __radd__(self, other: complex, /) -> float64 | complex128: ...
3600+
3601+
@overload
3602+
def __sub__(self, other: _Float64_co, /) -> float64: ...
3603+
@overload
3604+
def __sub__(self, other: complexfloating[_NBit1, _NBit2], /) -> complexfloating[_NBit1 | _64Bit, _NBit2 | _64Bit]: ...
3605+
@overload
3606+
def __sub__(self, other: complex, /) -> float64 | complex128: ...
3607+
@overload
3608+
def __rsub__(self, other: _Float64_co, /) -> float64: ...
3609+
@overload
3610+
def __rsub__(self, other: complexfloating[_NBit1, _NBit2], /) -> complexfloating[_NBit1 | _64Bit, _NBit2 | _64Bit]: ...
3611+
@overload
3612+
def __rsub__(self, other: complex, /) -> float64 | complex128: ...
3613+
3614+
@overload
3615+
def __mul__(self, other: _Float64_co, /) -> float64: ...
3616+
@overload
3617+
def __mul__(self, other: complexfloating[_NBit1, _NBit2], /) -> complexfloating[_NBit1 | _64Bit, _NBit2 | _64Bit]: ...
3618+
@overload
3619+
def __mul__(self, other: complex, /) -> float64 | complex128: ...
3620+
@overload
3621+
def __rmul__(self, other: _Float64_co, /) -> float64: ...
3622+
@overload
3623+
def __rmul__(self, other: complexfloating[_NBit1, _NBit2], /) -> complexfloating[_NBit1 | _64Bit, _NBit2 | _64Bit]: ...
3624+
@overload
3625+
def __rmul__(self, other: complex, /) -> float64 | complex128: ...
3626+
3627+
@overload
3628+
def __truediv__(self, other: _Float64_co, /) -> float64: ...
3629+
@overload
3630+
def __truediv__(self, other: complexfloating[_NBit1, _NBit2], /) -> complexfloating[_NBit1 | _64Bit, _NBit2 | _64Bit]: ...
3631+
@overload
3632+
def __truediv__(self, other: complex, /) -> float64 | complex128: ...
3633+
@overload
3634+
def __rtruediv__(self, other: _Float64_co, /) -> float64: ...
3635+
@overload
3636+
def __rtruediv__(self, other: complexfloating[_NBit1, _NBit2], /) -> complexfloating[_NBit1 | _64Bit, _NBit2 | _64Bit]: ...
3637+
@overload
3638+
def __rtruediv__(self, other: complex, /) -> float64 | complex128: ...
3639+
3640+
@overload
3641+
def __floordiv__(self, other: _Float64_co, /) -> float64: ...
3642+
@overload
3643+
def __floordiv__(self, other: complexfloating[_NBit1, _NBit2], /) -> complexfloating[_NBit1 | _64Bit, _NBit2 | _64Bit]: ...
3644+
@overload
3645+
def __floordiv__(self, other: complex, /) -> float64 | complex128: ...
3646+
@overload
3647+
def __rfloordiv__(self, other: _Float64_co, /) -> float64: ...
3648+
@overload
3649+
def __rfloordiv__(self, other: complexfloating[_NBit1, _NBit2], /) -> complexfloating[_NBit1 | _64Bit, _NBit2 | _64Bit]: ...
3650+
@overload
3651+
def __rfloordiv__(self, other: complex, /) -> float64 | complex128: ...
3652+
3653+
@overload
3654+
def __pow__(self, other: _Float64_co, /) -> float64: ...
3655+
@overload
3656+
def __pow__(self, other: complexfloating[_NBit1, _NBit2], /) -> complexfloating[_NBit1 | _64Bit, _NBit2 | _64Bit]: ...
3657+
@overload
3658+
def __pow__(self, other: complex, /) -> float64 | complex128: ...
3659+
@overload
3660+
def __rpow__(self, other: _Float64_co, /) -> float64: ...
3661+
@overload
3662+
def __rpow__(self, other: complexfloating[_NBit1, _NBit2], /) -> complexfloating[_NBit1 | _64Bit, _NBit2 | _64Bit]: ...
3663+
@overload
3664+
def __rpow__(self, other: complex, /) -> float64 | complex128: ...
3665+
3666+
def __mod__(self, other: _Float64_co, /) -> float64: ... # type: ignore[override]
3667+
def __rmod__(self, other: _Float64_co, /) -> float64: ... # type: ignore[override]
3668+
3669+
def __divmod__(self, other: _Float64_co, /) -> _2Tuple[float64]: ... # type: ignore[override]
3670+
def __rdivmod__(self, other: _Float64_co, /) -> _2Tuple[float64]: ... # type: ignore[override]
3671+
35673672

35683673
half: TypeAlias = floating[_NBitHalf]
35693674
single: TypeAlias = floating[_NBitSingle]

numpy/typing/tests/data/fail/arithmetic.pyi

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ td = np.timedelta64(0, "D")
1010
AR_b: npt.NDArray[np.bool]
1111
AR_u: npt.NDArray[np.uint32]
1212
AR_i: npt.NDArray[np.int64]
13-
AR_f: npt.NDArray[np.float64]
13+
AR_f: npt.NDArray[np.longdouble]
1414
AR_c: npt.NDArray[np.complex128]
1515
AR_m: npt.NDArray[np.timedelta64]
1616
AR_M: npt.NDArray[np.datetime64]

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

Lines changed: 23 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -275,8 +275,8 @@ assert_type(+td, np.timedelta64)
275275
assert_type(+AR_f, npt.NDArray[np.float64])
276276

277277
assert_type(abs(f16), np.floating[_128Bit])
278-
assert_type(abs(c16), np.float64)
279-
assert_type(abs(c8), np.float32)
278+
assert_type(abs(c16), np.floating[_64Bit])
279+
assert_type(abs(c8), np.floating[_32Bit])
280280
assert_type(abs(f8), np.float64)
281281
assert_type(abs(f4), np.float32)
282282
assert_type(abs(i8), np.int64)
@@ -386,7 +386,7 @@ assert_type(c8 + AR_f, npt.NDArray[np.complexfloating[Any, Any]])
386386

387387
assert_type(f16 + c8, np.complexfloating[_32Bit, _32Bit] | np.complexfloating[_128Bit, _128Bit])
388388
assert_type(c16 + c8, np.complexfloating[_32Bit, _32Bit] | np.complexfloating[_64Bit, _64Bit])
389-
assert_type(f8 + c8, np.complexfloating[_32Bit, _32Bit] | np.complexfloating[_64Bit, _64Bit])
389+
assert_type(f8 + c8, np.complexfloating[_64Bit, _64Bit])
390390
assert_type(i8 + c8, np.complexfloating[_32Bit, _32Bit] | np.complexfloating[_64Bit, _64Bit])
391391
assert_type(c8 + c8, np.complex64)
392392
assert_type(f4 + c8, np.complex64)
@@ -399,48 +399,48 @@ assert_type(AR_f + c8, npt.NDArray[np.complexfloating[Any, Any]])
399399

400400
# Float
401401

402-
assert_type(f8 + f16, np.floating[_64Bit] | np.floating[_128Bit])
402+
assert_type(f8 + f16, np.float64| np.floating[_128Bit])
403403
assert_type(f8 + f8, np.float64)
404404
assert_type(f8 + i8, np.float64)
405-
assert_type(f8 + f4, np.floating[_32Bit] | np.floating[_64Bit])
406-
assert_type(f8 + i4, np.floating[_32Bit] | np.floating[_64Bit])
405+
assert_type(f8 + f4, np.float64 | np.floating[_32Bit])
406+
assert_type(f8 + i4, np.float64 | np.floating[_32Bit])
407407
assert_type(f8 + b_, np.float64)
408408
assert_type(f8 + b, np.float64)
409-
assert_type(f8 + c, np.complex128)
409+
assert_type(f8 + c, np.float64 | np.complex128)
410410
assert_type(f8 + f, np.float64)
411411
assert_type(f8 + AR_f, npt.NDArray[np.floating[Any]])
412412

413-
assert_type(f16 + f8, np.floating[_64Bit] | np.floating[_128Bit])
413+
assert_type(f16 + f8, np.floating[_128Bit] | np.float64)
414414
assert_type(f8 + f8, np.float64)
415-
assert_type(i8 + f8, np.float64)
416-
assert_type(f4 + f8, np.floating[_32Bit] | np.floating[_64Bit])
417-
assert_type(i4 + f8, np.floating[_32Bit] | np.floating[_64Bit])
415+
assert_type(i8 + f8, np.floating[_64Bit])
416+
assert_type(f4 + f8, np.floating[_32Bit] | np.float64)
417+
assert_type(i4 + f8, np.floating[_32Bit] | np.float64)
418418
assert_type(b_ + f8, np.float64)
419419
assert_type(b + f8, np.float64)
420-
assert_type(c + f8, np.complex128)
420+
assert_type(c + f8, np.complex128 | np.float64)
421421
assert_type(f + f8, np.float64)
422422
assert_type(AR_f + f8, npt.NDArray[np.floating[Any]])
423423

424-
assert_type(f4 + f16, np.floating[_32Bit] | np.floating[_128Bit])
425-
assert_type(f4 + f8, np.floating[_32Bit] | np.floating[_64Bit])
426-
assert_type(f4 + i8, np.floating[_32Bit] | np.floating[_64Bit])
424+
assert_type(f4 + f16, np.float32 | np.floating[_128Bit])
425+
assert_type(f4 + f8, np.float32 | np.float64)
426+
assert_type(f4 + i8, np.float32 | np.floating[_64Bit])
427427
assert_type(f4 + f4, np.float32)
428428
assert_type(f4 + i4, np.float32)
429429
assert_type(f4 + b_, np.float32)
430430
assert_type(f4 + b, np.float32)
431431
assert_type(f4 + c, np.complexfloating[_32Bit, _32Bit] | np.complexfloating[_64Bit, _64Bit])
432-
assert_type(f4 + f, np.floating[_32Bit] | np.floating[_64Bit])
432+
assert_type(f4 + f, np.float32 | np.float64)
433433
assert_type(f4 + AR_f, npt.NDArray[np.floating[Any]])
434434

435-
assert_type(f16 + f4, np.floating[_32Bit] | np.floating[_128Bit])
436-
assert_type(f8 + f4, np.floating[_32Bit] | np.floating[_64Bit])
435+
assert_type(f16 + f4, np.floating[_128Bit] | np.float32)
436+
assert_type(f8 + f4, np.float64 | np.float32)
437437
assert_type(i8 + f4, np.floating[_32Bit] | np.floating[_64Bit])
438438
assert_type(f4 + f4, np.float32)
439439
assert_type(i4 + f4, np.float32)
440440
assert_type(b_ + f4, np.float32)
441441
assert_type(b + f4, np.float32)
442442
assert_type(c + f4, np.complexfloating[_32Bit, _32Bit] | np.complexfloating[_64Bit, _64Bit])
443-
assert_type(f + f4, np.floating[_32Bit] | np.floating[_64Bit])
443+
assert_type(f + f4, np.float64 | np.float32)
444444
assert_type(AR_f + f4, npt.NDArray[np.floating[Any]])
445445

446446
# Int
@@ -452,7 +452,7 @@ assert_type(i8 + u4, Any)
452452
assert_type(i8 + b_, np.int64)
453453
assert_type(i8 + b, np.int64)
454454
assert_type(i8 + c, np.complex128)
455-
assert_type(i8 + f, np.float64)
455+
assert_type(i8 + f, np.floating[_64Bit])
456456
assert_type(i8 + AR_f, npt.NDArray[np.floating[Any]])
457457

458458
assert_type(u8 + u8, np.uint64)
@@ -461,7 +461,7 @@ assert_type(u8 + u4, np.unsignedinteger[_32Bit] | np.unsignedinteger[_64Bit])
461461
assert_type(u8 + b_, np.uint64)
462462
assert_type(u8 + b, np.uint64)
463463
assert_type(u8 + c, np.complex128)
464-
assert_type(u8 + f, np.float64)
464+
assert_type(u8 + f, np.floating[_64Bit])
465465
assert_type(u8 + AR_f, npt.NDArray[np.floating[Any]])
466466

467467
assert_type(i8 + i8, np.int64)
@@ -471,7 +471,7 @@ assert_type(u4 + i8, Any)
471471
assert_type(b_ + i8, np.int64)
472472
assert_type(b + i8, np.int64)
473473
assert_type(c + i8, np.complex128)
474-
assert_type(f + i8, np.float64)
474+
assert_type(f + i8, np.floating[_64Bit])
475475
assert_type(AR_f + i8, npt.NDArray[np.floating[Any]])
476476

477477
assert_type(u8 + u8, np.uint64)
@@ -480,7 +480,7 @@ assert_type(u4 + u8, np.unsignedinteger[_32Bit] | np.unsignedinteger[_64Bit])
480480
assert_type(b_ + u8, np.uint64)
481481
assert_type(b + u8, np.uint64)
482482
assert_type(c + u8, np.complex128)
483-
assert_type(f + u8, np.float64)
483+
assert_type(f + u8, np.floating[_64Bit])
484484
assert_type(AR_f + u8, npt.NDArray[np.floating[Any]])
485485

486486
assert_type(i4 + i8, np.signedinteger[_32Bit] | np.signedinteger[_64Bit])

numpy/typing/tests/data/reveal/arraysetops.pyi

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import numpy.typing as npt
55
from numpy.lib._arraysetops_impl import (
66
UniqueAllResult, UniqueCountsResult, UniqueInverseResult
77
)
8+
from numpy._typing import _64Bit
89

910
from typing_extensions import assert_type
1011

@@ -25,7 +26,10 @@ assert_type(np.ediff1d(AR_LIKE_f8, to_begin=[1, 1.5]), npt.NDArray[Any])
2526
assert_type(np.intersect1d(AR_i8, AR_i8), npt.NDArray[np.int64])
2627
assert_type(np.intersect1d(AR_M, AR_M, assume_unique=True), npt.NDArray[np.datetime64])
2728
assert_type(np.intersect1d(AR_f8, AR_i8), npt.NDArray[Any])
28-
assert_type(np.intersect1d(AR_f8, AR_f8, return_indices=True), tuple[npt.NDArray[np.float64], npt.NDArray[np.intp], npt.NDArray[np.intp]])
29+
assert_type(
30+
np.intersect1d(AR_f8, AR_f8, return_indices=True),
31+
tuple[npt.NDArray[np.floating[_64Bit]], npt.NDArray[np.intp], npt.NDArray[np.intp]],
32+
)
2933

3034
assert_type(np.setxor1d(AR_i8, AR_i8), npt.NDArray[np.int64])
3135
assert_type(np.setxor1d(AR_M, AR_M, assume_unique=True), npt.NDArray[np.datetime64])

numpy/typing/tests/data/reveal/getlimits.pyi

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
from typing import Any
22

33
import numpy as np
4+
from numpy._typing import _64Bit
45

56
from typing_extensions import assert_type, LiteralString
67

@@ -15,8 +16,8 @@ u4: np.uint32
1516
finfo_f8: np.finfo[np.float64]
1617
iinfo_i8: np.iinfo[np.int64]
1718

18-
assert_type(np.finfo(f), np.finfo[np.double])
19-
assert_type(np.finfo(f8), np.finfo[np.float64])
19+
assert_type(np.finfo(f), np.finfo[np.float64])
20+
assert_type(np.finfo(f8), np.finfo[np.floating[_64Bit]])
2021
assert_type(np.finfo(c8), np.finfo[np.float32])
2122
assert_type(np.finfo('f2'), np.finfo[np.floating[Any]])
2223

0 commit comments

Comments
 (0)