While studying the NumPy package of Python, I tried the following code segment
import numpy as np
x = np.array([[1,2,3],[4,5,6],[7,8,9],[10,11,12]])
v = np.array([1,0,1])
y = np.empty_like(x)
print(y)
for i in range(4):
y[i,:] = x[i,:]+v
print "......."
print(y)
However, the first print(y) gives the output such as following, instead of all zero array. On the other side, the second print(y)generates the correct result as expected. I would like to know why.
[[ 72 0 0]
[ 0 2676 1346720256]
[1599357253 1950699087 10]
[1346524499 1163154497 242503250]]
.......
[[ 2 2 4]
[ 5 5 7]
[ 8 8 10]
[11 11 13]]