[NumPy-Tickets] [NumPy] #1566: fmt='%u' in savetxt behaves the same as '%d'.
NumPy Trac
numpy-tickets@scipy....
Wed Jul 28 17:41:13 CDT 2010
#1566: fmt='%u' in savetxt behaves the same as '%d'.
-------------------------+--------------------------------------------------
Reporter: rainwoodman | Owner: somebody
Type: defect | Status: new
Priority: normal | Milestone: 1.5.0
Component: Other | Version: 1.4.0
Keywords: |
-------------------------+--------------------------------------------------
According to the document of savetxt:
--------
``u`` : unsigned decimal integer
``x,X`` : unsigned hexadecimal integer
--------
However, the behavior is not as documented:
{{{
in [38]: print IDs[0:10]
-------> print(IDs[0:10])
[9223372043271415339 9223372043271415853 9223372043271415612
9223372043271416107 9223372043271415594 9223372043271415836
9223372043761290139 9223372044088967272 9223372044088967273
9223372043925949039]
In [26]: savetxt('/tmp/IDs', IDs, '%u')
In [27]: !head /tmp/IDs
-9223372030438136277
-9223372030438135763
-9223372030438136004
-9223372030438135509
-9223372030438136022
-9223372030438135780
-9223372029948261477
-9223372029620584344
-9223372029620584343
-9223372029783602577
}}}
The problem is on lib/io.py:1542,
{{{
fh.write(format % tuple(row) + '\n')
}}}
Apparently python doesn't support '%u' in the '%' operator.
{{{
In [44]: '%u', IDs[0]
Out[44]: ('%u', 9223372043271415339)
In [45]: print '%u' % IDs[0]
-------> print('%u' % IDs[0])
-9223372030438136277
}}}
Thus I don't see any easy fix for the problem. What is ironic is that
IDs[0] is however properly formatted by 'print'.
--
Ticket URL: <http://projects.scipy.org/numpy/ticket/1566>
NumPy <http://projects.scipy.org/numpy>
My example project
More information about the NumPy-Tickets
mailing list