I have the following placeholder array:
placeholder = np.zeros(10)
A contains the values that I want to go in to the placeholder
A = np.array([25, 40, 65,50])
idx has the indices of the placeholder ( note that this has the same shape as A)
idx = np.array([0, 5, 6, 8])
Question:
I want placeholder to be populated with the elements of A. The amount to which an element in A to be repeated is defined by the length of the intervals of the idx array.
For example, 25 is repeated 5 times because the corresponding index range is [0, 5). 65 is repeated twice because the corresponding index range is [6,8)
Expected output:
np.array([25, 25, 25, 25, 25, 40, 65, 65, 50, 50])