I have source and destination numpy arrays, say
dest = np.arange(1000)
src = np.random(500)
I want to copy across the src to the dest array overwriting the first 50 numbers, then all the numbers starting at index 100 to 150, then from 200 to 250 and so on till 900 to 950.
To calculate the index I use the following:
index = np.reshape([100*i+np.arange(50) for i in range(10)],-1)
then I just use
dest[index]=src
to copy across the remaining elements (with another src, say src2), i just adust the index
index2 = np.reshape([50+100*i+np.arange(50) for i in range(10)],-1)
dest[index2]=src2
I'm pretty sure there's a more elegant/efficient way of achieving this without having to explicitly build the indexes.
Is there a better way to perform the copy?