@@ -648,11 +648,12 @@ _ScalarT = TypeVar("_ScalarT", bound=generic)
648
648
_SelfScalarT = TypeVar ("_SelfScalarT" , bound = generic )
649
649
_ScalarT_co = TypeVar ("_ScalarT_co" , bound = generic , default = Any , covariant = True )
650
650
_IntegralT = TypeVar ("_IntegralT" , bound = bool_ | integer | object_ )
651
- _RealT = TypeVar ("_RealT" , bound = bool_ | integer | floating )
652
651
_RealScalarT = TypeVar ("_RealScalarT" , bound = bool_ | integer | floating | object_ )
653
652
_RealNumberT = TypeVar ("_RealNumberT" , bound = integer | floating )
654
653
_IntegerT = TypeVar ("_IntegerT" , bound = integer )
654
+ _CoIntegerT = TypeVar ("_CoIntegerT" , bound = bool_ | integer )
655
655
_FloatingT = TypeVar ("_FloatingT" , bound = floating )
656
+ _CoFloatingT = TypeVar ("_CoFloatingT" , bound = bool_ | integer | floating )
656
657
_ComplexFloatingT = TypeVar ("_ComplexFloatingT" , bound = complexfloating )
657
658
_InexactT = TypeVar ("_InexactT" , bound = inexact )
658
659
_NumberT = TypeVar ("_NumberT" , bound = number )
@@ -825,7 +826,7 @@ _IntegerCType: TypeAlias = _UnsignedIntegerCType | _SignedIntegerCType
825
826
_NumberCType : TypeAlias = _IntegerCType
826
827
_GenericCType : TypeAlias = _NumberCType | type [ct .c_bool | ct .c_char | ct .py_object [Any ]]
827
828
828
- _PyBoolND : TypeAlias = _nt .SequenceND [bool ]
829
+ _PyBoolND : TypeAlias = _nt .SequenceND [py_bool ]
829
830
_PyCoIntND : TypeAlias = _nt .SequenceND [int ]
830
831
_PyCoFloatND : TypeAlias = _nt .SequenceND [float ]
831
832
_PyCoComplexND : TypeAlias = _nt .SequenceND [complex ]
@@ -2617,7 +2618,9 @@ class ndarray(_ArrayOrScalarCommon, Generic[_ShapeT_co, _DTypeT_co]):
2617
2618
self : NDArray [_RealNumberT ], x : _nt .Casts [_RealNumberT ] | _nt .ToBool_nd , /
2618
2619
) -> NDArray [_RealNumberT ]: ...
2619
2620
@overload
2620
- def __mod__ (self : NDArray [_RealT ], x : _nt .CastsWith [_RealT , _RealScalarT ], / ) -> NDArray [_RealScalarT ]: ...
2621
+ def __mod__ (
2622
+ self : NDArray [_CoFloatingT ], x : _nt .CastsWith [_CoFloatingT , _RealScalarT ], /
2623
+ ) -> NDArray [_RealScalarT ]: ...
2621
2624
@overload
2622
2625
def __mod__ (self : _nt .CastsWithInt [_RealScalarT ], x : _PyIntND , / ) -> NDArray [_RealScalarT ]: ...
2623
2626
@overload
@@ -2637,7 +2640,9 @@ class ndarray(_ArrayOrScalarCommon, Generic[_ShapeT_co, _DTypeT_co]):
2637
2640
self : NDArray [_RealNumberT ], x : _nt .Casts [_RealNumberT ] | _nt .ToBool_nd , /
2638
2641
) -> NDArray [_RealNumberT ]: ...
2639
2642
@overload
2640
- def __rmod__ (self : NDArray [_RealT ], x : _nt .CastsWith [_RealT , _RealScalarT ], / ) -> NDArray [_RealScalarT ]: ...
2643
+ def __rmod__ (
2644
+ self : NDArray [_CoFloatingT ], x : _nt .CastsWith [_CoFloatingT , _RealScalarT ], /
2645
+ ) -> NDArray [_RealScalarT ]: ...
2641
2646
@overload
2642
2647
def __rmod__ (self : _nt .CastsWithInt [_RealScalarT ], x : _PyIntND , / ) -> NDArray [_RealScalarT ]: ...
2643
2648
@overload
@@ -2674,7 +2679,7 @@ class ndarray(_ArrayOrScalarCommon, Generic[_ShapeT_co, _DTypeT_co]):
2674
2679
) -> _2Tuple [NDArray [_RealNumberT ]]: ...
2675
2680
@overload
2676
2681
def __divmod__ (
2677
- self : NDArray [_RealT ], x : _nt .CastsWith [_RealT , _RealScalarT ], /
2682
+ self : NDArray [_CoFloatingT ], x : _nt .CastsWith [_CoFloatingT , _RealScalarT ], /
2678
2683
) -> _2Tuple [NDArray [_RealScalarT ]]: ...
2679
2684
@overload
2680
2685
def __divmod__ (self : _nt .CastsWithInt [_RealScalarT ], x : _PyIntND , / ) -> _2Tuple [NDArray [_RealScalarT ]]: ...
@@ -2696,7 +2701,7 @@ class ndarray(_ArrayOrScalarCommon, Generic[_ShapeT_co, _DTypeT_co]):
2696
2701
) -> _2Tuple [NDArray [_RealNumberT ]]: ...
2697
2702
@overload
2698
2703
def __rdivmod__ (
2699
- self : NDArray [_RealT ], x : _nt .CastsWith [_RealT , _RealScalarT ], /
2704
+ self : NDArray [_CoFloatingT ], x : _nt .CastsWith [_CoFloatingT , _RealScalarT ], /
2700
2705
) -> _2Tuple [NDArray [_RealScalarT ]]: ...
2701
2706
@overload
2702
2707
def __rdivmod__ (self : _nt .CastsWithInt [_RealScalarT ], x : _PyIntND , / ) -> _2Tuple [NDArray [_RealScalarT ]]: ...
@@ -2773,121 +2778,107 @@ class ndarray(_ArrayOrScalarCommon, Generic[_ShapeT_co, _DTypeT_co]):
2773
2778
@overload
2774
2779
def __irshift__ (self : NDArray [object_ ], x : object , / ) -> ndarray [_ShapeT_co , _DTypeT_co ]: ...
2775
2780
2776
- # TODO(jorenham): rewrite the binops below
2777
-
2778
2781
#
2779
2782
@overload
2780
- def __and__ (self : NDArray [bool_ ], rhs : _nt . ToBool_nd , / ) -> NDArray [bool_ ]: ...
2783
+ def __and__ (self : NDArray [bool_ ], x : _PyIntND , / ) -> NDArray [intp ]: ...
2781
2784
@overload
2782
- def __and__ (self : NDArray [unsignedinteger ], rhs : _nt . CoUInt64_nd , / ) -> NDArray [unsignedinteger ]: ...
2785
+ def __and__ (self : NDArray [_IntegerT ], x : _PyCoIntND , / ) -> NDArray [_IntegerT ]: ...
2783
2786
@overload
2784
- def __and__ (self : NDArray [signedinteger ], rhs : _nt .CoInt64_nd , / ) -> NDArray [signedinteger ]: ...
2787
+ def __and__ (self : NDArray [_CoIntegerT ], x : _nt .Casts [ _CoIntegerT ] | _PyBoolND , / ) -> NDArray [_CoIntegerT ]: ...
2785
2788
@overload
2786
- def __and__ (self : NDArray [integer ], rhs : _nt .CoInt64_nd , / ) -> NDArray [integer ]: ...
2789
+ def __and__ (self : NDArray [_CoIntegerT ], x : _nt .CastsWith [ _CoIntegerT , _IntegerT ], / ) -> NDArray [_IntegerT ]: ...
2787
2790
@overload
2788
- def __and__ (self : NDArray [object_ ], rhs : object , / ) -> NDArray [object_ ]: ...
2789
- @overload
2790
- def __and__ (self , rhs : _ArrayLikeObject_co , / ) -> NDArray [object_ ]: ...
2791
+ def __and__ (self : NDArray [object_ ], x : object , / ) -> NDArray [object_ ]: ...
2791
2792
2792
2793
#
2793
2794
@overload
2794
- def __rand__ (self : NDArray [bool_ ], lhs : _nt .ToBool_nd , / ) -> NDArray [bool_ ]: ...
2795
- @overload
2796
- def __rand__ (self : NDArray [unsignedinteger ], lhs : _nt .CoUInt64_nd , / ) -> NDArray [unsignedinteger ]: ...
2795
+ def __rand__ (self : NDArray [bool_ ], x : _PyIntND , / ) -> NDArray [intp ]: ...
2797
2796
@overload
2798
- def __rand__ (self : NDArray [signedinteger ], lhs : _nt . CoInt64_nd , / ) -> NDArray [signedinteger ]: ...
2797
+ def __rand__ (self : NDArray [_IntegerT ], x : _PyCoIntND , / ) -> NDArray [_IntegerT ]: ...
2799
2798
@overload
2800
- def __rand__ (self : NDArray [integer ], lhs : _nt .CoInt64_nd , / ) -> NDArray [integer ]: ...
2799
+ def __rand__ (self : NDArray [_CoIntegerT ], x : _nt .Casts [ _CoIntegerT ] | _PyBoolND , / ) -> NDArray [_CoIntegerT ]: ...
2801
2800
@overload
2802
- def __rand__ (self : NDArray [object_ ], lhs : object , / ) -> NDArray [object_ ]: ...
2801
+ def __rand__ (self : NDArray [_CoIntegerT ], x : _nt . CastsWith [ _CoIntegerT , _IntegerT ], / ) -> NDArray [_IntegerT ]: ...
2803
2802
@overload
2804
- def __rand__ (self , lhs : _ArrayLikeObject_co , / ) -> NDArray [object_ ]: ...
2803
+ def __rand__ (self : NDArray [ object_ ], x : object , / ) -> NDArray [object_ ]: ...
2805
2804
2806
2805
#
2807
2806
@overload # type: ignore[misc]
2808
- def __iand__ (self : NDArray [bool_ ], rhs : _nt .ToBool_nd , / ) -> ndarray [_ShapeT_co , _DTypeT_co ]: ...
2809
- @overload
2810
- def __iand__ (self : NDArray [unsignedinteger ], rhs : _nt .CoUInt64_nd , / ) -> ndarray [_ShapeT_co , _DTypeT_co ]: ...
2807
+ def __iand__ (self : NDArray [bool_ ], x : _nt .ToBool_nd , / ) -> ndarray [_ShapeT_co , _DTypeT_co ]: ...
2811
2808
@overload
2812
- def __iand__ (self : NDArray [integer ], rhs : _nt .CoInt64_nd , / ) -> ndarray [_ShapeT_co , _DTypeT_co ]: ...
2809
+ def __iand__ (
2810
+ self : NDArray [_IntegerT ], x : _nt .Casts [_IntegerT ] | _PyCoIntND , /
2811
+ ) -> ndarray [_ShapeT_co , _DTypeT_co ]: ...
2813
2812
@overload
2814
- def __iand__ (self : NDArray [object_ ], rhs : object , / ) -> ndarray [_ShapeT_co , _DTypeT_co ]: ...
2813
+ def __iand__ (self : NDArray [object_ ], x : object , / ) -> ndarray [_ShapeT_co , _DTypeT_co ]: ...
2815
2814
2816
2815
#
2817
2816
@overload
2818
- def __xor__ (self : NDArray [bool_ ], rhs : _nt . ToBool_nd , / ) -> NDArray [bool_ ]: ...
2817
+ def __xor__ (self : NDArray [bool_ ], x : _PyIntND , / ) -> NDArray [intp ]: ...
2819
2818
@overload
2820
- def __xor__ (self : NDArray [unsignedinteger ], rhs : _nt . CoUInt64_nd , / ) -> NDArray [unsignedinteger ]: ...
2819
+ def __xor__ (self : NDArray [_IntegerT ], x : _PyCoIntND , / ) -> NDArray [_IntegerT ]: ...
2821
2820
@overload
2822
- def __xor__ (self : NDArray [signedinteger ], rhs : _nt .CoInt64_nd , / ) -> NDArray [signedinteger ]: ...
2821
+ def __xor__ (self : NDArray [_CoIntegerT ], x : _nt .Casts [ _CoIntegerT ] | _PyBoolND , / ) -> NDArray [_CoIntegerT ]: ...
2823
2822
@overload
2824
- def __xor__ (self : NDArray [integer ], rhs : _nt .CoInt64_nd , / ) -> NDArray [integer ]: ...
2823
+ def __xor__ (self : NDArray [_CoIntegerT ], x : _nt .CastsWith [ _CoIntegerT , _IntegerT ], / ) -> NDArray [_IntegerT ]: ...
2825
2824
@overload
2826
- def __xor__ (self : NDArray [object_ ], rhs : object , / ) -> NDArray [object_ ]: ...
2827
- @overload
2828
- def __xor__ (self , rhs : _ArrayLikeObject_co , / ) -> NDArray [object_ ]: ...
2825
+ def __xor__ (self : NDArray [object_ ], x : object , / ) -> NDArray [object_ ]: ...
2829
2826
2830
2827
#
2831
2828
@overload
2832
- def __rxor__ (self : NDArray [bool_ ], lhs : _nt .ToBool_nd , / ) -> NDArray [bool_ ]: ...
2833
- @overload
2834
- def __rxor__ (self : NDArray [unsignedinteger ], lhs : _nt .CoUInt64_nd , / ) -> NDArray [unsignedinteger ]: ...
2829
+ def __rxor__ (self : NDArray [bool_ ], x : _PyIntND , / ) -> NDArray [intp ]: ...
2835
2830
@overload
2836
- def __rxor__ (self : NDArray [signedinteger ], lhs : _nt . CoInt64_nd , / ) -> NDArray [signedinteger ]: ...
2831
+ def __rxor__ (self : NDArray [_IntegerT ], x : _PyCoIntND , / ) -> NDArray [_IntegerT ]: ...
2837
2832
@overload
2838
- def __rxor__ (self : NDArray [integer ], lhs : _nt .CoInt64_nd , / ) -> NDArray [integer ]: ...
2833
+ def __rxor__ (self : NDArray [_CoIntegerT ], x : _nt .Casts [ _CoIntegerT ] | _PyBoolND , / ) -> NDArray [_CoIntegerT ]: ...
2839
2834
@overload
2840
- def __rxor__ (self : NDArray [object_ ], lhs : object , / ) -> NDArray [object_ ]: ...
2835
+ def __rxor__ (self : NDArray [_CoIntegerT ], x : _nt . CastsWith [ _CoIntegerT , _IntegerT ], / ) -> NDArray [_IntegerT ]: ...
2841
2836
@overload
2842
- def __rxor__ (self , lhs : _ArrayLikeObject_co , / ) -> NDArray [object_ ]: ...
2837
+ def __rxor__ (self : NDArray [ object_ ], x : object , / ) -> NDArray [object_ ]: ...
2843
2838
2844
2839
#
2845
2840
@overload # type: ignore[misc]
2846
- def __ixor__ (self : NDArray [bool_ ], rhs : _nt .ToBool_nd , / ) -> ndarray [_ShapeT_co , _DTypeT_co ]: ...
2847
- @overload
2848
- def __ixor__ (self : NDArray [unsignedinteger ], rhs : _nt .CoUInt64_nd , / ) -> ndarray [_ShapeT_co , _DTypeT_co ]: ...
2841
+ def __ixor__ (self : NDArray [bool_ ], x : _nt .ToBool_nd , / ) -> ndarray [_ShapeT_co , _DTypeT_co ]: ...
2849
2842
@overload
2850
- def __ixor__ (self : NDArray [integer ], rhs : _nt .CoInt64_nd , / ) -> ndarray [_ShapeT_co , _DTypeT_co ]: ...
2843
+ def __ixor__ (
2844
+ self : NDArray [_IntegerT ], x : _nt .Casts [_IntegerT ] | _PyCoIntND , /
2845
+ ) -> ndarray [_ShapeT_co , _DTypeT_co ]: ...
2851
2846
@overload
2852
- def __ixor__ (self : NDArray [object_ ], rhs : object , / ) -> ndarray [_ShapeT_co , _DTypeT_co ]: ...
2847
+ def __ixor__ (self : NDArray [object_ ], x : object , / ) -> ndarray [_ShapeT_co , _DTypeT_co ]: ...
2853
2848
2854
2849
#
2855
2850
@overload
2856
- def __or__ (self : NDArray [bool_ ], rhs : _nt . ToBool_nd , / ) -> NDArray [bool_ ]: ...
2851
+ def __or__ (self : NDArray [bool_ ], x : _PyIntND , / ) -> NDArray [intp ]: ...
2857
2852
@overload
2858
- def __or__ (self : NDArray [unsignedinteger ], rhs : _nt . CoUInt64_nd , / ) -> NDArray [unsignedinteger ]: ...
2853
+ def __or__ (self : NDArray [_IntegerT ], x : _PyCoIntND , / ) -> NDArray [_IntegerT ]: ...
2859
2854
@overload
2860
- def __or__ (self : NDArray [signedinteger ], rhs : _nt .CoInt64_nd , / ) -> NDArray [signedinteger ]: ...
2855
+ def __or__ (self : NDArray [_CoIntegerT ], x : _nt .Casts [ _CoIntegerT ] | _PyBoolND , / ) -> NDArray [_CoIntegerT ]: ...
2861
2856
@overload
2862
- def __or__ (self : NDArray [integer ], rhs : _nt .CoInt64_nd , / ) -> NDArray [integer ]: ...
2857
+ def __or__ (self : NDArray [_CoIntegerT ], x : _nt .CastsWith [ _CoIntegerT , _IntegerT ], / ) -> NDArray [_IntegerT ]: ...
2863
2858
@overload
2864
- def __or__ (self : NDArray [object_ ], rhs : object , / ) -> NDArray [object_ ]: ...
2865
- @overload
2866
- def __or__ (self , rhs : _ArrayLikeObject_co , / ) -> NDArray [object_ ]: ...
2859
+ def __or__ (self : NDArray [object_ ], x : object , / ) -> NDArray [object_ ]: ...
2867
2860
2868
2861
#
2869
2862
@overload
2870
- def __ror__ (self : NDArray [bool_ ], lhs : _nt .ToBool_nd , / ) -> NDArray [bool_ ]: ...
2871
- @overload
2872
- def __ror__ (self : NDArray [unsignedinteger ], lhs : _nt .CoUInt64_nd , / ) -> NDArray [unsignedinteger ]: ...
2863
+ def __ror__ (self : NDArray [bool_ ], x : _PyIntND , / ) -> NDArray [intp ]: ...
2873
2864
@overload
2874
- def __ror__ (self : NDArray [signedinteger ], lhs : _nt . CoInt64_nd , / ) -> NDArray [signedinteger ]: ...
2865
+ def __ror__ (self : NDArray [_IntegerT ], x : _PyCoIntND , / ) -> NDArray [_IntegerT ]: ...
2875
2866
@overload
2876
- def __ror__ (self : NDArray [integer ], lhs : _nt .CoInt64_nd , / ) -> NDArray [integer ]: ...
2867
+ def __ror__ (self : NDArray [_CoIntegerT ], x : _nt .Casts [ _CoIntegerT ] | _PyBoolND , / ) -> NDArray [_CoIntegerT ]: ...
2877
2868
@overload
2878
- def __ror__ (self : NDArray [object_ ], lhs : object , / ) -> NDArray [object_ ]: ...
2869
+ def __ror__ (self : NDArray [_CoIntegerT ], x : _nt . CastsWith [ _CoIntegerT , _IntegerT ], / ) -> NDArray [_IntegerT ]: ...
2879
2870
@overload
2880
- def __ror__ (self , lhs : _ArrayLikeObject_co , / ) -> NDArray [object_ ]: ...
2871
+ def __ror__ (self : NDArray [ object_ ], x : object , / ) -> NDArray [object_ ]: ...
2881
2872
2882
2873
#
2883
2874
@overload # type: ignore[misc]
2884
- def __ior__ (self : NDArray [bool_ ], rhs : _nt .ToBool_nd , / ) -> ndarray [_ShapeT_co , _DTypeT_co ]: ...
2885
- @overload
2886
- def __ior__ (self : NDArray [unsignedinteger ], rhs : _nt .CoUInt64_nd , / ) -> ndarray [_ShapeT_co , _DTypeT_co ]: ...
2875
+ def __ior__ (self : NDArray [bool_ ], x : _nt .ToBool_nd , / ) -> ndarray [_ShapeT_co , _DTypeT_co ]: ...
2887
2876
@overload
2888
- def __ior__ (self : NDArray [integer ], rhs : _nt .CoInt64_nd , / ) -> ndarray [_ShapeT_co , _DTypeT_co ]: ...
2877
+ def __ior__ (
2878
+ self : NDArray [_IntegerT ], x : _nt .Casts [_IntegerT ] | _PyCoIntND , /
2879
+ ) -> ndarray [_ShapeT_co , _DTypeT_co ]: ...
2889
2880
@overload
2890
- def __ior__ (self : NDArray [object_ ], rhs : object , / ) -> ndarray [_ShapeT_co , _DTypeT_co ]: ...
2881
+ def __ior__ (self : NDArray [object_ ], x : object , / ) -> ndarray [_ShapeT_co , _DTypeT_co ]: ...
2891
2882
2892
2883
#
2893
2884
def __dlpack__ (
0 commit comments