File tree Expand file tree Collapse file tree 1 file changed +12
-0
lines changed Expand file tree Collapse file tree 1 file changed +12
-0
lines changed Original file line number Diff line number Diff line change @@ -495,6 +495,18 @@ def to_list(self, row_major=False):
495
495
ct_array , shape = self .to_ctype (row_major , True )
496
496
return ctype_to_lists (ct_array , len (shape ) - 1 , shape )
497
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
+
498
510
def display (a ):
499
511
expr = inspect .stack ()[1 ][- 2 ]
500
512
if (expr is not None ):
You can’t perform that action at this time.
0 commit comments