Relative Content

Tag Archive for pythonnumpy

python numpy array index set extension

import numpy as np I = np.array([3,2,1,4,2]) x = np.linspace(0,1,10) y = np.empty(5) for i, j in enumerate(I): y[i] = x[j:].sum() This is a simplified version of the original code. The problem is that the length of I is larger, so using loop is costly. Is there any way to avoid loop here? I wish […]