I have a problem assigning values to variables in Python
import numpy
a = numpy.empty((3,3,))
a[:] = numpy.NaN
a
b=a
b[numpy.isnan(b)]=1
upto the second-to-last line a and b are equal to NaN arrays:
>>> a
array([[ nan, nan, nan],
[ nan, nan, nan],
[ nan, nan, nan]])
>>> b
array([[ nan, nan, nan],
[ nan, nan, nan],
[ nan, nan, nan]])
but when the last statement is executed (i.e. b[numpy.isnan(b)]=1) both a and b become arrays of ones
>>> a
array([[ 1., 1., 1.],
[ 1., 1., 1.],
[ 1., 1., 1.]])
>>> b
array([[ 1., 1., 1.],
[ 1., 1., 1.],
[ 1., 1., 1.]])
how can I set array b to ones and array a to NaN. Note that I need to maintain the b=a statement