[Numpy-discussion] float32 is not a float ?

Charles R Harris charlesr.harris@gmail....
Thu Apr 10 14:32:35 CDT 2008


On Thu, Apr 10, 2008 at 12:38 PM, Charles Doutriaux <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?


>
> 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.

Chuck
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://projects.scipy.org/pipermail/numpy-discussion/attachments/20080410/e7c3049c/attachment.html 


More information about the Numpy-discussion mailing list