#NUMPY
np_arr = np.arange(1,6)
np_ind = np.array([-1,-2,-3,-4,-5])
#DPT
dpt_arr = dpt.asarray(np_arr)
dpt_ind = dpt.asarray(np_ind)
np.take(np_arr,np_ind,mode='clip')
>> array([1, 1, 1, 1, 1])
dpt.take(dpt_arr,dpt_ind)
>> usm_ndarray([5, 4, 3, 2, 1])
# work with positive over indexes
dpt_ind = dpt.asarray([5,6,7,8,9])
dpt.take(dpt_arr,dpt_ind)
>> usm_ndarray([5, 5, 5, 5, 5])
When we pass negative indexes to
dpctl.takewithclipmod (default), it returns different array elements depending on the negative index.This is the wrong behavior.
clipmode means that all indices that are too large are replaced by the index that addresses the last element along that axis.Note that this disables indexing with negative numbers.