Skip to content

Commit 5ddeb97

Browse files
FilipeMaiapavanky
authored andcommitted
Ensure arrayfire is called in infix operations with numpy
1 parent b2a2efe commit 5ddeb97

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

arrayfire/array.py

+6
Original file line numberDiff line numberDiff line change
@@ -373,6 +373,12 @@ class Array(BaseArray):
373373
374374
"""
375375

376+
# Numpy checks this attribute to know which class handles binary builtin operations, such as __add__.
377+
# Setting to such a high value should make sure that arrayfire has priority over
378+
# other classes, ensuring that e.g. numpy.float32(1)*arrayfire.randu(3) is handled by
379+
# arrayfire's __radd__() instead of numpy's __add__()
380+
__array_priority__ = 30
381+
376382
def __init__(self, src=None, dims=(0,), dtype=None, is_device=False, offset=None, strides=None):
377383

378384
super(Array, self).__init__()

0 commit comments

Comments
 (0)