We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
2 parents a5394fe + 1e09d86 commit b4f589aCopy full SHA for b4f589a
1 file changed
arrayfire/array.py
@@ -495,6 +495,18 @@ def to_list(self, row_major=False):
495
ct_array, shape = self.to_ctype(row_major, True)
496
return ctype_to_lists(ct_array, len(shape) - 1, shape)
497
498
+ def __repr__(self):
499
+ # Having __repr__ directly print things is a bad idea
500
+ # Placeholder for when af_array_to_string is available
501
+ # safe_call(backend.get().af_array_to_string...
502
+ return '%s of dimensions %s' % (type(self), self.dims())
503
+
504
+ def __array__(self):
505
+ import numpy as np
506
+ res = np.empty(self.dims(), dtype=np.dtype(to_typecode[self.type()]), order='F')
507
+ safe_call(backend.get().af_get_data_ptr(ct.c_void_p(res.ctypes.data), self.arr))
508
+ return res
509
510
def display(a):
511
expr = inspect.stack()[1][-2]
512
if (expr is not None):
0 commit comments