[Numpy-discussion] Assigning complex value to real array

Pauli Virtanen pav@iki...
Thu Oct 7 17:17:27 CDT 2010


Thu, 07 Oct 2010 18:02:43 -0400, Andrew P. Mullhaupt wrote:
> On 10/7/2010 3:45 PM, josef.pktd@gmail.com wrote:
>> what's your namespace?from scipy import log
>>>>> log(int(-2))
>> (0.69314718055994529+3.1415926535897931j)
> 
> This should explain:
> >>> R = ones(2)
> >>> R[0] = R[0] * 1j
> >>> R
> array([ 0.,  1.])
[clip]

As Charles and Anne said:

> Newer versions of numpy will warn you that the imaginary part is 
> going to be discarded in your first example.

This will possibly be strengthened to an error or NaN in the future.



More information about the NumPy-Discussion mailing list