@@ -656,6 +656,7 @@ _FloatingT = TypeVar("_FloatingT", bound=floating)
656
656
_ComplexFloatingT = TypeVar ("_ComplexFloatingT" , bound = complexfloating )
657
657
_InexactT = TypeVar ("_InexactT" , bound = inexact )
658
658
_NumberT = TypeVar ("_NumberT" , bound = number )
659
+ _NumericT = TypeVar ("_NumericT" , bound = number | timedelta64 )
659
660
_CoNumberT = TypeVar ("_CoNumberT" , bound = bool_ | number )
660
661
_CharT = TypeVar ("_CharT" , bound = character )
661
662
@@ -2209,13 +2210,13 @@ class ndarray(_ArrayOrScalarCommon, Generic[_ShapeT_co, _DTypeT_co]):
2209
2210
self : NDArray [generic [_T ]], x : _nt .Sequence1ND [_nt .op .CanRAdd [_T , _T ]], /
2210
2211
) -> ndarray [_ShapeT_co , _DTypeT_co ]: ...
2211
2212
2212
- # TODO(jorenham): reject `bool_ - bool_`
2213
+ #
2213
2214
@overload
2214
- def __sub__ (self : NDArray [_ScalarT ], x : _nt .Casts [_ScalarT ], / ) -> NDArray [_ScalarT ]: ... # type: ignore[overload-overlap]
2215
+ def __sub__ (self : NDArray [_NumericT ], x : _nt .Casts [_NumericT ], / ) -> NDArray [_NumericT ]: ... # type: ignore[overload-overlap]
2215
2216
@overload
2216
2217
def __sub__ (self : NDArray [_SelfScalarT ], x : _nt .CastsWith [_SelfScalarT , _ScalarT ], / ) -> NDArray [_ScalarT ]: ... # type: ignore[overload-overlap]
2217
2218
@overload
2218
- def __sub__ (self : _nt .CastsWithBuiltin [_T , _ScalarT ], x : _nt .SequenceND [_T ], / ) -> NDArray [_ScalarT ]: ...
2219
+ def __sub__ (self : _nt .CastsWithBuiltin [_T , _NumericT ], x : _nt .SequenceND [_T ], / ) -> NDArray [_NumericT ]: ...
2219
2220
@overload
2220
2221
def __sub__ (self : _nt .CastsWithInt [_ScalarT ], x : _nt .SequenceND [_nt .JustInt ], / ) -> NDArray [_ScalarT ]: ...
2221
2222
@overload
@@ -2229,19 +2230,15 @@ class ndarray(_ArrayOrScalarCommon, Generic[_ShapeT_co, _DTypeT_co]):
2229
2230
@overload
2230
2231
def __sub__ (self : NDArray [object_ ], x : object , / ) -> NDArray [object_ ]: ... # type: ignore[overload-cannot-match]
2231
2232
@overload
2232
- def __sub__ (self : NDArray [str_ ], x : _nt .ToString_nd [_T ], / ) -> _nt .StringArrayND [_T ]: ...
2233
- @overload
2234
- def __sub__ (self : _nt .StringArrayND [_T ], x : _nt .ToString_nd [_T ] | _nt .ToStr_nd , / ) -> _nt .StringArrayND [_T ]: ...
2235
- @overload
2236
2233
def __sub__ (self : NDArray [generic [_T ]], x : _nt .Sequence1ND [_nt .op .CanRSub [_T ]], / ) -> NDArray [Incomplete ]: ...
2237
2234
2238
2235
#
2239
2236
@overload
2240
- def __rsub__ (self : NDArray [_ScalarT ], x : _nt .Casts [_ScalarT ], / ) -> NDArray [_ScalarT ]: ... # type: ignore[overload-overlap]
2237
+ def __rsub__ (self : NDArray [_NumericT ], x : _nt .Casts [_NumericT ], / ) -> NDArray [_NumericT ]: ... # type: ignore[overload-overlap]
2241
2238
@overload
2242
2239
def __rsub__ (self : NDArray [_SelfScalarT ], x : _nt .CastsWith [_SelfScalarT , _ScalarT ], / ) -> NDArray [_ScalarT ]: ... # type: ignore[overload-overlap]
2243
2240
@overload
2244
- def __rsub__ (self : _nt .CastsWithBuiltin [_T , _ScalarT ], x : _nt .SequenceND [_T ], / ) -> NDArray [_ScalarT ]: ...
2241
+ def __rsub__ (self : _nt .CastsWithBuiltin [_T , _NumericT ], x : _nt .SequenceND [_T ], / ) -> NDArray [_NumericT ]: ...
2245
2242
@overload
2246
2243
def __rsub__ (self : _nt .CastsWithInt [_ScalarT ], x : _nt .SequenceND [_nt .JustInt ], / ) -> NDArray [_ScalarT ]: ...
2247
2244
@overload
@@ -2255,10 +2252,6 @@ class ndarray(_ArrayOrScalarCommon, Generic[_ShapeT_co, _DTypeT_co]):
2255
2252
@overload
2256
2253
def __rsub__ (self : NDArray [object_ ], x : object , / ) -> NDArray [object_ ]: ... # type: ignore[overload-cannot-match]
2257
2254
@overload
2258
- def __rsub__ (self : NDArray [str_ ], x : _nt .ToString_nd [_T ], / ) -> _nt .StringArrayND [_T ]: ...
2259
- @overload
2260
- def __rsub__ (self : _nt .StringArrayND [_T ], x : _nt .ToString_nd [_T ] | _nt .ToStr_nd , / ) -> _nt .StringArrayND [_T ]: ...
2261
- @overload
2262
2255
def __rsub__ (self : NDArray [generic [_T ]], x : _nt .Sequence1ND [_nt .op .CanSub [_T ]], / ) -> NDArray [Incomplete ]: ...
2263
2256
2264
2257
#
@@ -2277,10 +2270,6 @@ class ndarray(_ArrayOrScalarCommon, Generic[_ShapeT_co, _DTypeT_co]):
2277
2270
@overload
2278
2271
def __isub__ (self : NDArray [object_ ], x : object , / ) -> ndarray [_ShapeT_co , _DTypeT_co ]: ...
2279
2272
@overload
2280
- def __isub__ (
2281
- self : _nt .StringArrayND [_T ], x : _nt .ToString_nd [_T ] | _nt .ToStr_nd , /
2282
- ) -> ndarray [_ShapeT_co , _DTypeT_co ]: ...
2283
- @overload
2284
2273
def __isub__ (
2285
2274
self : NDArray [generic [_T ]], x : _nt .Sequence1ND [_nt .op .CanRSub [_T , _T ]], /
2286
2275
) -> ndarray [_ShapeT_co , _DTypeT_co ]: ...
@@ -2422,9 +2411,13 @@ class ndarray(_ArrayOrScalarCommon, Generic[_ShapeT_co, _DTypeT_co]):
2422
2411
def __pow__ (self : NDArray [_NumberT ], x : _nt .Casts [_NumberT ], k : None = None , / ) -> NDArray [_NumberT ]: ...
2423
2412
@overload
2424
2413
def __pow__ (
2425
- self : NDArray [_NumberT ], x : _nt .CastsWith [_NumberT , _ScalarT ], k : None = None , /
2414
+ self : NDArray [_CoNumberT ], x : _nt .CastsWith [_CoNumberT , _ScalarT ], k : None = None , /
2426
2415
) -> NDArray [_ScalarT ]: ...
2427
2416
@overload
2417
+ def __pow__ (
2418
+ self : _nt .CastsWithBuiltin [_T , _NumberT ], x : _nt .SequenceND [_T ], k : None = None , /
2419
+ ) -> NDArray [_NumberT ]: ...
2420
+ @overload
2428
2421
def __pow__ (
2429
2422
self : _nt .CastsWithInt [_ScalarT ], x : _nt .SequenceND [_nt .JustInt ], k : None = None , /
2430
2423
) -> NDArray [_ScalarT ]: ...
@@ -2437,16 +2430,22 @@ class ndarray(_ArrayOrScalarCommon, Generic[_ShapeT_co, _DTypeT_co]):
2437
2430
self : _nt .CastsWithComplex [_ScalarT ], x : _nt .SequenceND [_nt .JustComplex ], k : None = None , /
2438
2431
) -> NDArray [_ScalarT ]: ...
2439
2432
@overload
2433
+ def __pow__ (self : NDArray [bool_ ], x : _nt .ToBool_nd , k : None = None , / ) -> NDArray [int8 ]: ...
2434
+ @overload
2440
2435
def __pow__ (self : NDArray [object_ ], x : object , k : None = None , / ) -> NDArray [object_ ]: ...
2441
2436
2442
2437
#
2443
2438
@overload
2444
2439
def __rpow__ (self : NDArray [_NumberT ], x : _nt .Casts [_NumberT ], k : None = None , / ) -> NDArray [_NumberT ]: ...
2445
2440
@overload
2446
2441
def __rpow__ (
2447
- self : NDArray [_NumberT ], x : _nt .CastsWith [_NumberT , _ScalarT ], k : None = None , /
2442
+ self : NDArray [_CoNumberT ], x : _nt .CastsWith [_CoNumberT , _ScalarT ], k : None = None , /
2448
2443
) -> NDArray [_ScalarT ]: ...
2449
2444
@overload
2445
+ def __rpow__ (
2446
+ self : _nt .CastsWithBuiltin [_T , _NumberT ], x : _nt .SequenceND [_T ], k : None = None , /
2447
+ ) -> NDArray [_NumberT ]: ...
2448
+ @overload
2450
2449
def __rpow__ (
2451
2450
self : _nt .CastsWithInt [_ScalarT ], x : _nt .SequenceND [_nt .JustInt ], k : None = None , /
2452
2451
) -> NDArray [_ScalarT ]: ...
@@ -2459,6 +2458,8 @@ class ndarray(_ArrayOrScalarCommon, Generic[_ShapeT_co, _DTypeT_co]):
2459
2458
self : _nt .CastsWithComplex [_ScalarT ], x : _nt .SequenceND [_nt .JustComplex ], k : None = None , /
2460
2459
) -> NDArray [_ScalarT ]: ...
2461
2460
@overload
2461
+ def __rpow__ (self : NDArray [bool_ ], x : _nt .ToBool_nd , k : None = None , / ) -> NDArray [int8 ]: ...
2462
+ @overload
2462
2463
def __rpow__ (self : NDArray [object_ ], x : object , k : None = None , / ) -> NDArray [object_ ]: ...
2463
2464
2464
2465
#
@@ -2477,14 +2478,18 @@ class ndarray(_ArrayOrScalarCommon, Generic[_ShapeT_co, _DTypeT_co]):
2477
2478
@overload
2478
2479
def __truediv__ (self : NDArray [_InexactT ], x : _nt .Casts [_InexactT ], / ) -> NDArray [_InexactT ]: ...
2479
2480
@overload
2480
- def __truediv__ (self : NDArray [_InexactT ], x : _nt .CastsWith [_InexactT , _ScalarT ], / ) -> NDArray [_ScalarT ]: ...
2481
+ def __truediv__ (self : NDArray [_ScalarT ], x : _nt .CastsWith [_ScalarT , _InexactT ], / ) -> NDArray [_InexactT ]: ...
2481
2482
@overload
2482
2483
def __truediv__ (self : _nt .CastsWithFloat [_ScalarT ], x : _nt .SequenceND [float ], / ) -> NDArray [_ScalarT ]: ...
2483
2484
@overload
2484
2485
def __truediv__ (
2485
2486
self : _nt .CastsWithComplex [_ScalarT ], x : _nt .SequenceND [_nt .JustComplex ], /
2486
2487
) -> NDArray [_ScalarT ]: ...
2487
2488
@overload
2489
+ def __truediv__ (
2490
+ self : _HasDType [_HasType [_JustNumber ]], x : _nt .CoFloat64_nd | _HasDType [_HasType [_JustNumber ]], /
2491
+ ) -> NDArray [inexact ]: ...
2492
+ @overload
2488
2493
def __truediv__ (self : NDArray [_nt .co_integer ], x : _nt .CoInteger_nd , / ) -> NDArray [float64 ]: ...
2489
2494
@overload
2490
2495
def __truediv__ (self : NDArray [timedelta64 ], x : _nt .ToTimeDelta_nd , / ) -> NDArray [float64 ]: ...
@@ -2501,14 +2506,18 @@ class ndarray(_ArrayOrScalarCommon, Generic[_ShapeT_co, _DTypeT_co]):
2501
2506
@overload
2502
2507
def __rtruediv__ (self : NDArray [_InexactT ], x : _nt .Casts [_InexactT ], / ) -> NDArray [_InexactT ]: ...
2503
2508
@overload
2504
- def __rtruediv__ (self : NDArray [_InexactT ], x : _nt .CastsWith [_InexactT , _ScalarT ], / ) -> NDArray [_ScalarT ]: ...
2509
+ def __rtruediv__ (self : NDArray [_ScalarT ], x : _nt .CastsWith [_ScalarT , _InexactT ], / ) -> NDArray [_InexactT ]: ...
2505
2510
@overload
2506
2511
def __rtruediv__ (self : _nt .CastsWithFloat [_ScalarT ], x : _nt .SequenceND [float ], / ) -> NDArray [_ScalarT ]: ...
2507
2512
@overload
2508
2513
def __rtruediv__ (
2509
2514
self : _nt .CastsWithComplex [_ScalarT ], x : _nt .SequenceND [_nt .JustComplex ], /
2510
2515
) -> NDArray [_ScalarT ]: ...
2511
2516
@overload
2517
+ def __rtruediv__ (
2518
+ self : _HasDType [_HasType [_JustNumber ]], x : _nt .CoFloat64_nd | _HasDType [_HasType [_JustNumber ]], /
2519
+ ) -> NDArray [inexact ]: ...
2520
+ @overload
2512
2521
def __rtruediv__ (self : NDArray [_nt .co_integer ], x : _nt .CoInteger_nd , / ) -> NDArray [float64 ]: ...
2513
2522
@overload
2514
2523
def __rtruediv__ (self : NDArray [timedelta64 ], x : _nt .ToTimeDelta_nd , / ) -> NDArray [float64 ]: ...
0 commit comments