[Numpy-discussion] Nasty bug using pre-initialized arrays
Sat Jan 5 06:25:14 CST 2008
>> I wasn't at all arguing that having complex data chopped and
>> downcast into an int or float container was the right thing to do.
> indeed, it is an clearly bad thing to do -- but a bug magnet? I'm not so
> sure, surely, anyone that had any idea at all what they were doing with
> complex numbers would notice it right away.
> To the OP: Did you waste any time thinking this was working right? Or
> was your time spent figuring out why numpy wold do such a thing? which
> is wasted time none the less.
Thanks for the question. I spent about 1/2 hour looking at my other
code trying to figure out why I was getting strange results. Of
course, I suspected my own code to be the culpret, since NumPy is a
mature package, right?.
Then, when I looked closely at the return array given by NumPy, I
noticed that it was real, when I was working with complex numbers. I
said to myself "WTF?". Then a little more investigating revealed that
NumPy was silently truncating my complex array to real.
I respectfully submit that silently chopping the imaginary part *is* a
magnet for bugs, since many dumb NumPy users (like me) aren't
necessarily aware of the typecasting rules. We're only thinking about
doing math, after all!
Interactive Supercomputing, inc.
135 Beaver Street | Waltham | MA | 02452 | USA
More information about the Numpy-discussion