-
-
Notifications
You must be signed in to change notification settings - Fork 12k
Closed
Description
I've translated some code we have from Python2 to Python3, and I think I've encountered a strange bug with np.fromfile. If I run the following code snippet:
import numpy as np
for mode in ['rb', 'rb+']:
with open('test.w', mode) as fid:
fid.read(2)
pos1 = fid.tell()
data = np.fromfile(fid, count=1)
pos2 = fid.tell()
print(pos1, pos2)
I get this output in Python2:
(2, 10)
(2, 10)
But this output in Python3:
2 12
2 10
This is not good, because subsequent reads from the file will not occur at correct positions. In other words, I have to add the + to the file open parameter in order to get multiple calls to fromfile to read with correct positions. I've uploaded the test file here in case someone wants to try to replicate:
I'm running Ubuntu Linux 13.10 64-bit. I had this problem on the system version, as well as on a version I just compiled myself (with MKL support).
Metadata
Metadata
Assignees
Labels
No labels