[Numpy-discussion] float32 is not a float ?

Travis E. Oliphant oliphant@enthought....
Thu Apr 10 15:34:09 CDT 2008


Charles R Harris wrote:
>
>
> On Thu, Apr 10, 2008 at 12:38 PM, Charles Doutriaux 
> <doutriaux1@llnl.gov <mailto:doutriaux1@llnl.gov>> wrote:
>
>     Hello,
>
>     I guess this maybe "normal" but it breaks a lot of thing when
>     conterting
>     from Numeric
>
>      >>> a=numpy.ones(5,dtype=numpy.float32)
>      >>> isinstance(a[0],float)
>     False
>      >>>
>
>  
> It looks like float in this case is a python float, not a numpy float.
>  
>
>
>     float64 works...
>
>  
> It has the same underlying c type as the python float. Maybe it should 
> fail?

float64 does inherit from float so isinstance succeeds.

>  
>
>
>     I can see why one could argue for returning False, but then the
>     converter might be too zealous
>     things that used to work like:
>     if type(item) in [types.IntType, types.FloatType]:
>
>     or:
>
>      isinstance(item, types.FloatType)
>
>     now fail,
>
>
>  
>
>
>     should we be concerned? should we consider returning True ?
>
>
> I think you want the isreal function, but it will also return true for 
> complex with 0 imaginary part. Hmm... the various iswhatever functions 
> seem to be lacking in coverage. Maybe we should fix that.
We definitely could try and fix it. 



More information about the Numpy-discussion mailing list