Is this a bug or a feature?
import numpy as np
a=b=c=0
print 'a=',a
print 'b=',b
print 'c=',c
a = 5
print 'a=',a
print 'b=',b
print 'c=',c
b = 3
print 'a=',a
print 'b=',b
print 'c=',c
x=y=z=np.zeros(5)
print 'x=',x
print 'y=',y
print 'z=',z
x[2]= 10
print 'x=',x
print 'y=',y
print 'z=',z
y[3]= 20
print 'x=',x
print 'y=',y
print 'z=',z
The output of the code shows me that the numpy initializations are clones of each other while python tends to treat them as independent variable.
a= 0
b= 0
c= 0
a= 5
b= 0
c= 0
a= 5
b= 3
c= 0
x= [ 0. 0. 0. 0. 0.]
y= [ 0. 0. 0. 0. 0.]
z= [ 0. 0. 0. 0. 0.]
x= [ 0. 0. 10. 0. 0.]
y= [ 0. 0. 10. 0. 0.]
z= [ 0. 0. 10. 0. 0.]
x= [ 0. 0. 10. 20. 0.]
y= [ 0. 0. 10. 20. 0.]
z= [ 0. 0. 10. 20. 0.]
I hope the problem is clear. Is this a bug or a feature in numpy?
Regards