[Numpy-discussion] real and imag functions should produce errors for object arrays
Pauli Virtanen
pav at iki.fi
Tue Sep 21 18:40:00 EDT 2010
Tue, 21 Sep 2010 17:28:08 -0500, Robert Kern wrote:
[clip]
>> *that* == return a complex number from .real
>
> What is the alternative? I'm personally happy with saying that many of
> the operations we define on numpy arrays can be done because we know the
> types and that object arrays subvert this. numpy can't, without
> excessive amounts of magic, always know a sensible thing to do with
> object arrays, so we implement the fast thing to do.
As I see it, the alternatives are
1) Not to define .real and .imag for object arrays
2) Define them as elementwise .real and .imag
I don't clearly see the reason for
>>> x.real is x
True
>>> x.imag
array([0], dtype=object)
But it is a minor corner case, and there may be backward compatibility
issues in changing it.
--
Pauli Virtanen
More information about the NumPy-Discussion
mailing list