[SciPy-user] Setting the real part of a complex array element
oliphant.travis at ieee.org
Sun Jan 15 17:01:08 CST 2006
Paul Ray wrote:
>I have some old code that tries to write to the real part of a
>complex array element, but the syntax now seems to fail in the new
>NumPy. Looking in the new NumPy book (section 3.1.3) , it appears
>that the .real attribute should be writable, but it does not seem to
>work. Does anyone know how to do this?
>In : import numpy
>In : numpy.__version__
>In : c = numpy.zeros(10,dtype=numpy.complex64)
>In : c.real = 1.0
c.real = 1.0
The problem is that
c is not an array it is a scalar. This would not have worked with
typecode='D' with Numeric either...
c.real = 1.0 will work.
More information about the SciPy-user