@@ -182,7 +182,7 @@ def _get_assign_dims(key, idims):
182182 elif isinstance (key , ParallelRange ):
183183 dims [0 ] = _slice_to_length (key .S , idims [0 ])
184184 return dims
185- elif isinstance (key , BaseArray ):
185+ elif isinstance (key , BaseArray ):
186186 # If the array is boolean take only the number of nonzeros
187187 if (key .dtype () is Dtype .b8 ):
188188 dims [0 ] = int (sum (key ))
@@ -1039,24 +1039,28 @@ def __array__(self):
10391039 safe_call (backend .get ().af_get_data_ptr (ct .c_void_p (res .ctypes .data ), self .arr ))
10401040 return res
10411041
1042- def display (a ):
1042+ def display (a , precision = 4 ):
10431043 """
10441044 Displays the contents of an array.
10451045
10461046 Parameters
10471047 ----------
10481048 a : af.Array
10491049 Multi dimensional arrayfire array
1050+ precision: int. optional.
1051+ Specifies the number of precision bits to display
10501052 """
10511053 expr = inspect .stack ()[1 ][- 2 ]
1054+ name = ""
10521055
10531056 try :
10541057 if (expr is not None ):
10551058 st = expr [0 ].find ('(' ) + 1
10561059 en = expr [0 ].rfind (')' )
1057- print ('%s' % expr [0 ][st :en ])
1058- safe_call (backend .get ().af_print_array (a .arr ))
1060+ name = expr [0 ][st :en ]
10591061 except :
1060- safe_call (backend .get ().af_print_array (a .arr ))
1062+ pass
1063+
1064+ safe_call (backend .get ().af_print_array_gen (name , a .arr , ct .c_int (precision )))
10611065
10621066from .algorithm import sum
0 commit comments