|
From: Stephen W. <ste...@cs...> - 2005-01-31 18:40:23
|
I don't think the load function needs to be changed in the way you
suggest. The "problem" is not the load function. It is the fact that
numarray arrays are stored in row-major, not column-major, order, and so
tuple unpacking a numarray array goes by row, not by column.
In [15]: A=arange(6)
In [16]: A.shape=(3,2)
In [17]: x,y=A
---------------------------------------------------------------------------
exceptions.ValueError Traceback (most
recent call last)
ValueError: too many values to unpack
The transpose is required here as well if you want to unpack by
columns. If I have a file containing 731 rows and 17 columns and use
'load', I get an array with 731 rows and 17 columns, exactly as I expect.
I'm far from a Python expert myself ;-), but you can do what you're
trying with the single line
x,y=transpose(load('toto.dat')[:,1:3])
(note that array indexing in Python is zero-based, not one-based, and
also read up on how slices work).
|