@@ -36,7 +36,7 @@ class Array:
36
36
# Setting to such a high value should make sure that arrayfire has priority over
37
37
# other classes, ensuring that e.g. numpy.float32(1)*arrayfire.randu(3) is handled by
38
38
# arrayfire's __radd__() instead of numpy's __add__()
39
- __array_priority__ = 30
39
+ __array_priority__ = 30 # TODO discuss its purpose
40
40
41
41
def __init__ (
42
42
self ,x :None | Array | py_array .array | int | ctypes .c_void_p | list = None ,
@@ -286,25 +286,25 @@ def __radd__(self, other: Array, /) -> Array:
286
286
"""
287
287
Return other + self.
288
288
"""
289
- return _process_c_function (other , self ,backend .get ().af_add )
289
+ return _process_c_function (self , other ,backend .get ().af_add )
290
290
291
291
def __rsub__ (self ,other :Array ,/ )-> Array :
292
292
"""
293
293
Return other - self.
294
294
"""
295
- return _process_c_function (other , self ,backend .get ().af_sub )
295
+ return _process_c_function (self , other ,backend .get ().af_sub )
296
296
297
297
def __rmul__ (self ,other :Array ,/ )-> Array :
298
298
"""
299
299
Return other * self.
300
300
"""
301
- return _process_c_function (other , self ,backend .get ().af_mul )
301
+ return _process_c_function (self , other ,backend .get ().af_mul )
302
302
303
303
def __rtruediv__ (self ,other :Array ,/ )-> Array :
304
304
"""
305
305
Return other / self.
306
306
"""
307
- return _process_c_function (other , self ,backend .get ().af_div )
307
+ return _process_c_function (self , other ,backend .get ().af_div )
308
308
309
309
def __rfloordiv__ (self ,other :Array ,/ )-> Array :
310
310
# TODO
@@ -314,13 +314,13 @@ def __rmod__(self, other: Array, /) -> Array:
314
314
"""
315
315
Return other / self.
316
316
"""
317
- return _process_c_function (other , self ,backend .get ().af_mod )
317
+ return _process_c_function (self , other ,backend .get ().af_mod )
318
318
319
319
def __rpow__ (self ,other :Array ,/ )-> Array :
320
320
"""
321
321
Return other ** self.
322
322
"""
323
- return _process_c_function (other , self ,backend .get ().af_pow )
323
+ return _process_c_function (self , other ,backend .get ().af_pow )
324
324
325
325
# Reflected Array Operators
326
326
@@ -334,31 +334,31 @@ def __rand__(self, other: Array, /) -> Array:
334
334
"""
335
335
Return other & self.
336
336
"""
337
- return _process_c_function (other , self ,backend .get ().af_bitand )
337
+ return _process_c_function (self , other ,backend .get ().af_bitand )
338
338
339
339
def __ror__ (self ,other :Array ,/ )-> Array :
340
340
"""
341
341
Return other & self.
342
342
"""
343
- return _process_c_function (other , self ,backend .get ().af_bitor )
343
+ return _process_c_function (self , other ,backend .get ().af_bitor )
344
344
345
345
def __rxor__ (self ,other :Array ,/ )-> Array :
346
346
"""
347
347
Return other ^ self.
348
348
"""
349
- return _process_c_function (other , self ,backend .get ().af_bitxor )
349
+ return _process_c_function (self , other ,backend .get ().af_bitxor )
350
350
351
351
def __rlshift__ (self ,other :Array ,/ )-> Array :
352
352
"""
353
353
Return other << self.
354
354
"""
355
- return _process_c_function (other , self ,backend .get ().af_bitshiftl )
355
+ return _process_c_function (self , other ,backend .get ().af_bitshiftl )
356
356
357
357
def __rrshift__ (self ,other :Array ,/ )-> Array :
358
358
"""
359
359
Return other >> self.
360
360
"""
361
- return _process_c_function (other , self ,backend .get ().af_bitshiftr )
361
+ return _process_c_function (self , other ,backend .get ().af_bitshiftr )
362
362
363
363
# In-place Arithmetic Operators
364
364
@@ -617,6 +617,9 @@ def _process_c_function(
617
617
target :Array ,other :int | float | bool | complex | Array ,c_function :Any )-> Array :
618
618
out = Array ()
619
619
620
+ # TODO discuss the difference between binary_func and binary_funcr
621
+ # because implementation looks like exectly the same.
622
+ # consider chaging to __iadd__ = __radd__ = __add__ interfce if no difference
620
623
if isinstance (other ,Array ):
621
624
safe_call (c_function (ctypes .pointer (out .arr ),target .arr ,other .arr ,_bcast_var ))
622
625
elif is_number (other ):