np_to_af_array copy
selimyoussry opened this issue · comments
Selim Youssry commented
Hi everyone, the source code for "np_to_af_array" seems guaranteed to raise a RuntimeError("Copy can not be False for numpy arrays"), shouldn't it only be present in the "else" statement?
I'm thinking of this:
def np_to_af_array(np_arr, copy=True):
in_shape = np_arr.shape
in_ptr = np_arr.ctypes.data_as(c_void_ptr_t)
in_dtype = _nptype_to_aftype[np_arr.dtype.str[1:]]
if (np_arr.flags['F_CONTIGUOUS']):
return _fc_to_af_array(in_ptr, in_shape, in_dtype)
elif (np_arr.flags['C_CONTIGUOUS']):
return _cc_to_af_array(in_ptr, np_arr.ndim, in_shape, in_dtype)
else:
if not copy:
raise RuntimeError("Copy cannot be false if the data is not a single, Fortran-style (F_CONTIGUOUS flag) or C-style (C_CONTIGUOUS flag) contiguous segment")
return np_to_af_array(np_arr.copy())
instead of the current code
What do you think?
Thanks!
Pavan Yalamanchili commented
@selimyoussry copy should never be false. You can send in a PR to remove that option if you want to.