[Numpy-discussion] memmap, write through and flush
Tom Kuiper
kuiper@jpl.nasa....
Sat Aug 8 21:33:22 CDT 2009
There is something curious here. The second flush() fails. Can anyone
explain this?
Tom
------------------- code snippet ------------------------
...
# create a memmap with dtype and shape that matches the data
fp = np.memmap(filename, dtype='float32', mode='w+', shape=(3,4))
print "Initial memory mapped array (mode 'w+'):\n",fp
# write data to memmap array
fp[:] = data[:]
fp.flush()
# append a row to the array
fp = np.append(fp, [[12,13,14,15]], 0)
print "Filled memory mapped array:\n",fp
fp.flush()
...
----------------- output -----------------------
Filled memory mapped array:
[[ 0. 1. 2. 3.]
[ 4. 5. 6. 7.]
[ 8. 9. 10. 11.]
[ 12. 13. 14. 15.]]
---------------------------------------------------------------------------
AttributeError Traceback (most recent call last)
..../memmap_test.py in <module>()
21 fp = np.append(fp, [[12,13,14,15]], 0)
22 print "Filled memory mapped array:\n",fp
---> 23 fp.flush()
24
25 # deletion flushes memory changes to disk before removing the object
AttributeError: 'numpy.ndarray' object has no attribute 'flush'
WARNING: Failure executing file: <memmap_test.py>
More information about the NumPy-Discussion
mailing list