@@ -191,7 +191,7 @@ def __array__(
191
191
# NumPy behavior
192
192
193
193
def _check_allowed_dtypes (
194
- self , other : Array | bool | int | float | complex , dtype_category : str , op : str
194
+ self , other : Array | complex , dtype_category : str , op : str
195
195
) -> Array :
196
196
"""
197
197
Helper function for operators to only allow specific input dtypes
@@ -233,7 +233,7 @@ def _check_allowed_dtypes(
233
233
234
234
return other
235
235
236
- def _check_device (self , other : Array | bool | int | float | complex ) -> None :
236
+ def _check_device (self , other : Array | complex ) -> None :
237
237
"""Check that other is on a device compatible with the current array"""
238
238
if isinstance (other , (bool , int , float , complex )):
239
239
return
@@ -244,7 +244,7 @@ def _check_device(self, other: Array | bool | int | float | complex) -> None:
244
244
raise TypeError (f"Expected Array | python scalar; got { type (other )} " )
245
245
246
246
# Helper function to match the type promotion rules in the spec
247
- def _promote_scalar (self , scalar : bool | int | float | complex ) -> Array :
247
+ def _promote_scalar (self , scalar : complex ) -> Array :
248
248
"""
249
249
Returns a promoted version of a Python scalar appropriate for use with
250
250
operations on self.
@@ -538,7 +538,7 @@ def __abs__(self) -> Array:
538
538
res = self ._array .__abs__ ()
539
539
return self .__class__ ._new (res , device = self .device )
540
540
541
- def __add__ (self , other : Array | int | float | complex , / ) -> Array :
541
+ def __add__ (self , other : Array | complex , / ) -> Array :
542
542
"""
543
543
Performs the operation __add__.
544
544
"""
@@ -550,7 +550,7 @@ def __add__(self, other: Array | int | float | complex, /) -> Array:
550
550
res = self ._array .__add__ (other ._array )
551
551
return self .__class__ ._new (res , device = self .device )
552
552
553
- def __and__ (self , other : Array | bool | int , / ) -> Array :
553
+ def __and__ (self , other : Array | int , / ) -> Array :
554
554
"""
555
555
Performs the operation __and__.
556
556
"""
@@ -647,7 +647,7 @@ def __dlpack_device__(self) -> tuple[IntEnum, int]:
647
647
# Note: device support is required for this
648
648
return self ._array .__dlpack_device__ ()
649
649
650
- def __eq__ (self , other : Array | bool | int | float | complex , / ) -> Array : # type: ignore[override]
650
+ def __eq__ (self , other : Array | complex , / ) -> Array : # type: ignore[override]
651
651
"""
652
652
Performs the operation __eq__.
653
653
"""
@@ -673,7 +673,7 @@ def __float__(self) -> float:
673
673
res = self ._array .__float__ ()
674
674
return res
675
675
676
- def __floordiv__ (self , other : Array | int | float , / ) -> Array :
676
+ def __floordiv__ (self , other : Array | float , / ) -> Array :
677
677
"""
678
678
Performs the operation __floordiv__.
679
679
"""
@@ -685,7 +685,7 @@ def __floordiv__(self, other: Array | int | float, /) -> Array:
685
685
res = self ._array .__floordiv__ (other ._array )
686
686
return self .__class__ ._new (res , device = self .device )
687
687
688
- def __ge__ (self , other : Array | int | float , / ) -> Array :
688
+ def __ge__ (self , other : Array | float , / ) -> Array :
689
689
"""
690
690
Performs the operation __ge__.
691
691
"""
@@ -737,7 +737,7 @@ def __getitem__(
737
737
res = self ._array .__getitem__ (np_key )
738
738
return self ._new (res , device = self .device )
739
739
740
- def __gt__ (self , other : Array | int | float , / ) -> Array :
740
+ def __gt__ (self , other : Array | float , / ) -> Array :
741
741
"""
742
742
Performs the operation __gt__.
743
743
"""
@@ -792,7 +792,7 @@ def __iter__(self) -> Iterator[Array]:
792
792
# implemented, which implies iteration on 1-D arrays.
793
793
return (Array ._new (i , device = self .device ) for i in self ._array )
794
794
795
- def __le__ (self , other : Array | int | float , / ) -> Array :
795
+ def __le__ (self , other : Array | float , / ) -> Array :
796
796
"""
797
797
Performs the operation __le__.
798
798
"""
@@ -816,7 +816,7 @@ def __lshift__(self, other: Array | int, /) -> Array:
816
816
res = self ._array .__lshift__ (other ._array )
817
817
return self .__class__ ._new (res , device = self .device )
818
818
819
- def __lt__ (self , other : Array | int | float , / ) -> Array :
819
+ def __lt__ (self , other : Array | float , / ) -> Array :
820
820
"""
821
821
Performs the operation __lt__.
822
822
"""
@@ -841,7 +841,7 @@ def __matmul__(self, other: Array, /) -> Array:
841
841
res = self ._array .__matmul__ (other ._array )
842
842
return self .__class__ ._new (res , device = self .device )
843
843
844
- def __mod__ (self , other : Array | int | float , / ) -> Array :
844
+ def __mod__ (self , other : Array | float , / ) -> Array :
845
845
"""
846
846
Performs the operation __mod__.
847
847
"""
@@ -853,7 +853,7 @@ def __mod__(self, other: Array | int | float, /) -> Array:
853
853
res = self ._array .__mod__ (other ._array )
854
854
return self .__class__ ._new (res , device = self .device )
855
855
856
- def __mul__ (self , other : Array | int | float | complex , / ) -> Array :
856
+ def __mul__ (self , other : Array | complex , / ) -> Array :
857
857
"""
858
858
Performs the operation __mul__.
859
859
"""
@@ -865,7 +865,7 @@ def __mul__(self, other: Array | int | float | complex, /) -> Array:
865
865
res = self ._array .__mul__ (other ._array )
866
866
return self .__class__ ._new (res , device = self .device )
867
867
868
- def __ne__ (self , other : Array | bool | int | float | complex , / ) -> Array : # type: ignore[override]
868
+ def __ne__ (self , other : Array | complex , / ) -> Array : # type: ignore[override]
869
869
"""
870
870
Performs the operation __ne__.
871
871
"""
@@ -886,7 +886,7 @@ def __neg__(self) -> Array:
886
886
res = self ._array .__neg__ ()
887
887
return self .__class__ ._new (res , device = self .device )
888
888
889
- def __or__ (self , other : Array | bool | int , / ) -> Array :
889
+ def __or__ (self , other : Array | int , / ) -> Array :
890
890
"""
891
891
Performs the operation __or__.
892
892
"""
@@ -907,7 +907,7 @@ def __pos__(self) -> Array:
907
907
res = self ._array .__pos__ ()
908
908
return self .__class__ ._new (res , device = self .device )
909
909
910
- def __pow__ (self , other : Array | int | float | complex , / ) -> Array :
910
+ def __pow__ (self , other : Array | complex , / ) -> Array :
911
911
"""
912
912
Performs the operation __pow__.
913
913
"""
@@ -944,7 +944,7 @@ def __setitem__(
944
944
| Array
945
945
| tuple [int | slice | EllipsisType , ...]
946
946
),
947
- value : Array | bool | int | float | complex ,
947
+ value : Array | complex ,
948
948
/ ,
949
949
) -> None :
950
950
"""
@@ -957,7 +957,7 @@ def __setitem__(
957
957
np_key = key ._array if isinstance (key , Array ) else key
958
958
self ._array .__setitem__ (np_key , asarray (value )._array )
959
959
960
- def __sub__ (self , other : Array | int | float | complex , / ) -> Array :
960
+ def __sub__ (self , other : Array | complex , / ) -> Array :
961
961
"""
962
962
Performs the operation __sub__.
963
963
"""
@@ -971,7 +971,7 @@ def __sub__(self, other: Array | int | float | complex, /) -> Array:
971
971
972
972
# PEP 484 requires int to be a subtype of float, but __truediv__ should
973
973
# not accept int.
974
- def __truediv__ (self , other : Array | int | float | complex , / ) -> Array :
974
+ def __truediv__ (self , other : Array | complex , / ) -> Array :
975
975
"""
976
976
Performs the operation __truediv__.
977
977
"""
@@ -983,7 +983,7 @@ def __truediv__(self, other: Array | int | float | complex, /) -> Array:
983
983
res = self ._array .__truediv__ (other ._array )
984
984
return self .__class__ ._new (res , device = self .device )
985
985
986
- def __xor__ (self , other : Array | bool | int , / ) -> Array :
986
+ def __xor__ (self , other : Array | int , / ) -> Array :
987
987
"""
988
988
Performs the operation __xor__.
989
989
"""
@@ -995,7 +995,7 @@ def __xor__(self, other: Array | bool | int, /) -> Array:
995
995
res = self ._array .__xor__ (other ._array )
996
996
return self .__class__ ._new (res , device = self .device )
997
997
998
- def __iadd__ (self , other : Array | int | float | complex , / ) -> Array :
998
+ def __iadd__ (self , other : Array | complex , / ) -> Array :
999
999
"""
1000
1000
Performs the operation __iadd__.
1001
1001
"""
@@ -1006,7 +1006,7 @@ def __iadd__(self, other: Array | int | float | complex, /) -> Array:
1006
1006
self ._array .__iadd__ (other ._array )
1007
1007
return self
1008
1008
1009
- def __radd__ (self , other : Array | int | float | complex , / ) -> Array :
1009
+ def __radd__ (self , other : Array | complex , / ) -> Array :
1010
1010
"""
1011
1011
Performs the operation __radd__.
1012
1012
"""
@@ -1018,7 +1018,7 @@ def __radd__(self, other: Array | int | float | complex, /) -> Array:
1018
1018
res = self ._array .__radd__ (other ._array )
1019
1019
return self .__class__ ._new (res , device = self .device )
1020
1020
1021
- def __iand__ (self , other : Array | bool | int , / ) -> Array :
1021
+ def __iand__ (self , other : Array | int , / ) -> Array :
1022
1022
"""
1023
1023
Performs the operation __iand__.
1024
1024
"""
@@ -1029,7 +1029,7 @@ def __iand__(self, other: Array | bool | int, /) -> Array:
1029
1029
self ._array .__iand__ (other ._array )
1030
1030
return self
1031
1031
1032
- def __rand__ (self , other : Array | bool | int , / ) -> Array :
1032
+ def __rand__ (self , other : Array | int , / ) -> Array :
1033
1033
"""
1034
1034
Performs the operation __rand__.
1035
1035
"""
@@ -1041,7 +1041,7 @@ def __rand__(self, other: Array | bool | int, /) -> Array:
1041
1041
res = self ._array .__rand__ (other ._array )
1042
1042
return self .__class__ ._new (res , device = self .device )
1043
1043
1044
- def __ifloordiv__ (self , other : Array | int | float , / ) -> Array :
1044
+ def __ifloordiv__ (self , other : Array | float , / ) -> Array :
1045
1045
"""
1046
1046
Performs the operation __ifloordiv__.
1047
1047
"""
@@ -1052,7 +1052,7 @@ def __ifloordiv__(self, other: Array | int | float, /) -> Array:
1052
1052
self ._array .__ifloordiv__ (other ._array )
1053
1053
return self
1054
1054
1055
- def __rfloordiv__ (self , other : Array | int | float , / ) -> Array :
1055
+ def __rfloordiv__ (self , other : Array | float , / ) -> Array :
1056
1056
"""
1057
1057
Performs the operation __rfloordiv__.
1058
1058
"""
@@ -1113,7 +1113,7 @@ def __rmatmul__(self, other: Array, /) -> Array:
1113
1113
res = self ._array .__rmatmul__ (other ._array )
1114
1114
return self .__class__ ._new (res , device = self .device )
1115
1115
1116
- def __imod__ (self , other : Array | int | float , / ) -> Array :
1116
+ def __imod__ (self , other : Array | float , / ) -> Array :
1117
1117
"""
1118
1118
Performs the operation __imod__.
1119
1119
"""
@@ -1123,7 +1123,7 @@ def __imod__(self, other: Array | int | float, /) -> Array:
1123
1123
self ._array .__imod__ (other ._array )
1124
1124
return self
1125
1125
1126
- def __rmod__ (self , other : Array | int | float , / ) -> Array :
1126
+ def __rmod__ (self , other : Array | float , / ) -> Array :
1127
1127
"""
1128
1128
Performs the operation __rmod__.
1129
1129
"""
@@ -1135,7 +1135,7 @@ def __rmod__(self, other: Array | int | float, /) -> Array:
1135
1135
res = self ._array .__rmod__ (other ._array )
1136
1136
return self .__class__ ._new (res , device = self .device )
1137
1137
1138
- def __imul__ (self , other : Array | int | float | complex , / ) -> Array :
1138
+ def __imul__ (self , other : Array | complex , / ) -> Array :
1139
1139
"""
1140
1140
Performs the operation __imul__.
1141
1141
"""
@@ -1145,7 +1145,7 @@ def __imul__(self, other: Array | int | float | complex, /) -> Array:
1145
1145
self ._array .__imul__ (other ._array )
1146
1146
return self
1147
1147
1148
- def __rmul__ (self , other : Array | int | float | complex , / ) -> Array :
1148
+ def __rmul__ (self , other : Array | complex , / ) -> Array :
1149
1149
"""
1150
1150
Performs the operation __rmul__.
1151
1151
"""
@@ -1157,7 +1157,7 @@ def __rmul__(self, other: Array | int | float | complex, /) -> Array:
1157
1157
res = self ._array .__rmul__ (other ._array )
1158
1158
return self .__class__ ._new (res , device = self .device )
1159
1159
1160
- def __ior__ (self , other : Array | bool | int , / ) -> Array :
1160
+ def __ior__ (self , other : Array | int , / ) -> Array :
1161
1161
"""
1162
1162
Performs the operation __ior__.
1163
1163
"""
@@ -1167,7 +1167,7 @@ def __ior__(self, other: Array | bool | int, /) -> Array:
1167
1167
self ._array .__ior__ (other ._array )
1168
1168
return self
1169
1169
1170
- def __ror__ (self , other : Array | bool | int , / ) -> Array :
1170
+ def __ror__ (self , other : Array | int , / ) -> Array :
1171
1171
"""
1172
1172
Performs the operation __ror__.
1173
1173
"""
@@ -1179,7 +1179,7 @@ def __ror__(self, other: Array | bool | int, /) -> Array:
1179
1179
res = self ._array .__ror__ (other ._array )
1180
1180
return self .__class__ ._new (res , device = self .device )
1181
1181
1182
- def __ipow__ (self , other : Array | int | float | complex , / ) -> Array :
1182
+ def __ipow__ (self , other : Array | complex , / ) -> Array :
1183
1183
"""
1184
1184
Performs the operation __ipow__.
1185
1185
"""
@@ -1189,7 +1189,7 @@ def __ipow__(self, other: Array | int | float | complex, /) -> Array:
1189
1189
self ._array .__ipow__ (other ._array )
1190
1190
return self
1191
1191
1192
- def __rpow__ (self , other : Array | int | float | complex , / ) -> Array :
1192
+ def __rpow__ (self , other : Array | complex , / ) -> Array :
1193
1193
"""
1194
1194
Performs the operation __rpow__.
1195
1195
"""
@@ -1224,7 +1224,7 @@ def __rrshift__(self, other: Array | int, /) -> Array:
1224
1224
res = self ._array .__rrshift__ (other ._array )
1225
1225
return self .__class__ ._new (res , device = self .device )
1226
1226
1227
- def __isub__ (self , other : Array | int | float | complex , / ) -> Array :
1227
+ def __isub__ (self , other : Array | complex , / ) -> Array :
1228
1228
"""
1229
1229
Performs the operation __isub__.
1230
1230
"""
@@ -1234,7 +1234,7 @@ def __isub__(self, other: Array | int | float | complex, /) -> Array:
1234
1234
self ._array .__isub__ (other ._array )
1235
1235
return self
1236
1236
1237
- def __rsub__ (self , other : Array | int | float | complex , / ) -> Array :
1237
+ def __rsub__ (self , other : Array | complex , / ) -> Array :
1238
1238
"""
1239
1239
Performs the operation __rsub__.
1240
1240
"""
@@ -1246,7 +1246,7 @@ def __rsub__(self, other: Array | int | float | complex, /) -> Array:
1246
1246
res = self ._array .__rsub__ (other ._array )
1247
1247
return self .__class__ ._new (res , device = self .device )
1248
1248
1249
- def __itruediv__ (self , other : Array | int | float | complex , / ) -> Array :
1249
+ def __itruediv__ (self , other : Array | complex , / ) -> Array :
1250
1250
"""
1251
1251
Performs the operation __itruediv__.
1252
1252
"""
@@ -1256,7 +1256,7 @@ def __itruediv__(self, other: Array | int | float | complex, /) -> Array:
1256
1256
self ._array .__itruediv__ (other ._array )
1257
1257
return self
1258
1258
1259
- def __rtruediv__ (self , other : Array | int | float | complex , / ) -> Array :
1259
+ def __rtruediv__ (self , other : Array | complex , / ) -> Array :
1260
1260
"""
1261
1261
Performs the operation __rtruediv__.
1262
1262
"""
@@ -1268,7 +1268,7 @@ def __rtruediv__(self, other: Array | int | float | complex, /) -> Array:
1268
1268
res = self ._array .__rtruediv__ (other ._array )
1269
1269
return self .__class__ ._new (res , device = self .device )
1270
1270
1271
- def __ixor__ (self , other : Array | bool | int , / ) -> Array :
1271
+ def __ixor__ (self , other : Array | int , / ) -> Array :
1272
1272
"""
1273
1273
Performs the operation __ixor__.
1274
1274
"""
@@ -1278,7 +1278,7 @@ def __ixor__(self, other: Array | bool | int, /) -> Array:
1278
1278
self ._array .__ixor__ (other ._array )
1279
1279
return self
1280
1280
1281
- def __rxor__ (self , other : Array | bool | int , / ) -> Array :
1281
+ def __rxor__ (self , other : Array | int , / ) -> Array :
1282
1282
"""
1283
1283
Performs the operation __rxor__.
1284
1284
"""
0 commit comments