[Numpy-tickets] [NumPy] #436: a[::-1].tofile(f) creates junk

NumPy numpy-tickets at scipy.net
Sat Jan 27 07:30:31 CST 2007


#436: a[::-1].tofile(f)  creates junk
----------------------+-----------------------------------------------------
 Reporter:  sebhaase  |        Owner:  somebody
     Type:  defect    |       Status:  new     
 Priority:  normal    |    Milestone:          
Component:  Other     |      Version:          
 Severity:  normal    |   Resolution:          
 Keywords:            |  
----------------------+-----------------------------------------------------
Comment (by stefan):

 What do you you get when you run the following code snippet?

 {{{
 import numpy as N

 x = N.arange(16).astype(N.uint16)

 f = file('test.dat','wb')
 hdr = 'x'*1024
 f.write(hdr)
 x[::-1].tofile(f)
 f.close()

 f = file('test.dat')
 f.seek(1024)
 x_ = N.fromfile(f,N.uint16)

 print x[::-1]
 print x_
 }}}

 I see

 {{{
 [15 14 13 12 11 10  9  8  7  6  5  4  3  2  1  0]
 [15 14 13 12 11 10  9  8  7  6  5  4  3  2  1  0]
 }}}

 with r3511.

-- 
Ticket URL: <http://projects.scipy.org/scipy/numpy/ticket/436#comment:1>
NumPy <http://projects.scipy.org/scipy/numpy>
The fundamental package needed for scientific computing with Python.


More information about the Numpy-tickets mailing list