@@ -666,6 +666,7 @@ _BitT2 = TypeVar("_BitT2", bound=NBitBase, default=_BitT1) # pyright: ignore[re
666
666
667
667
_ItemT_co = TypeVar ("_ItemT_co" , default = Any , covariant = True )
668
668
_BoolItemT_co = TypeVar ("_BoolItemT_co" , bound = py_bool , default = py_bool , covariant = True )
669
+ _NumberItemT = TypeVar ("_NumberItemT" , bound = complex )
669
670
_NumberItemT_co = TypeVar ("_NumberItemT_co" , bound = complex , default = Any , covariant = True )
670
671
_InexactItemT_co = TypeVar ("_InexactItemT_co" , bound = complex , default = Any , covariant = True )
671
672
_FlexItemT_co = TypeVar (
@@ -2212,9 +2213,9 @@ class ndarray(_ArrayOrScalarCommon, Generic[_ShapeT_co, _DTypeT_co]):
2212
2213
2213
2214
#
2214
2215
@overload
2215
- def __sub__ (self : NDArray [_NumericT ], x : _nt .Casts [_NumericT ], / ) -> NDArray [_NumericT ]: ... # type: ignore[overload-overlap]
2216
+ def __sub__ (self : NDArray [_NumericT ], x : _nt .Casts [_NumericT ], / ) -> NDArray [_NumericT ]: ...
2216
2217
@overload
2217
- def __sub__ (self : NDArray [_SelfScalarT ], x : _nt .CastsWith [_SelfScalarT , _ScalarT ], / ) -> NDArray [_ScalarT ]: ... # type: ignore[overload-overlap]
2218
+ def __sub__ (self : NDArray [_CoNumberT ], x : _nt .CastsWith [_CoNumberT , _ScalarT ], / ) -> NDArray [_ScalarT ]: ...
2218
2219
@overload
2219
2220
def __sub__ (self : _nt .CastsWithBuiltin [_T , _NumericT ], x : _nt .SequenceND [_T ], / ) -> NDArray [_NumericT ]: ...
2220
2221
@overload
@@ -2228,15 +2229,17 @@ class ndarray(_ArrayOrScalarCommon, Generic[_ShapeT_co, _DTypeT_co]):
2228
2229
@overload
2229
2230
def __sub__ (self : NDArray [datetime64 ], x : _nt .CoTimeDelta_nd , / ) -> NDArray [datetime64 ]: ...
2230
2231
@overload
2231
- def __sub__ (self : NDArray [object_ ], x : object , / ) -> NDArray [object_ ]: ... # type: ignore[overload-cannot-match]
2232
+ def __sub__ (self : NDArray [object_ ], x : object , / ) -> NDArray [object_ ]: ...
2232
2233
@overload
2233
- def __sub__ (self : NDArray [generic [_T ]], x : _nt .Sequence1ND [_nt .op .CanRSub [_T ]], / ) -> NDArray [Incomplete ]: ...
2234
+ def __sub__ (
2235
+ self : NDArray [generic [_NumberItemT ]], x : _nt .Sequence1ND [_nt .op .CanRSub [_NumberItemT ]], /
2236
+ ) -> NDArray [Incomplete ]: ...
2234
2237
2235
2238
#
2236
2239
@overload
2237
- def __rsub__ (self : NDArray [_NumericT ], x : _nt .Casts [_NumericT ], / ) -> NDArray [_NumericT ]: ... # type: ignore[overload-overlap]
2240
+ def __rsub__ (self : NDArray [_NumericT ], x : _nt .Casts [_NumericT ], / ) -> NDArray [_NumericT ]: ...
2238
2241
@overload
2239
- def __rsub__ (self : NDArray [_SelfScalarT ], x : _nt .CastsWith [_SelfScalarT , _ScalarT ], / ) -> NDArray [_ScalarT ]: ... # type: ignore[overload-overlap]
2242
+ def __rsub__ (self : NDArray [_CoNumberT ], x : _nt .CastsWith [_CoNumberT , _ScalarT ], / ) -> NDArray [_ScalarT ]: ...
2240
2243
@overload
2241
2244
def __rsub__ (self : _nt .CastsWithBuiltin [_T , _NumericT ], x : _nt .SequenceND [_T ], / ) -> NDArray [_NumericT ]: ...
2242
2245
@overload
@@ -2250,16 +2253,16 @@ class ndarray(_ArrayOrScalarCommon, Generic[_ShapeT_co, _DTypeT_co]):
2250
2253
@overload
2251
2254
def __rsub__ (self : NDArray [_nt .co_timedelta ], x : _nt .ToDateTime_nd , / ) -> NDArray [datetime64 ]: ...
2252
2255
@overload
2253
- def __rsub__ (self : NDArray [object_ ], x : object , / ) -> NDArray [object_ ]: ... # type: ignore[overload-cannot-match]
2256
+ def __rsub__ (self : NDArray [object_ ], x : object , / ) -> NDArray [object_ ]: ...
2254
2257
@overload
2255
- def __rsub__ (self : NDArray [generic [_T ]], x : _nt .Sequence1ND [_nt .op .CanSub [_T ]], / ) -> NDArray [Incomplete ]: ...
2258
+ def __rsub__ (
2259
+ self : NDArray [generic [_NumberItemT ]], x : _nt .Sequence1ND [_nt .op .CanSub [_NumberItemT ]], /
2260
+ ) -> NDArray [Incomplete ]: ...
2256
2261
2257
2262
#
2258
2263
@overload # type: ignore[misc]
2259
2264
def __isub__ (self : NDArray [_ScalarT ], x : _nt .Casts [_ScalarT ], / ) -> ndarray [_ShapeT_co , _DTypeT_co ]: ...
2260
2265
@overload
2261
- def __isub__ (self : NDArray [bool_ ], x : _nt .SequenceND [bool ], / ) -> ndarray [_ShapeT_co , _DTypeT_co ]: ...
2262
- @overload
2263
2266
def __isub__ (self : NDArray [number ], x : _nt .SequenceND [int ], / ) -> ndarray [_ShapeT_co , _DTypeT_co ]: ...
2264
2267
@overload
2265
2268
def __isub__ (self : NDArray [inexact ], x : _nt .SequenceND [float ], / ) -> ndarray [_ShapeT_co , _DTypeT_co ]: ...
@@ -2271,7 +2274,7 @@ class ndarray(_ArrayOrScalarCommon, Generic[_ShapeT_co, _DTypeT_co]):
2271
2274
def __isub__ (self : NDArray [object_ ], x : object , / ) -> ndarray [_ShapeT_co , _DTypeT_co ]: ...
2272
2275
@overload
2273
2276
def __isub__ (
2274
- self : NDArray [generic [_T ]], x : _nt .Sequence1ND [_nt .op .CanRSub [_T , _T ]], /
2277
+ self : NDArray [generic [_NumberItemT ]], x : _nt .Sequence1ND [_nt .op .CanRSub [_T , _T ]], /
2275
2278
) -> ndarray [_ShapeT_co , _DTypeT_co ]: ...
2276
2279
2277
2280
#
@@ -2410,18 +2413,14 @@ class ndarray(_ArrayOrScalarCommon, Generic[_ShapeT_co, _DTypeT_co]):
2410
2413
@overload
2411
2414
def __pow__ (self : NDArray [_NumberT ], x : _nt .Casts [_NumberT ], k : None = None , / ) -> NDArray [_NumberT ]: ...
2412
2415
@overload
2413
- def __pow__ (
2414
- self : NDArray [_CoNumberT ], x : _nt .CastsWith [_CoNumberT , _ScalarT ], k : None = None , /
2415
- ) -> NDArray [_ScalarT ]: ...
2416
- @overload
2417
- def __pow__ (
2418
- self : _nt .CastsWithBuiltin [_T , _NumberT ], x : _nt .SequenceND [_T ], k : None = None , /
2419
- ) -> NDArray [_NumberT ]: ...
2416
+ def __pow__ (self : NDArray [bool_ ], x : _nt .ToBool_nd , k : None = None , / ) -> NDArray [int8 ]: ...
2420
2417
@overload
2421
2418
def __pow__ (
2422
- self : _nt . CastsWithInt [ _ScalarT ], x : _nt .SequenceND [ _nt . JustInt ], k : None = None , /
2419
+ self : NDArray [ _NumberT ], x : _nt .CastsWith [ _NumberT , _ScalarT ], k : None = None , /
2423
2420
) -> NDArray [_ScalarT ]: ...
2424
2421
@overload
2422
+ def __pow__ (self : _nt .CastsWithInt [_NumberT ], x : _nt .SequenceND [int ], k : None = None , / ) -> NDArray [_NumberT ]: ...
2423
+ @overload
2425
2424
def __pow__ (
2426
2425
self : _nt .CastsWithFloat [_ScalarT ], x : _nt .SequenceND [_nt .JustFloat ], k : None = None , /
2427
2426
) -> NDArray [_ScalarT ]: ...
@@ -2430,26 +2429,20 @@ class ndarray(_ArrayOrScalarCommon, Generic[_ShapeT_co, _DTypeT_co]):
2430
2429
self : _nt .CastsWithComplex [_ScalarT ], x : _nt .SequenceND [_nt .JustComplex ], k : None = None , /
2431
2430
) -> NDArray [_ScalarT ]: ...
2432
2431
@overload
2433
- def __pow__ (self : NDArray [bool_ ], x : _nt .ToBool_nd , k : None = None , / ) -> NDArray [int8 ]: ...
2434
- @overload
2435
2432
def __pow__ (self : NDArray [object_ ], x : object , k : None = None , / ) -> NDArray [object_ ]: ...
2436
2433
2437
2434
#
2438
2435
@overload
2439
2436
def __rpow__ (self : NDArray [_NumberT ], x : _nt .Casts [_NumberT ], k : None = None , / ) -> NDArray [_NumberT ]: ...
2440
2437
@overload
2441
- def __rpow__ (
2442
- self : NDArray [_CoNumberT ], x : _nt .CastsWith [_CoNumberT , _ScalarT ], k : None = None , /
2443
- ) -> NDArray [_ScalarT ]: ...
2444
- @overload
2445
- def __rpow__ (
2446
- self : _nt .CastsWithBuiltin [_T , _NumberT ], x : _nt .SequenceND [_T ], k : None = None , /
2447
- ) -> NDArray [_NumberT ]: ...
2438
+ def __rpow__ (self : NDArray [bool_ ], x : _nt .ToBool_nd , k : None = None , / ) -> NDArray [int8 ]: ...
2448
2439
@overload
2449
2440
def __rpow__ (
2450
- self : _nt . CastsWithInt [ _ScalarT ], x : _nt .SequenceND [ _nt . JustInt ], k : None = None , /
2441
+ self : NDArray [ _NumberT ], x : _nt .CastsWith [ _NumberT , _ScalarT ], k : None = None , /
2451
2442
) -> NDArray [_ScalarT ]: ...
2452
2443
@overload
2444
+ def __rpow__ (self : _nt .CastsWithInt [_NumberT ], x : _nt .SequenceND [int ], k : None = None , / ) -> NDArray [_NumberT ]: ...
2445
+ @overload
2453
2446
def __rpow__ (
2454
2447
self : _nt .CastsWithFloat [_ScalarT ], x : _nt .SequenceND [_nt .JustFloat ], k : None = None , /
2455
2448
) -> NDArray [_ScalarT ]: ...
@@ -2458,8 +2451,6 @@ class ndarray(_ArrayOrScalarCommon, Generic[_ShapeT_co, _DTypeT_co]):
2458
2451
self : _nt .CastsWithComplex [_ScalarT ], x : _nt .SequenceND [_nt .JustComplex ], k : None = None , /
2459
2452
) -> NDArray [_ScalarT ]: ...
2460
2453
@overload
2461
- def __rpow__ (self : NDArray [bool_ ], x : _nt .ToBool_nd , k : None = None , / ) -> NDArray [int8 ]: ...
2462
- @overload
2463
2454
def __rpow__ (self : NDArray [object_ ], x : object , k : None = None , / ) -> NDArray [object_ ]: ...
2464
2455
2465
2456
#
@@ -2476,59 +2467,59 @@ class ndarray(_ArrayOrScalarCommon, Generic[_ShapeT_co, _DTypeT_co]):
2476
2467
2477
2468
#
2478
2469
@overload
2470
+ def __truediv__ (
2471
+ self : _HasDType [_HasType [_JustNumber ]], x : _nt .CoFloat64_nd | _HasDType [_HasType [_JustNumber ]], /
2472
+ ) -> NDArray [inexact ]: ...
2473
+ @overload
2479
2474
def __truediv__ (self : NDArray [_InexactT ], x : _nt .Casts [_InexactT ], / ) -> NDArray [_InexactT ]: ...
2480
2475
@overload
2481
- def __truediv__ (self : NDArray [_ScalarT ], x : _nt .CastsWith [_ScalarT , _InexactT ], / ) -> NDArray [_InexactT ]: ...
2476
+ def __truediv__ (self : NDArray [_ScalarT ], x : _nt .CastsWith [_ScalarT , _InexactT ], / ) -> NDArray [_InexactT ]: ... # type: ignore[overload-overlap]
2482
2477
@overload
2483
2478
def __truediv__ (self : _nt .CastsWithFloat [_ScalarT ], x : _nt .SequenceND [float ], / ) -> NDArray [_ScalarT ]: ...
2484
2479
@overload
2485
2480
def __truediv__ (
2486
2481
self : _nt .CastsWithComplex [_ScalarT ], x : _nt .SequenceND [_nt .JustComplex ], /
2487
2482
) -> NDArray [_ScalarT ]: ...
2488
2483
@overload
2489
- def __truediv__ (
2490
- self : _HasDType [_HasType [_JustNumber ]], x : _nt .CoFloat64_nd | _HasDType [_HasType [_JustNumber ]], /
2491
- ) -> NDArray [inexact ]: ...
2492
- @overload
2493
2484
def __truediv__ (self : NDArray [_nt .co_integer ], x : _nt .CoInteger_nd , / ) -> NDArray [float64 ]: ...
2494
2485
@overload
2495
2486
def __truediv__ (self : NDArray [timedelta64 ], x : _nt .ToTimeDelta_nd , / ) -> NDArray [float64 ]: ...
2496
2487
@overload
2497
2488
def __truediv__ (self : NDArray [timedelta64 ], x : _nt .ToInteger_nd | _nt .ToFloating_nd , / ) -> NDArray [timedelta64 ]: ...
2498
2489
@overload
2499
- def __truediv__ (self : NDArray [object_ ], x : object , / ) -> NDArray [object_ ]: ...
2500
- @overload
2501
2490
def __truediv__ (
2502
- self : NDArray [generic [_T ]], x : _nt .Sequence1ND [_nt .op .CanRTruediv [_T ]], /
2491
+ self : NDArray [generic [_NumberItemT ]], x : _nt .Sequence1ND [_nt .op .CanRTruediv [_NumberItemT ]], /
2503
2492
) -> NDArray [Incomplete ]: ...
2493
+ @overload
2494
+ def __truediv__ (self : NDArray [object_ ], x : object , / ) -> NDArray [object_ ]: ...
2504
2495
2505
2496
#
2506
2497
@overload
2498
+ def __rtruediv__ (
2499
+ self : _HasDType [_HasType [_JustNumber ]], x : _nt .CoFloat64_nd | _HasDType [_HasType [_JustNumber ]], /
2500
+ ) -> NDArray [inexact ]: ...
2501
+ @overload
2507
2502
def __rtruediv__ (self : NDArray [_InexactT ], x : _nt .Casts [_InexactT ], / ) -> NDArray [_InexactT ]: ...
2508
2503
@overload
2509
- def __rtruediv__ (self : NDArray [_ScalarT ], x : _nt .CastsWith [_ScalarT , _InexactT ], / ) -> NDArray [_InexactT ]: ...
2504
+ def __rtruediv__ (self : NDArray [_ScalarT ], x : _nt .CastsWith [_ScalarT , _InexactT ], / ) -> NDArray [_InexactT ]: ... # type: ignore[overload-overlap]
2510
2505
@overload
2511
2506
def __rtruediv__ (self : _nt .CastsWithFloat [_ScalarT ], x : _nt .SequenceND [float ], / ) -> NDArray [_ScalarT ]: ...
2512
2507
@overload
2513
2508
def __rtruediv__ (
2514
2509
self : _nt .CastsWithComplex [_ScalarT ], x : _nt .SequenceND [_nt .JustComplex ], /
2515
2510
) -> NDArray [_ScalarT ]: ...
2516
2511
@overload
2517
- def __rtruediv__ (
2518
- self : _HasDType [_HasType [_JustNumber ]], x : _nt .CoFloat64_nd | _HasDType [_HasType [_JustNumber ]], /
2519
- ) -> NDArray [inexact ]: ...
2520
- @overload
2521
2512
def __rtruediv__ (self : NDArray [_nt .co_integer ], x : _nt .CoInteger_nd , / ) -> NDArray [float64 ]: ...
2522
2513
@overload
2523
2514
def __rtruediv__ (self : NDArray [timedelta64 ], x : _nt .ToTimeDelta_nd , / ) -> NDArray [float64 ]: ...
2524
2515
@overload
2525
2516
def __rtruediv__ (self : NDArray [integer | floating ], x : _nt .ToTimeDelta_nd , / ) -> NDArray [timedelta64 ]: ...
2526
2517
@overload
2527
- def __rtruediv__ (self : NDArray [object_ ], x : object , / ) -> NDArray [object_ ]: ...
2528
- @overload
2529
2518
def __rtruediv__ (
2530
- self : NDArray [generic [_T ]], x : _nt .Sequence1ND [_nt .op .CanTruediv [_T ]], /
2519
+ self : NDArray [generic [_NumberItemT ]], x : _nt .Sequence1ND [_nt .op .CanTruediv [_NumberItemT ]], /
2531
2520
) -> NDArray [Incomplete ]: ...
2521
+ @overload
2522
+ def __rtruediv__ (self : NDArray [object_ ], x : object , / ) -> NDArray [object_ ]: ...
2532
2523
2533
2524
#
2534
2525
@overload # type: ignore[misc]
@@ -2544,11 +2535,11 @@ class ndarray(_ArrayOrScalarCommon, Generic[_ShapeT_co, _DTypeT_co]):
2544
2535
self : NDArray [timedelta64 ], x : _nt .ToInteger_nd | _nt .ToFloating_nd , /
2545
2536
) -> ndarray [_ShapeT_co , _DTypeT_co ]: ...
2546
2537
@overload
2547
- def __itruediv__ (self : NDArray [object_ ], x : object , / ) -> ndarray [_ShapeT_co , _DTypeT_co ]: ...
2548
- @overload
2549
2538
def __itruediv__ (
2550
- self : NDArray [generic [_T ]], x : _nt .Sequence1ND [_nt .op .CanRTruediv [_T , _T ]], /
2539
+ self : NDArray [generic [_NumberItemT ]], x : _nt .Sequence1ND [_nt .op .CanRTruediv [_NumberItemT , _NumberItemT ]], /
2551
2540
) -> ndarray [_ShapeT_co , _DTypeT_co ]: ...
2541
+ @overload
2542
+ def __itruediv__ (self : NDArray [object_ ], x : object , / ) -> ndarray [_ShapeT_co , _DTypeT_co ]: ...
2552
2543
2553
2544
# TODO(jorenham): rewrite the modular and bitwise binops below
2554
2545
0 commit comments