[Numpy-discussion] Assigning complex values to a real array
Stéfan van der Walt
Sat Mar 7 03:30:03 CST 2009
2009/3/7 Charles R Harris <firstname.lastname@example.org>:
>> a = np.zeros(6) # real
>> b= np.arange(6)*(2+3j) # complex
>> a = b # shouldn't this break?
>> What is the rationale behind this behaviour?
> The same as this:
> In : a = zeros(2)
> In : a = '1'
> In : a
> Out: array([ 1., 0.])
This difference is that, in your example, no information is lost.
When assigning a complex value to a real array, you are probably doing
More information about the Numpy-discussion