[Numpy-discussion] Handling methods of object-arrays

Stéfan van der Walt stefan@sun.ac...
Tue Jan 6 03:15:45 CST 2009

Hi all,

What is the exact protocol for evaluating functions like "real" and
"imag" on object arrays?

For example, I'm looking at

x  = np.array([np.array(3+1j), np.array(4+1j)], dtype=object)

For which both

In [4]: x.real
Out[4]: array([(3+1j), (4+1j)], dtype=object)


In [6]: np.real(x)
Out[6]: array([(3+1j), (4+1j)], dtype=object)

does nothing, so that I have to do

In [8]: [np.real(e) for e in x]
Out[8]: [array(3.0), array(4.0)]

or [e.real for e in x].

Would it make sense make np.real aware of the above scenario?


More information about the Numpy-discussion mailing list