[Numpy-discussion] A question about dtype syntax
Pierre GM
pgmdevlist@gmail....
Wed Aug 31 09:02:06 CDT 2011
On Aug 31, 2011, at 3:40 PM, Jean-Baptiste Marquette wrote:
> Traceback (most recent call last):
> File "/Users/marquett/workspace/Distort/src/StatsSep.py", line 44, in <module>
> np.savetxt(Table, StatsAll, delimiter=' ', fmt=['%15s %.5f %.5f %5d %.4f %.4f'])
> File "/Library/Frameworks/EPD64.framework/Versions/7.1/lib/python2.7/site-packages/numpy/lib/npyio.py", line 979, in savetxt
> fh.write(asbytes(format % tuple(row) + newline))
> TypeError: not enough arguments for format string
Without knowing StatsAll, it ain't easy… From the exception message, we could expect that one of rows is empty or as less than the 6 elements required by your format string.
If you're using IPython, switch to debugger mode (pdb), then inspect row and format to find out the content of the offending line.
> I struggled with various unsuccessful fmt syntaxes, and the numpy doc is very discrete about that topic:
>
> fmt : string or sequence of strings
>
> A single format (%10.5f), a sequence of formats
Looks clear enough to me… But yes, a comment in the code shows that " `fmt` can be a string with multiple insertion points or a list of formats. E.g. '%10.5f\t%10d' or ('%10.5f', '$10d')" (so we should probably update the doc to this regard)
More information about the NumPy-Discussion
mailing list