On Tue, Sep 21, 2010 at 4:31 PM, Michael Gilbert < michael.s.gilb...@gmail.com> 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
_______________________________________________ NumPy-Discussion mailing list NumPy-Discussion@scipy.org http://mail.scipy.org/mailman/listinfo/numpy-discussion