# simple but difficult numpy memory reference problem

Advertisements import numpy as np a = np.array([0,0,0,0,0,0,0,0]) b = np.array([4,2,3]) c = np.array([5,5,2]) for i, e in enumerate(c): a[e] += b[i] print(a) # [0 0 3 0 0 6 0 0] a = np.array([0,0,0,0,0,0,0,0]) b = np.array([4,2,3]) c = np.array([5,5,2]) a[c] += b[np.arange(len(b))] print(a) # [0 0 3 0 0 2 0 0] The… Read More simple but difficult numpy memory reference problem