[Numpy-discussion] help! type 'float64scalar' is not type 'float'

Sebastian Haase haase at msg.ucsf.edu
Wed Aug 2 23:31:38 CDT 2006


Hi!
I just finished maybe a total of 5 hours tracking down a nasty bug.
So I thought I would share this:
I'm keeping a version of (old) SciPy's 'plt' module around.
(I know about matplotlib - anyway - ...)
I changed the code some time ago from Numeric to numarray - no problem.
Now I switched to numpy ... and suddenly the zooming does not work 
anymore: it always zooms to "full view".

Finally I traced the problem down to a utility function:
"is_number" - it is simply implemented as
def is_number(val):
     return (type(val) in [type(0.0),type(0)])

As I said - now I finally saw that I always got
False since the type of my number (0.025) is
  <type 'float64scalar'>
and that's neither <type 'float'> nor <type 'int'>

OK - how should this have been done right ?

Anyway, I'm excited about the new numpy
and am looking forward to it's progress
Thanks,
Sebastian Haase




More information about the Numpy-discussion mailing list