I have an 3D array that is a mask. Additionally, I have some indices that encode where (array position) some values should be saved.
Everything seems to be working fine, except that the output matrix is still empty after assigning the values to the desired positions.
I can not see what I am missing here. I have also tried numpy.put
with no luck.
import numpy as np
# Initialize output matrix (here the results will be stored)
results = np.zeros((67, 67, 45))
# define the mask - where to put the calculated values in the results array
mask = np.random.randint(2, size=(67, 67, 45)).astype(bool)
# store the results only in these positions
index_keep = range(0, 13732)
values = np.ones((13732,))
results[mask][index_keep] = values.copy()
# the results array is still empty
print(results.sum())
#0