[Numpy-discussion] silly user wish
Thu Jun 9 21:07:14 CDT 2011
On Thu, Jun 9, 2011 at 19:25, Paul Anton Letnes
> Dear numpy developers, users, and fans:
> I wish for a numpy that will magically detect all my errors. Barring the invention of a numpy version which knows what I need, not what I ask of it, I have the following, simpler wish: if one takes myarray.real or myarray.imag of a float (or possibly integer), give a warning saying "well that didn't make much sense, did it?".
> (Maybe there is some good reason why this is a bad idea, but the idea has been presented to you, nonetheless.)
Those attributes were explicitly added to all arrays (and numpy
scalars!) because it makes it easier to write generic complex
algorithms that will work correctly regardless of the dtype of the
input without dispatching to different code paths. There's a
reasonably large portion of complex algorithms that can be correctly
implemented for real arrays simply by implicitly assuming that the
imaginary component is all 0s.
If you happen to have an algorithm where passing a float array is more
likely an indicator of an error, you can do the check yourself.
"I have come to believe that the whole world is an enigma, a harmless
enigma that is made terrible by our own mad attempt to interpret it as
though it had an underlying truth."
-- Umberto Eco
More information about the NumPy-Discussion