[SciPy-user] Data types

Travis Oliphant oliphant.travis at ieee.org
Mon Mar 6 01:44:35 CST 2006

Tony Mannucci wrote:
> Dear Scipy community,
> I cannot find a clear statement as to allowable data types, and how 
> these are specified. I am trying to read in an array using 
> read_array. One of the arguments of the function is "atype", to 
> specify the dtype of the output array. I cannot figure out what 
> format the tuple atype is in.
While SciPy builds for NumPy, it has not been "fully" adapted in that it 
still uses a lot of Numeric idioms for data-types. 

The read_array code is still using the old concept of "typecode" which 
is a one-character string (i.e. what dtype.char gives now).  

There may also still be bugs still in SciPy.  
> If Numpy is like Numeric, then, according to "Python In A Nutshell", 
> the array objects contain a single type. So, I cannot use several 
> values, I would specify only one value for atype. This seems to 
> differ from the scipy online documentation, suggesting atype could be 
> a tuple. I realize the functionality is evolving.
In this case, the functionality was there but might have become broken 
in the transition to NumPy (or the result of an old bug).  You should be 
able to specify a tuple for data-type.  Most SciPy functions that take 
data-types need to be made aware of the new concept of data type in NumPy.
> Along these lines, the following works:
> data = ARRIN.read_array('filename',columns=(0,2),atype='d')
> and appears to give a double precision array (as evidenced from 
> data.dtype.char = 'd'). However, using a few other strings for atype 
> does not work, e.g. 'I', or 'L', etc. 
What do you get as the error?

> Finally, the following does not seem to work:
> data = ARRIN.read_array('filename',columns=(2))
> so reading a single column appears to cause a problem. The following DOES work:
> data = ARRIN.read_array('filename',columns=(0,2))
It would be easiest if you opened a ticket and attached an example 
file.  Open tickets at




More information about the SciPy-user mailing list