Skip to content

Commit 1b25ef5

Browse files
authored
Merge pull request numpy#28108 from jorenham/typing/better-ndarray-arithmetic-binops-for-float64-and-complex128
TYP: Better ``ndarray`` binop return types for ``float64`` & ``complex128``
2 parents dcbc24e + 37c8793 commit 1b25ef5

File tree

6 files changed

+438
-213
lines changed

6 files changed

+438
-213
lines changed

numpy/__init__.pyi

Lines changed: 358 additions & 133 deletions
Large diffs are not rendered by default.

numpy/_typing/__init__.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -121,15 +121,14 @@
121121
NDArray as NDArray,
122122
ArrayLike as ArrayLike,
123123
_ArrayLike as _ArrayLike,
124-
_FiniteNestedSequence as _FiniteNestedSequence,
125-
_SupportsArray as _SupportsArray,
126-
_SupportsArrayFunc as _SupportsArrayFunc,
127124
_ArrayLikeInt as _ArrayLikeInt,
128125
_ArrayLikeBool_co as _ArrayLikeBool_co,
129126
_ArrayLikeUInt_co as _ArrayLikeUInt_co,
130127
_ArrayLikeInt_co as _ArrayLikeInt_co,
131128
_ArrayLikeFloat_co as _ArrayLikeFloat_co,
129+
_ArrayLikeFloat64_co as _ArrayLikeFloat64_co,
132130
_ArrayLikeComplex_co as _ArrayLikeComplex_co,
131+
_ArrayLikeComplex128_co as _ArrayLikeComplex128_co,
133132
_ArrayLikeNumber_co as _ArrayLikeNumber_co,
134133
_ArrayLikeTD64_co as _ArrayLikeTD64_co,
135134
_ArrayLikeDT64_co as _ArrayLikeDT64_co,
@@ -140,6 +139,9 @@
140139
_ArrayLikeString_co as _ArrayLikeString_co,
141140
_ArrayLikeAnyString_co as _ArrayLikeAnyString_co,
142141
_ArrayLikeUnknown as _ArrayLikeUnknown,
142+
_FiniteNestedSequence as _FiniteNestedSequence,
143+
_SupportsArray as _SupportsArray,
144+
_SupportsArrayFunc as _SupportsArrayFunc,
143145
_UnknownType as _UnknownType,
144146
)
145147

numpy/_typing/_array_like.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
str_,
2222
bytes_,
2323
)
24+
from ._nbit_base import _32Bit, _64Bit
2425
from ._nested_sequence import _NestedSequence
2526
from ._shape import _Shape
2627

@@ -164,6 +165,11 @@ def __buffer__(self, flags: int, /) -> memoryview: ...
164165
_ArrayLikeString_co
165166
)
166167

168+
__Float64_co: TypeAlias = np.floating[_64Bit] | np.float32 | np.float16 | np.integer | np.bool
169+
__Complex128_co: TypeAlias = np.number[_64Bit] | np.number[_32Bit] | np.float16 | np.integer | np.bool
170+
_ArrayLikeFloat64_co: TypeAlias = _DualArrayLike[dtype[__Float64_co], float | int]
171+
_ArrayLikeComplex128_co: TypeAlias = _DualArrayLike[dtype[__Complex128_co], complex | float | int]
172+
167173
# NOTE: This includes `builtins.bool`, but not `numpy.bool`.
168174
_ArrayLikeInt: TypeAlias = _DualArrayLike[
169175
dtype[integer[Any]],

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

Lines changed: 61 additions & 55 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,7 @@ AR_m: npt.NDArray[np.timedelta64]
5151
AR_M: npt.NDArray[np.datetime64]
5252
AR_O: npt.NDArray[np.object_]
5353
AR_number: npt.NDArray[np.number[Any]]
54+
AR_Any: npt.NDArray[Any]
5455

5556
AR_LIKE_b: list[bool]
5657
AR_LIKE_u: list[np.uint32]
@@ -61,34 +62,35 @@ AR_LIKE_m: list[np.timedelta64]
6162
AR_LIKE_M: list[np.datetime64]
6263
AR_LIKE_O: list[np.object_]
6364

65+
6466
# Array subtraction
6567

6668
assert_type(AR_number - AR_number, npt.NDArray[np.number[Any]])
6769

68-
assert_type(AR_b - AR_LIKE_u, npt.NDArray[np.unsignedinteger[Any]])
70+
assert_type(AR_b - AR_LIKE_u, npt.NDArray[np.uint32])
6971
assert_type(AR_b - AR_LIKE_i, npt.NDArray[np.signedinteger[Any]])
7072
assert_type(AR_b - AR_LIKE_f, npt.NDArray[np.floating[Any]])
7173
assert_type(AR_b - AR_LIKE_c, npt.NDArray[np.complexfloating[Any, Any]])
7274
assert_type(AR_b - AR_LIKE_m, npt.NDArray[np.timedelta64])
7375
assert_type(AR_b - AR_LIKE_O, Any)
7476

75-
assert_type(AR_LIKE_u - AR_b, npt.NDArray[np.unsignedinteger[Any]])
77+
assert_type(AR_LIKE_u - AR_b, npt.NDArray[np.uint32])
7678
assert_type(AR_LIKE_i - AR_b, npt.NDArray[np.signedinteger[Any]])
7779
assert_type(AR_LIKE_f - AR_b, npt.NDArray[np.floating[Any]])
7880
assert_type(AR_LIKE_c - AR_b, npt.NDArray[np.complexfloating[Any, Any]])
7981
assert_type(AR_LIKE_m - AR_b, npt.NDArray[np.timedelta64])
8082
assert_type(AR_LIKE_M - AR_b, npt.NDArray[np.datetime64])
8183
assert_type(AR_LIKE_O - AR_b, Any)
8284

83-
assert_type(AR_u - AR_LIKE_b, npt.NDArray[np.unsignedinteger[Any]])
85+
assert_type(AR_u - AR_LIKE_b, npt.NDArray[np.uint32])
8486
assert_type(AR_u - AR_LIKE_u, npt.NDArray[np.unsignedinteger[Any]])
8587
assert_type(AR_u - AR_LIKE_i, npt.NDArray[np.signedinteger[Any]])
8688
assert_type(AR_u - AR_LIKE_f, npt.NDArray[np.floating[Any]])
8789
assert_type(AR_u - AR_LIKE_c, npt.NDArray[np.complexfloating[Any, Any]])
8890
assert_type(AR_u - AR_LIKE_m, npt.NDArray[np.timedelta64])
8991
assert_type(AR_u - AR_LIKE_O, Any)
9092

91-
assert_type(AR_LIKE_b - AR_u, npt.NDArray[np.unsignedinteger[Any]])
93+
assert_type(AR_LIKE_b - AR_u, npt.NDArray[np.uint32])
9294
assert_type(AR_LIKE_u - AR_u, npt.NDArray[np.unsignedinteger[Any]])
9395
assert_type(AR_LIKE_i - AR_u, npt.NDArray[np.signedinteger[Any]])
9496
assert_type(AR_LIKE_f - AR_u, npt.NDArray[np.floating[Any]])
@@ -97,15 +99,15 @@ assert_type(AR_LIKE_m - AR_u, npt.NDArray[np.timedelta64])
9799
assert_type(AR_LIKE_M - AR_u, npt.NDArray[np.datetime64])
98100
assert_type(AR_LIKE_O - AR_u, Any)
99101

100-
assert_type(AR_i - AR_LIKE_b, npt.NDArray[np.signedinteger[Any]])
102+
assert_type(AR_i - AR_LIKE_b, npt.NDArray[np.int64])
101103
assert_type(AR_i - AR_LIKE_u, npt.NDArray[np.signedinteger[Any]])
102104
assert_type(AR_i - AR_LIKE_i, npt.NDArray[np.signedinteger[Any]])
103105
assert_type(AR_i - AR_LIKE_f, npt.NDArray[np.floating[Any]])
104106
assert_type(AR_i - AR_LIKE_c, npt.NDArray[np.complexfloating[Any, Any]])
105107
assert_type(AR_i - AR_LIKE_m, npt.NDArray[np.timedelta64])
106108
assert_type(AR_i - AR_LIKE_O, Any)
107109

108-
assert_type(AR_LIKE_b - AR_i, npt.NDArray[np.signedinteger[Any]])
110+
assert_type(AR_LIKE_b - AR_i, npt.NDArray[np.int64])
109111
assert_type(AR_LIKE_u - AR_i, npt.NDArray[np.signedinteger[Any]])
110112
assert_type(AR_LIKE_i - AR_i, npt.NDArray[np.signedinteger[Any]])
111113
assert_type(AR_LIKE_f - AR_i, npt.NDArray[np.floating[Any]])
@@ -114,32 +116,32 @@ assert_type(AR_LIKE_m - AR_i, npt.NDArray[np.timedelta64])
114116
assert_type(AR_LIKE_M - AR_i, npt.NDArray[np.datetime64])
115117
assert_type(AR_LIKE_O - AR_i, Any)
116118

117-
assert_type(AR_f - AR_LIKE_b, npt.NDArray[np.floating[Any]])
118-
assert_type(AR_f - AR_LIKE_u, npt.NDArray[np.floating[Any]])
119-
assert_type(AR_f - AR_LIKE_i, npt.NDArray[np.floating[Any]])
120-
assert_type(AR_f - AR_LIKE_f, npt.NDArray[np.floating[Any]])
119+
assert_type(AR_f - AR_LIKE_b, npt.NDArray[np.float64])
120+
assert_type(AR_f - AR_LIKE_u, npt.NDArray[np.float64])
121+
assert_type(AR_f - AR_LIKE_i, npt.NDArray[np.float64])
122+
assert_type(AR_f - AR_LIKE_f, npt.NDArray[np.float64])
121123
assert_type(AR_f - AR_LIKE_c, npt.NDArray[np.complexfloating[Any, Any]])
122124
assert_type(AR_f - AR_LIKE_O, Any)
123125

124-
assert_type(AR_LIKE_b - AR_f, npt.NDArray[np.floating[Any]])
125-
assert_type(AR_LIKE_u - AR_f, npt.NDArray[np.floating[Any]])
126-
assert_type(AR_LIKE_i - AR_f, npt.NDArray[np.floating[Any]])
127-
assert_type(AR_LIKE_f - AR_f, npt.NDArray[np.floating[Any]])
126+
assert_type(AR_LIKE_b - AR_f, npt.NDArray[np.float64])
127+
assert_type(AR_LIKE_u - AR_f, npt.NDArray[np.float64])
128+
assert_type(AR_LIKE_i - AR_f, npt.NDArray[np.float64])
129+
assert_type(AR_LIKE_f - AR_f, npt.NDArray[np.float64])
128130
assert_type(AR_LIKE_c - AR_f, npt.NDArray[np.complexfloating[Any, Any]])
129131
assert_type(AR_LIKE_O - AR_f, Any)
130132

131-
assert_type(AR_c - AR_LIKE_b, npt.NDArray[np.complexfloating[Any, Any]])
132-
assert_type(AR_c - AR_LIKE_u, npt.NDArray[np.complexfloating[Any, Any]])
133-
assert_type(AR_c - AR_LIKE_i, npt.NDArray[np.complexfloating[Any, Any]])
134-
assert_type(AR_c - AR_LIKE_f, npt.NDArray[np.complexfloating[Any, Any]])
135-
assert_type(AR_c - AR_LIKE_c, npt.NDArray[np.complexfloating[Any, Any]])
133+
assert_type(AR_c - AR_LIKE_b, npt.NDArray[np.complex128])
134+
assert_type(AR_c - AR_LIKE_u, npt.NDArray[np.complex128])
135+
assert_type(AR_c - AR_LIKE_i, npt.NDArray[np.complex128])
136+
assert_type(AR_c - AR_LIKE_f, npt.NDArray[np.complex128])
137+
assert_type(AR_c - AR_LIKE_c, npt.NDArray[np.complex128])
136138
assert_type(AR_c - AR_LIKE_O, Any)
137139

138-
assert_type(AR_LIKE_b - AR_c, npt.NDArray[np.complexfloating[Any, Any]])
139-
assert_type(AR_LIKE_u - AR_c, npt.NDArray[np.complexfloating[Any, Any]])
140-
assert_type(AR_LIKE_i - AR_c, npt.NDArray[np.complexfloating[Any, Any]])
141-
assert_type(AR_LIKE_f - AR_c, npt.NDArray[np.complexfloating[Any, Any]])
142-
assert_type(AR_LIKE_c - AR_c, npt.NDArray[np.complexfloating[Any, Any]])
140+
assert_type(AR_LIKE_b - AR_c, npt.NDArray[np.complex128])
141+
assert_type(AR_LIKE_u - AR_c, npt.NDArray[np.complex128])
142+
assert_type(AR_LIKE_i - AR_c, npt.NDArray[np.complex128])
143+
assert_type(AR_LIKE_f - AR_c, npt.NDArray[np.complex128])
144+
assert_type(AR_LIKE_c - AR_c, npt.NDArray[np.complex128])
143145
assert_type(AR_LIKE_O - AR_c, Any)
144146

145147
assert_type(AR_m - AR_LIKE_b, npt.NDArray[np.timedelta64])
@@ -186,53 +188,53 @@ assert_type(AR_LIKE_O - AR_O, Any)
186188
# Array floor division
187189

188190
assert_type(AR_b // AR_LIKE_b, npt.NDArray[np.int8])
189-
assert_type(AR_b // AR_LIKE_u, npt.NDArray[np.unsignedinteger[Any]])
191+
assert_type(AR_b // AR_LIKE_u, npt.NDArray[np.uint32])
190192
assert_type(AR_b // AR_LIKE_i, npt.NDArray[np.signedinteger[Any]])
191193
assert_type(AR_b // AR_LIKE_f, npt.NDArray[np.floating[Any]])
192194
assert_type(AR_b // AR_LIKE_O, Any)
193195

194196
assert_type(AR_LIKE_b // AR_b, npt.NDArray[np.int8])
195-
assert_type(AR_LIKE_u // AR_b, npt.NDArray[np.unsignedinteger[Any]])
197+
assert_type(AR_LIKE_u // AR_b, npt.NDArray[np.uint32])
196198
assert_type(AR_LIKE_i // AR_b, npt.NDArray[np.signedinteger[Any]])
197199
assert_type(AR_LIKE_f // AR_b, npt.NDArray[np.floating[Any]])
198200
assert_type(AR_LIKE_O // AR_b, Any)
199201

200-
assert_type(AR_u // AR_LIKE_b, npt.NDArray[np.unsignedinteger[Any]])
202+
assert_type(AR_u // AR_LIKE_b, npt.NDArray[np.uint32])
201203
assert_type(AR_u // AR_LIKE_u, npt.NDArray[np.unsignedinteger[Any]])
202204
assert_type(AR_u // AR_LIKE_i, npt.NDArray[np.signedinteger[Any]])
203205
assert_type(AR_u // AR_LIKE_f, npt.NDArray[np.floating[Any]])
204206
assert_type(AR_u // AR_LIKE_O, Any)
205207

206-
assert_type(AR_LIKE_b // AR_u, npt.NDArray[np.unsignedinteger[Any]])
208+
assert_type(AR_LIKE_b // AR_u, npt.NDArray[np.uint32])
207209
assert_type(AR_LIKE_u // AR_u, npt.NDArray[np.unsignedinteger[Any]])
208210
assert_type(AR_LIKE_i // AR_u, npt.NDArray[np.signedinteger[Any]])
209211
assert_type(AR_LIKE_f // AR_u, npt.NDArray[np.floating[Any]])
210212
assert_type(AR_LIKE_m // AR_u, npt.NDArray[np.timedelta64])
211213
assert_type(AR_LIKE_O // AR_u, Any)
212214

213-
assert_type(AR_i // AR_LIKE_b, npt.NDArray[np.signedinteger[Any]])
215+
assert_type(AR_i // AR_LIKE_b, npt.NDArray[np.int64])
214216
assert_type(AR_i // AR_LIKE_u, npt.NDArray[np.signedinteger[Any]])
215217
assert_type(AR_i // AR_LIKE_i, npt.NDArray[np.signedinteger[Any]])
216218
assert_type(AR_i // AR_LIKE_f, npt.NDArray[np.floating[Any]])
217219
assert_type(AR_i // AR_LIKE_O, Any)
218220

219-
assert_type(AR_LIKE_b // AR_i, npt.NDArray[np.signedinteger[Any]])
221+
assert_type(AR_LIKE_b // AR_i, npt.NDArray[np.int64])
220222
assert_type(AR_LIKE_u // AR_i, npt.NDArray[np.signedinteger[Any]])
221223
assert_type(AR_LIKE_i // AR_i, npt.NDArray[np.signedinteger[Any]])
222224
assert_type(AR_LIKE_f // AR_i, npt.NDArray[np.floating[Any]])
223225
assert_type(AR_LIKE_m // AR_i, npt.NDArray[np.timedelta64])
224226
assert_type(AR_LIKE_O // AR_i, Any)
225227

226-
assert_type(AR_f // AR_LIKE_b, npt.NDArray[np.floating[Any]])
227-
assert_type(AR_f // AR_LIKE_u, npt.NDArray[np.floating[Any]])
228-
assert_type(AR_f // AR_LIKE_i, npt.NDArray[np.floating[Any]])
229-
assert_type(AR_f // AR_LIKE_f, npt.NDArray[np.floating[Any]])
228+
assert_type(AR_f // AR_LIKE_b, npt.NDArray[np.float64])
229+
assert_type(AR_f // AR_LIKE_u, npt.NDArray[np.float64])
230+
assert_type(AR_f // AR_LIKE_i, npt.NDArray[np.float64])
231+
assert_type(AR_f // AR_LIKE_f, npt.NDArray[np.float64])
230232
assert_type(AR_f // AR_LIKE_O, Any)
231233

232-
assert_type(AR_LIKE_b // AR_f, npt.NDArray[np.floating[Any]])
233-
assert_type(AR_LIKE_u // AR_f, npt.NDArray[np.floating[Any]])
234-
assert_type(AR_LIKE_i // AR_f, npt.NDArray[np.floating[Any]])
235-
assert_type(AR_LIKE_f // AR_f, npt.NDArray[np.floating[Any]])
234+
assert_type(AR_LIKE_b // AR_f, npt.NDArray[np.float64])
235+
assert_type(AR_LIKE_u // AR_f, npt.NDArray[np.float64])
236+
assert_type(AR_LIKE_i // AR_f, npt.NDArray[np.float64])
237+
assert_type(AR_LIKE_f // AR_f, npt.NDArray[np.float64])
236238
assert_type(AR_LIKE_m // AR_f, npt.NDArray[np.timedelta64])
237239
assert_type(AR_LIKE_O // AR_f, Any)
238240

@@ -407,7 +409,7 @@ assert_type(c16 + b_, np.complex128)
407409
assert_type(c16 + b, np.complex128)
408410
assert_type(c16 + c, np.complex128)
409411
assert_type(c16 + f, np.complex128)
410-
assert_type(c16 + AR_f, npt.NDArray[np.complexfloating[Any, Any]])
412+
assert_type(c16 + AR_f, npt.NDArray[np.complex128])
411413

412414
assert_type(f16 + c16, np.complex128 | np.complexfloating[_128Bit, _128Bit])
413415
assert_type(c16 + c16, np.complex128)
@@ -420,7 +422,7 @@ assert_type(b_ + c16, np.complex128)
420422
assert_type(b + c16, np.complex128)
421423
assert_type(c + c16, np.complex128)
422424
assert_type(f + c16, np.complex128)
423-
assert_type(AR_f + c16, npt.NDArray[np.complexfloating[Any, Any]])
425+
assert_type(AR_f + c16, npt.NDArray[np.complex128])
424426

425427
assert_type(c8 + f16, np.complexfloating[_32Bit, _32Bit] | np.complexfloating[_128Bit, _128Bit])
426428
assert_type(c8 + c16, np.complex64 | np.complex128)
@@ -433,7 +435,7 @@ assert_type(c8 + b_, np.complex64)
433435
assert_type(c8 + b, np.complex64)
434436
assert_type(c8 + c, np.complex64 | np.complex128)
435437
assert_type(c8 + f, np.complex64 | np.complex128)
436-
assert_type(c8 + AR_f, npt.NDArray[np.complexfloating[Any, Any]])
438+
assert_type(c8 + AR_f, npt.NDArray[np.complexfloating])
437439

438440
assert_type(f16 + c8, np.complexfloating[_128Bit, _128Bit] | np.complex64)
439441
assert_type(c16 + c8, np.complex128)
@@ -446,7 +448,7 @@ assert_type(b_ + c8, np.complex64)
446448
assert_type(b + c8, np.complex64)
447449
assert_type(c + c8, np.complex64 | np.complex128)
448450
assert_type(f + c8, np.complex64 | np.complex128)
449-
assert_type(AR_f + c8, npt.NDArray[np.complexfloating[Any, Any]])
451+
assert_type(AR_f + c8, npt.NDArray[np.complexfloating])
450452

451453
# Float
452454

@@ -459,18 +461,18 @@ assert_type(f8 + b_, np.float64)
459461
assert_type(f8 + b, np.float64)
460462
assert_type(f8 + c, np.float64 | np.complex128)
461463
assert_type(f8 + f, np.float64)
462-
assert_type(f8 + AR_f, npt.NDArray[np.floating[Any]])
464+
assert_type(f8 + AR_f, npt.NDArray[np.float64])
463465

464466
assert_type(f16 + f8, np.floating[_128Bit] | np.float64)
465467
assert_type(f8 + f8, np.float64)
466468
assert_type(i8 + f8, np.float64)
467-
assert_type(f4 + f8, np.floating[_32Bit] | np.float64)
469+
assert_type(f4 + f8, np.float32 | np.float64)
468470
assert_type(i4 + f8,np.float64)
469471
assert_type(b_ + f8, np.float64)
470472
assert_type(b + f8, np.float64)
471473
assert_type(c + f8, np.complex128 | np.float64)
472474
assert_type(f + f8, np.float64)
473-
assert_type(AR_f + f8, npt.NDArray[np.floating[Any]])
475+
assert_type(AR_f + f8, npt.NDArray[np.float64])
474476

475477
assert_type(f4 + f16, np.float32 | np.floating[_128Bit])
476478
assert_type(f4 + f8, np.float32 | np.float64)
@@ -481,7 +483,7 @@ assert_type(f4 + b_, np.float32)
481483
assert_type(f4 + b, np.float32)
482484
assert_type(f4 + c, np.complex64 | np.complex128)
483485
assert_type(f4 + f, np.float32 | np.float64)
484-
assert_type(f4 + AR_f, npt.NDArray[np.floating[Any]])
486+
assert_type(f4 + AR_f, npt.NDArray[np.float64])
485487

486488
assert_type(f16 + f4, np.floating[_128Bit] | np.float32)
487489
assert_type(f8 + f4, np.float64)
@@ -492,7 +494,7 @@ assert_type(b_ + f4, np.float32)
492494
assert_type(b + f4, np.float32)
493495
assert_type(c + f4, np.complex64 | np.complex128)
494496
assert_type(f + f4, np.float64 | np.float32)
495-
assert_type(AR_f + f4, npt.NDArray[np.floating[Any]])
497+
assert_type(AR_f + f4, npt.NDArray[np.float64])
496498

497499
# Int
498500

@@ -504,7 +506,7 @@ assert_type(i8 + b_, np.int64)
504506
assert_type(i8 + b, np.int64)
505507
assert_type(i8 + c, np.complex128)
506508
assert_type(i8 + f, np.float64)
507-
assert_type(i8 + AR_f, npt.NDArray[np.floating[Any]])
509+
assert_type(i8 + AR_f, npt.NDArray[np.float64])
508510

509511
assert_type(u8 + u8, np.uint64)
510512
assert_type(u8 + i4, Any)
@@ -513,7 +515,7 @@ assert_type(u8 + b_, np.uint64)
513515
assert_type(u8 + b, np.uint64)
514516
assert_type(u8 + c, np.complex128)
515517
assert_type(u8 + f, np.float64)
516-
assert_type(u8 + AR_f, npt.NDArray[np.floating[Any]])
518+
assert_type(u8 + AR_f, npt.NDArray[np.float64])
517519

518520
assert_type(i8 + i8, np.int64)
519521
assert_type(u8 + i8, Any)
@@ -523,7 +525,7 @@ assert_type(b_ + i8, np.int64)
523525
assert_type(b + i8, np.int64)
524526
assert_type(c + i8, np.complex128)
525527
assert_type(f + i8, np.float64)
526-
assert_type(AR_f + i8, npt.NDArray[np.floating[Any]])
528+
assert_type(AR_f + i8, npt.NDArray[np.float64])
527529

528530
assert_type(u8 + u8, np.uint64)
529531
assert_type(i4 + u8, Any)
@@ -532,32 +534,36 @@ assert_type(b_ + u8, np.uint64)
532534
assert_type(b + u8, np.uint64)
533535
assert_type(c + u8, np.complex128)
534536
assert_type(f + u8, np.float64)
535-
assert_type(AR_f + u8, npt.NDArray[np.floating[Any]])
537+
assert_type(AR_f + u8, npt.NDArray[np.float64])
536538

537539
assert_type(i4 + i8, np.signedinteger[_32Bit] | np.signedinteger[_64Bit])
538540
assert_type(i4 + i4, np.int32)
539541
assert_type(i4 + b_, np.int32)
540542
assert_type(i4 + b, np.int32)
541-
assert_type(i4 + AR_f, npt.NDArray[np.floating[Any]])
543+
assert_type(i4 + AR_f, npt.NDArray[np.float64])
542544

543545
assert_type(u4 + i8, Any)
544546
assert_type(u4 + i4, Any)
545547
assert_type(u4 + u8, np.unsignedinteger[_32Bit] | np.unsignedinteger[_64Bit])
546548
assert_type(u4 + u4, np.uint32)
547549
assert_type(u4 + b_, np.uint32)
548550
assert_type(u4 + b, np.uint32)
549-
assert_type(u4 + AR_f, npt.NDArray[np.floating[Any]])
551+
assert_type(u4 + AR_f, npt.NDArray[np.float64])
550552

551553
assert_type(i8 + i4, np.signedinteger[_32Bit] | np.signedinteger[_64Bit])
552554
assert_type(i4 + i4, np.int32)
553555
assert_type(b_ + i4, np.int32)
554556
assert_type(b + i4, np.int32)
555-
assert_type(AR_f + i4, npt.NDArray[np.floating[Any]])
557+
assert_type(AR_f + i4, npt.NDArray[np.float64])
556558

557559
assert_type(i8 + u4, Any)
558560
assert_type(i4 + u4, Any)
559561
assert_type(u8 + u4, np.unsignedinteger[_32Bit] | np.unsignedinteger[_64Bit])
560562
assert_type(u4 + u4, np.uint32)
561563
assert_type(b_ + u4, np.uint32)
562564
assert_type(b + u4, np.uint32)
563-
assert_type(AR_f + u4, npt.NDArray[np.floating[Any]])
565+
assert_type(AR_f + u4, npt.NDArray[np.float64])
566+
567+
# Any
568+
569+
assert_type(AR_Any + 2, npt.NDArray[Any])

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

Lines changed: 0 additions & 14 deletions
This file was deleted.

0 commit comments

Comments
 (0)