[SciPy-user] Confused about enhanced-scalar dtypes

Travis Oliphant oliphant at ee.byu.edu
Fri Feb 24 18:17:05 CST 2006


LATORNELL, Doug wrote:

>I built NumPy from SVN this morning and got a surprise concerning dtype
>arguments:
>
>In [24]: import numpy
>
>In [25]: numpy.__version__
>Out[25]: '0.9.6.2165'
>
>In [26]: a = numpy.fromfile("profiles-O0", dtype="float", sep=' ')
>------------------------------------------------------------------------
>---
>exceptions.TypeError                                 Traceback (most
>recent call last)
>
>/ocean/dlatorne/SoG/dlatornell06/profiles/<ipython console> 
>
>TypeError: data type not understood
>  
>

I don't recommend using strings like "float".  Just use float (which is 
a type-object).

I don't think "float" is actually an accepted string.  There are a few 
strings that are recognized and more could be added, but I would just 
use dtype=float.

>Based on the tip in the middle of pg 19 of my copy of the NumPy book, I
>expected both dtype="float" and dtype="float_" to work.
>  
>
dtype=float and dtype=numpy.float_  are similar.  Note the absence of ""

>I know there has been a bunch of work lately on things related to dtype,
>but I don't recall seeing anything about breaking the equivalence of the
>enhanced-scalar types (like float_) and the corresponding standard
>Python types (float, in this case).  Did I miss, or misunderstand
>something, get unluck with the timing of my checkout this morning, or is
>this a bug?
>  
>
I'm surprised "float" worked before and then doesn't work now.  But, 
there have been enough changes between 0.9.3 and 0.9.5 that it's 
possible.   But, don't do it that way :-)

-Travis



More information about the SciPy-user mailing list