2323from .dtypes import uint64 as af_uint64
2424
2525ShapeType = tuple [int , ...]
26- _bcast_var = False # HACK, TODO replace for actual bcast_var after refactoring
26+ # HACK, TODO replace for actual bcast_var after refactoring ~ https://github.com/arrayfire/arrayfire/pull/2871
27+ _bcast_var = False
28+
29+ # TODO use int | float in operators -> remove bool | complex support
2730
2831
2932@dataclass
@@ -33,12 +36,6 @@ class _ArrayBuffer:
3336
3437
3538class Array :
36- # Numpy checks this attribute to know which class handles binary builtin operations, such as __add__.
37- # Setting to such a high value should make sure that arrayfire has priority over
38- # other classes, ensuring that e.g. numpy.float32(1)*arrayfire.randu(3) is handled by
39- # arrayfire's __radd__() instead of numpy's __add__()
40- __array_priority__ = 30 # TODO discuss its purpose
41-
4239 def __init__ (
4340 self , x : None | Array | py_array .array | int | ctypes .c_void_p | list = None ,
4441 dtype : None | Dtype | str = None , shape : None | ShapeType = None ,
@@ -164,7 +161,6 @@ def __neg__(self) -> Array:
164161 return 0 - self # type: ignore[no-any-return, operator] # FIXME
165162
166163 def __add__ (self , other : int | float | Array , / ) -> Array :
167- # TODO discuss either we need to support complex and bool as other input type
168164 """
169165 Calculates the sum for each element of an array instance with the respective element of the array other.
170166
@@ -300,21 +296,13 @@ def __pow__(self, other: int | float | Array, /) -> Array:
300296 out : Array
301297 An array containing the element-wise results. The returned array must have a data type determined
302298 by Type Promotion Rules.
303-
304- Note
305- ----
306- - If both self and other have integer data types, the result of __pow__ when other_i is negative
307- (i.e., less than zero) is unspecified and thus implementation-dependent.
308- If self has an integer data type and other has a floating-point data type, behavior is
309- implementation-dependent, as type promotion between data type “kinds” (e.g., integer versus floating-point)
310- is unspecified.
311299 """
312300 return _process_c_function (self , other , backend .get ().af_pow )
313301
314302 # Array Operators
315303
316304 def __matmul__ (self , other : Array , / ) -> Array :
317- # TODO
305+ # TODO get from blas - make vanilla version and not copy af.matmul as is
318306 return NotImplemented
319307
320308 # Bitwise Operators
@@ -508,7 +496,7 @@ def __rfloordiv__(self, other: Array, /) -> Array:
508496
509497 def __rmod__ (self , other : Array , / ) -> Array :
510498 """
511- Return other / self.
499+ Return other % self.
512500 """
513501 return _process_c_function (other , self , backend .get ().af_mod )
514502
@@ -534,7 +522,7 @@ def __rand__(self, other: Array, /) -> Array:
534522
535523 def __ror__ (self , other : Array , / ) -> Array :
536524 """
537- Return other & self.
525+ Return other | self.
538526 """
539527 return _process_c_function (other , self , backend .get ().af_bitor )
540528
@@ -648,7 +636,7 @@ def __array_namespace__(self, *, api_version: None | str = None) -> Any:
648636 return NotImplemented
649637
650638 def __bool__ (self ) -> bool :
651- # TODO
639+ # TODO consider using scalar() and is_scalar()
652640 return NotImplemented
653641
654642 def __complex__ (self ) -> complex :
@@ -668,7 +656,7 @@ def __float__(self) -> float:
668656 return NotImplemented
669657
670658 def __getitem__ (self , key : int | slice | tuple [int | slice ] | Array , / ) -> Array :
671- # TODO: API Specification - key: int | slice | ellipsis | tuple[int | slice] | Array
659+ # TODO: API Specification - key: int | slice | ellipsis | tuple[int | slice] | Array - consider using af.span
672660 # TODO: refactor
673661 out = Array ()
674662 ndims = self .ndim
0 commit comments