[Numpy-discussion] real and imag functions should produce errors for object arrays
Tue Sep 21 17:23:08 CDT 2010
On Tue, Sep 21, 2010 at 4:44 PM, Benjamin Root <firstname.lastname@example.org> wrote:
> On Tue, Sep 21, 2010 at 4:31 PM, Michael Gilbert <
> email@example.com> wrote:
>> The following example demonstrates a rather unexpected result:
>> >>> import numpy
>> >>> x = numpy.array( complex( 1.0 , 1.0 ) , numpy.object )
>> >>> print x.real
>> >>> print x.imag
>> Shouldn't real and imag return an error in such a situation?
> 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.
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the NumPy-Discussion