I was trying add ones to some specific position in a 100*100 zero matrix. My code was something this:
adjacency=[[0]*100]*100
while ...
x=...
y=...
adjacency[x][y]=adjacency[x][y]+1
But it adds to other positions as well. In face, adjacency[0]=adjacency[1]=..=adjacency[99], while there's no way that the calculation of x, y in while-loop will produce this kind of result.
So, I changed to array. The only thing I changed was:
adjacency=np.zeros((100,100))
And the result is right this time. Adjacency[i] no longer equals to each other.
Does anyone know why? (Using Python2.7.)