[Numpy-discussion] can savetxt write arrays with ndim > 2 ?

Mark Bakker markbak at gmail.com
Tue Sep 28 04:26:28 EDT 2010


Hello list,

I tried to savetxt an array with ndim = 3, but I get an error:

In [252]: savetxt('test.dat',a)

/Library/Frameworks/Python.framework/Versions/6.2/lib/python2.6/site-packages/numpy/lib/io.py
in savetxt(fname, X, fmt, delimiter)
    784
    785     for row in X:
--> 786         fh.write(format % tuple(row) + '\n')
    787
    788 import re

TypeError: float argument required, not numpy.ndarray

I don't see this anywhere in the documentation of savetxt. And if that is a
restriction it should probably be caught with an assertion.

Numpy version 1.4.0.
I see why ndim>2 may cause problems, as there is now way on 'loadtxt' to
figure out the shape of the array, but I think it should throw an assertion
and the documentation should be updated.

Thanks, Mark
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/numpy-discussion/attachments/20100928/9cbb9728/attachment.html>


More information about the NumPy-Discussion mailing list