[AstroPy] question on matplotlib's loadtxt

Derek Homeier derek@astro.physik.uni-goettingen...
Fri Nov 4 11:57:55 CDT 2011


On 4 Nov 2011, at 17:19, Grigoris Maravelias wrote:

> In [23]: s,d = 
> 
> ---------------------------------------------------------------------------
> ValueError                                Traceback (most recent call last)
> 
> /home/.../<ipython console> in <module>()
> 
> ValueError: too many values to unpack
> 
> 
> 
> Derek, I checked the version of numpy and it is 1.3.0 - So I suppose it 
> should be due to the version only?
> 
I've checked with a version 1.2.1 and unpacking is definitely broken there - 
in your example, it would try to return something like 
np.array(('1496548.', 'tth*g')), np.array(('1690289.', 'hgf4')), which of course 
does not match your dtypes...
Try to upgrade; otherwise a workaround could be as I described

A = loadtxt('test.test', dtype=[('x','f8'),('y','f8')], usecols=[0,1])
x, y = A['x'], A['y']

Or you may indeed give genfromtxt a try, but I am not sure how far this had evolved 
as of 1.3.0 (coming to think of it, I believe it currently still has the same unpacking 
bug that is now fixed in loadtxt).

Cheers,
						Derek



More information about the AstroPy mailing list