On Tue, Sep 21, 2010 at 4:44 PM, Benjamin Root <[email protected]> wrote:

> On Tue, Sep 21, 2010 at 4:31 PM, Michael Gilbert <
> [email protected]> wrote:
>
>> Hi,
>>
>> The following example demonstrates a rather unexpected result:
>>
>> >>> import numpy
>> >>> x = numpy.array( complex( 1.0 , 1.0 ) , numpy.object )
>> >>> print x.real
>> (1+1j)
>> >>> print x.imag
>> 0
>>
>> Shouldn't real and imag return an error in such a situation?
>>
>> Thanks,
>> Mike
>>
>
> Don't use 'numpy.object'.  Because complex is a  numerical type, numpy can
> handle it just fine.  By setting dtype to numpy.object, numpy then treats it
> like an object rather than a numerical.
>
> x = numpy.array( complex(1.0, 1.0) )
>
> should work just fine.
>
> I hope that helps!
> Ben Root
>
>
I see that I have interpreted this thread as "Doctor, it hurts when I do
this...  Well, don't do that!"  Sorry for the noise.

Ben Root
_______________________________________________
NumPy-Discussion mailing list
[email protected]
http://mail.scipy.org/mailman/listinfo/numpy-discussion

Reply via email to