Using Matlab you can modify an array from indices using vectorization :
A = [1, 2, 3, 4, 5, 6, 7, 8, 9]
Output :
A =
1 2 3 4 5 6 7 8 9
Modifying :
A([2,4,6:9]) = -1
Output :
A =
1 -1 3 -1 5 -1 -1 -1 -1
How can we do that using Numpy Python ?
A[np.r_[1,3,5:8]]=-1?np.r_is doing the same thing as MATLAB[2,4,6:9], expanding and concatenating to create an array of individual indices. MATLAB wraps a lot of functionality in that[...]syntax. In python that syntax is restricted to lists and indexing (which is whatr_is 'pretending' to do!).