@@ -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_type_device (self , other : Array | bool | int | float | complex ) -> None :
236
+ def _check_type_device (self , other : Array | complex ) -> None :
237
237
"""Check that other is either a Python scalar or an array on a device
238
238
compatible with the current array.
239
239
"""
@@ -245,7 +245,7 @@ def _check_type_device(self, other: Array | bool | int | float | complex) -> Non
245
245
raise TypeError (f"Expected Array or Python scalar; got { type (other )} " )
246
246
247
247
# Helper function to match the type promotion rules in the spec
248
- def _promote_scalar (self , scalar : bool | int | float | complex ) -> Array :
248
+ def _promote_scalar (self , scalar : complex ) -> Array :
249
249
"""
250
250
Returns a promoted version of a Python scalar appropriate for use with
251
251
operations on self.
@@ -539,7 +539,7 @@ def __abs__(self) -> Array:
539
539
res = self ._array .__abs__ ()
540
540
return self .__class__ ._new (res , device = self .device )
541
541
542
- def __add__ (self , other : Array | int | float | complex , / ) -> Array :
542
+ def __add__ (self , other : Array | complex , / ) -> Array :
543
543
"""
544
544
Performs the operation __add__.
545
545
"""
@@ -551,7 +551,7 @@ def __add__(self, other: Array | int | float | complex, /) -> Array:
551
551
res = self ._array .__add__ (other ._array )
552
552
return self .__class__ ._new (res , device = self .device )
553
553
554
- def __and__ (self , other : Array | bool | int , / ) -> Array :
554
+ def __and__ (self , other : Array | int , / ) -> Array :
555
555
"""
556
556
Performs the operation __and__.
557
557
"""
@@ -648,7 +648,7 @@ def __dlpack_device__(self) -> tuple[IntEnum, int]:
648
648
# Note: device support is required for this
649
649
return self ._array .__dlpack_device__ ()
650
650
651
- def __eq__ (self , other : Array | bool | int | float | complex , / ) -> Array : # type: ignore[override]
651
+ def __eq__ (self , other : Array | complex , / ) -> Array : # type: ignore[override]
652
652
"""
653
653
Performs the operation __eq__.
654
654
"""
@@ -674,7 +674,7 @@ def __float__(self) -> float:
674
674
res = self ._array .__float__ ()
675
675
return res
676
676
677
- def __floordiv__ (self , other : Array | int | float , / ) -> Array :
677
+ def __floordiv__ (self , other : Array | float , / ) -> Array :
678
678
"""
679
679
Performs the operation __floordiv__.
680
680
"""
@@ -686,7 +686,7 @@ def __floordiv__(self, other: Array | int | float, /) -> Array:
686
686
res = self ._array .__floordiv__ (other ._array )
687
687
return self .__class__ ._new (res , device = self .device )
688
688
689
- def __ge__ (self , other : Array | int | float , / ) -> Array :
689
+ def __ge__ (self , other : Array | float , / ) -> Array :
690
690
"""
691
691
Performs the operation __ge__.
692
692
"""
@@ -738,7 +738,7 @@ def __getitem__(
738
738
res = self ._array .__getitem__ (np_key )
739
739
return self ._new (res , device = self .device )
740
740
741
- def __gt__ (self , other : Array | int | float , / ) -> Array :
741
+ def __gt__ (self , other : Array | float , / ) -> Array :
742
742
"""
743
743
Performs the operation __gt__.
744
744
"""
@@ -793,7 +793,7 @@ def __iter__(self) -> Iterator[Array]:
793
793
# implemented, which implies iteration on 1-D arrays.
794
794
return (Array ._new (i , device = self .device ) for i in self ._array )
795
795
796
- def __le__ (self , other : Array | int | float , / ) -> Array :
796
+ def __le__ (self , other : Array | float , / ) -> Array :
797
797
"""
798
798
Performs the operation __le__.
799
799
"""
@@ -817,7 +817,7 @@ def __lshift__(self, other: Array | int, /) -> Array:
817
817
res = self ._array .__lshift__ (other ._array )
818
818
return self .__class__ ._new (res , device = self .device )
819
819
820
- def __lt__ (self , other : Array | int | float , / ) -> Array :
820
+ def __lt__ (self , other : Array | float , / ) -> Array :
821
821
"""
822
822
Performs the operation __lt__.
823
823
"""
@@ -842,7 +842,7 @@ def __matmul__(self, other: Array, /) -> Array:
842
842
res = self ._array .__matmul__ (other ._array )
843
843
return self .__class__ ._new (res , device = self .device )
844
844
845
- def __mod__ (self , other : Array | int | float , / ) -> Array :
845
+ def __mod__ (self , other : Array | float , / ) -> Array :
846
846
"""
847
847
Performs the operation __mod__.
848
848
"""
@@ -854,7 +854,7 @@ def __mod__(self, other: Array | int | float, /) -> Array:
854
854
res = self ._array .__mod__ (other ._array )
855
855
return self .__class__ ._new (res , device = self .device )
856
856
857
- def __mul__ (self , other : Array | int | float | complex , / ) -> Array :
857
+ def __mul__ (self , other : Array | complex , / ) -> Array :
858
858
"""
859
859
Performs the operation __mul__.
860
860
"""
@@ -866,7 +866,7 @@ def __mul__(self, other: Array | int | float | complex, /) -> Array:
866
866
res = self ._array .__mul__ (other ._array )
867
867
return self .__class__ ._new (res , device = self .device )
868
868
869
- def __ne__ (self , other : Array | bool | int | float | complex , / ) -> Array : # type: ignore[override]
869
+ def __ne__ (self , other : Array | complex , / ) -> Array : # type: ignore[override]
870
870
"""
871
871
Performs the operation __ne__.
872
872
"""
@@ -887,7 +887,7 @@ def __neg__(self) -> Array:
887
887
res = self ._array .__neg__ ()
888
888
return self .__class__ ._new (res , device = self .device )
889
889
890
- def __or__ (self , other : Array | bool | int , / ) -> Array :
890
+ def __or__ (self , other : Array | int , / ) -> Array :
891
891
"""
892
892
Performs the operation __or__.
893
893
"""
@@ -908,7 +908,7 @@ def __pos__(self) -> Array:
908
908
res = self ._array .__pos__ ()
909
909
return self .__class__ ._new (res , device = self .device )
910
910
911
- def __pow__ (self , other : Array | int | float | complex , / ) -> Array :
911
+ def __pow__ (self , other : Array | complex , / ) -> Array :
912
912
"""
913
913
Performs the operation __pow__.
914
914
"""
@@ -945,7 +945,7 @@ def __setitem__(
945
945
| Array
946
946
| tuple [int | slice | EllipsisType , ...]
947
947
),
948
- value : Array | bool | int | float | complex ,
948
+ value : Array | complex ,
949
949
/ ,
950
950
) -> None :
951
951
"""
@@ -958,7 +958,7 @@ def __setitem__(
958
958
np_key = key ._array if isinstance (key , Array ) else key
959
959
self ._array .__setitem__ (np_key , asarray (value )._array )
960
960
961
- def __sub__ (self , other : Array | int | float | complex , / ) -> Array :
961
+ def __sub__ (self , other : Array | complex , / ) -> Array :
962
962
"""
963
963
Performs the operation __sub__.
964
964
"""
@@ -972,7 +972,7 @@ def __sub__(self, other: Array | int | float | complex, /) -> Array:
972
972
973
973
# PEP 484 requires int to be a subtype of float, but __truediv__ should
974
974
# not accept int.
975
- def __truediv__ (self , other : Array | int | float | complex , / ) -> Array :
975
+ def __truediv__ (self , other : Array | complex , / ) -> Array :
976
976
"""
977
977
Performs the operation __truediv__.
978
978
"""
@@ -984,7 +984,7 @@ def __truediv__(self, other: Array | int | float | complex, /) -> Array:
984
984
res = self ._array .__truediv__ (other ._array )
985
985
return self .__class__ ._new (res , device = self .device )
986
986
987
- def __xor__ (self , other : Array | bool | int , / ) -> Array :
987
+ def __xor__ (self , other : Array | int , / ) -> Array :
988
988
"""
989
989
Performs the operation __xor__.
990
990
"""
@@ -996,7 +996,7 @@ def __xor__(self, other: Array | bool | int, /) -> Array:
996
996
res = self ._array .__xor__ (other ._array )
997
997
return self .__class__ ._new (res , device = self .device )
998
998
999
- def __iadd__ (self , other : Array | int | float | complex , / ) -> Array :
999
+ def __iadd__ (self , other : Array | complex , / ) -> Array :
1000
1000
"""
1001
1001
Performs the operation __iadd__.
1002
1002
"""
@@ -1007,7 +1007,7 @@ def __iadd__(self, other: Array | int | float | complex, /) -> Array:
1007
1007
self ._array .__iadd__ (other ._array )
1008
1008
return self
1009
1009
1010
- def __radd__ (self , other : Array | int | float | complex , / ) -> Array :
1010
+ def __radd__ (self , other : Array | complex , / ) -> Array :
1011
1011
"""
1012
1012
Performs the operation __radd__.
1013
1013
"""
@@ -1019,7 +1019,7 @@ def __radd__(self, other: Array | int | float | complex, /) -> Array:
1019
1019
res = self ._array .__radd__ (other ._array )
1020
1020
return self .__class__ ._new (res , device = self .device )
1021
1021
1022
- def __iand__ (self , other : Array | bool | int , / ) -> Array :
1022
+ def __iand__ (self , other : Array | int , / ) -> Array :
1023
1023
"""
1024
1024
Performs the operation __iand__.
1025
1025
"""
@@ -1030,7 +1030,7 @@ def __iand__(self, other: Array | bool | int, /) -> Array:
1030
1030
self ._array .__iand__ (other ._array )
1031
1031
return self
1032
1032
1033
- def __rand__ (self , other : Array | bool | int , / ) -> Array :
1033
+ def __rand__ (self , other : Array | int , / ) -> Array :
1034
1034
"""
1035
1035
Performs the operation __rand__.
1036
1036
"""
@@ -1042,7 +1042,7 @@ def __rand__(self, other: Array | bool | int, /) -> Array:
1042
1042
res = self ._array .__rand__ (other ._array )
1043
1043
return self .__class__ ._new (res , device = self .device )
1044
1044
1045
- def __ifloordiv__ (self , other : Array | int | float , / ) -> Array :
1045
+ def __ifloordiv__ (self , other : Array | float , / ) -> Array :
1046
1046
"""
1047
1047
Performs the operation __ifloordiv__.
1048
1048
"""
@@ -1053,7 +1053,7 @@ def __ifloordiv__(self, other: Array | int | float, /) -> Array:
1053
1053
self ._array .__ifloordiv__ (other ._array )
1054
1054
return self
1055
1055
1056
- def __rfloordiv__ (self , other : Array | int | float , / ) -> Array :
1056
+ def __rfloordiv__ (self , other : Array | float , / ) -> Array :
1057
1057
"""
1058
1058
Performs the operation __rfloordiv__.
1059
1059
"""
@@ -1114,7 +1114,7 @@ def __rmatmul__(self, other: Array, /) -> Array:
1114
1114
res = self ._array .__rmatmul__ (other ._array )
1115
1115
return self .__class__ ._new (res , device = self .device )
1116
1116
1117
- def __imod__ (self , other : Array | int | float , / ) -> Array :
1117
+ def __imod__ (self , other : Array | float , / ) -> Array :
1118
1118
"""
1119
1119
Performs the operation __imod__.
1120
1120
"""
@@ -1124,7 +1124,7 @@ def __imod__(self, other: Array | int | float, /) -> Array:
1124
1124
self ._array .__imod__ (other ._array )
1125
1125
return self
1126
1126
1127
- def __rmod__ (self , other : Array | int | float , / ) -> Array :
1127
+ def __rmod__ (self , other : Array | float , / ) -> Array :
1128
1128
"""
1129
1129
Performs the operation __rmod__.
1130
1130
"""
@@ -1136,7 +1136,7 @@ def __rmod__(self, other: Array | int | float, /) -> Array:
1136
1136
res = self ._array .__rmod__ (other ._array )
1137
1137
return self .__class__ ._new (res , device = self .device )
1138
1138
1139
- def __imul__ (self , other : Array | int | float | complex , / ) -> Array :
1139
+ def __imul__ (self , other : Array | complex , / ) -> Array :
1140
1140
"""
1141
1141
Performs the operation __imul__.
1142
1142
"""
@@ -1146,7 +1146,7 @@ def __imul__(self, other: Array | int | float | complex, /) -> Array:
1146
1146
self ._array .__imul__ (other ._array )
1147
1147
return self
1148
1148
1149
- def __rmul__ (self , other : Array | int | float | complex , / ) -> Array :
1149
+ def __rmul__ (self , other : Array | complex , / ) -> Array :
1150
1150
"""
1151
1151
Performs the operation __rmul__.
1152
1152
"""
@@ -1158,7 +1158,7 @@ def __rmul__(self, other: Array | int | float | complex, /) -> Array:
1158
1158
res = self ._array .__rmul__ (other ._array )
1159
1159
return self .__class__ ._new (res , device = self .device )
1160
1160
1161
- def __ior__ (self , other : Array | bool | int , / ) -> Array :
1161
+ def __ior__ (self , other : Array | int , / ) -> Array :
1162
1162
"""
1163
1163
Performs the operation __ior__.
1164
1164
"""
@@ -1168,7 +1168,7 @@ def __ior__(self, other: Array | bool | int, /) -> Array:
1168
1168
self ._array .__ior__ (other ._array )
1169
1169
return self
1170
1170
1171
- def __ror__ (self , other : Array | bool | int , / ) -> Array :
1171
+ def __ror__ (self , other : Array | int , / ) -> Array :
1172
1172
"""
1173
1173
Performs the operation __ror__.
1174
1174
"""
@@ -1180,7 +1180,7 @@ def __ror__(self, other: Array | bool | int, /) -> Array:
1180
1180
res = self ._array .__ror__ (other ._array )
1181
1181
return self .__class__ ._new (res , device = self .device )
1182
1182
1183
- def __ipow__ (self , other : Array | int | float | complex , / ) -> Array :
1183
+ def __ipow__ (self , other : Array | complex , / ) -> Array :
1184
1184
"""
1185
1185
Performs the operation __ipow__.
1186
1186
"""
@@ -1190,7 +1190,7 @@ def __ipow__(self, other: Array | int | float | complex, /) -> Array:
1190
1190
self ._array .__ipow__ (other ._array )
1191
1191
return self
1192
1192
1193
- def __rpow__ (self , other : Array | int | float | complex , / ) -> Array :
1193
+ def __rpow__ (self , other : Array | complex , / ) -> Array :
1194
1194
"""
1195
1195
Performs the operation __rpow__.
1196
1196
"""
@@ -1225,7 +1225,7 @@ def __rrshift__(self, other: Array | int, /) -> Array:
1225
1225
res = self ._array .__rrshift__ (other ._array )
1226
1226
return self .__class__ ._new (res , device = self .device )
1227
1227
1228
- def __isub__ (self , other : Array | int | float | complex , / ) -> Array :
1228
+ def __isub__ (self , other : Array | complex , / ) -> Array :
1229
1229
"""
1230
1230
Performs the operation __isub__.
1231
1231
"""
@@ -1235,7 +1235,7 @@ def __isub__(self, other: Array | int | float | complex, /) -> Array:
1235
1235
self ._array .__isub__ (other ._array )
1236
1236
return self
1237
1237
1238
- def __rsub__ (self , other : Array | int | float | complex , / ) -> Array :
1238
+ def __rsub__ (self , other : Array | complex , / ) -> Array :
1239
1239
"""
1240
1240
Performs the operation __rsub__.
1241
1241
"""
@@ -1247,7 +1247,7 @@ def __rsub__(self, other: Array | int | float | complex, /) -> Array:
1247
1247
res = self ._array .__rsub__ (other ._array )
1248
1248
return self .__class__ ._new (res , device = self .device )
1249
1249
1250
- def __itruediv__ (self , other : Array | int | float | complex , / ) -> Array :
1250
+ def __itruediv__ (self , other : Array | complex , / ) -> Array :
1251
1251
"""
1252
1252
Performs the operation __itruediv__.
1253
1253
"""
@@ -1257,7 +1257,7 @@ def __itruediv__(self, other: Array | int | float | complex, /) -> Array:
1257
1257
self ._array .__itruediv__ (other ._array )
1258
1258
return self
1259
1259
1260
- def __rtruediv__ (self , other : Array | int | float | complex , / ) -> Array :
1260
+ def __rtruediv__ (self , other : Array | complex , / ) -> Array :
1261
1261
"""
1262
1262
Performs the operation __rtruediv__.
1263
1263
"""
@@ -1269,7 +1269,7 @@ def __rtruediv__(self, other: Array | int | float | complex, /) -> Array:
1269
1269
res = self ._array .__rtruediv__ (other ._array )
1270
1270
return self .__class__ ._new (res , device = self .device )
1271
1271
1272
- def __ixor__ (self , other : Array | bool | int , / ) -> Array :
1272
+ def __ixor__ (self , other : Array | int , / ) -> Array :
1273
1273
"""
1274
1274
Performs the operation __ixor__.
1275
1275
"""
@@ -1279,7 +1279,7 @@ def __ixor__(self, other: Array | bool | int, /) -> Array:
1279
1279
self ._array .__ixor__ (other ._array )
1280
1280
return self
1281
1281
1282
- def __rxor__ (self , other : Array | bool | int , / ) -> Array :
1282
+ def __rxor__ (self , other : Array | int , / ) -> Array :
1283
1283
"""
1284
1284
Performs the operation __rxor__.
1285
1285
"""
0 commit comments