ipython-books / cookbook-code

[DEPRECATED] See the new edition:

Home Page:http://ipython-books.github.io/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

np.memap won't work without mode parameter if the file does not exist yet (receipe 4.9)

rndblnch opened this issue · comments

the memory mapping exemple will only work if the file already exists.
to make it work regardless of that, it should have the mode parameter filled:

f = np.memmap('memmapped.dat', dtype=np.float32, mode='w+', shape=(nrows, ncols))

https://github.com/ipython-books/cookbook-code/blob/master/notebooks/chapter04_optimization/09_memmap.ipynb#L61

Thanks! PR welcome :)