question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Resizing memmap arrays

See original GitHub issue

I’m referring to this discussion on stackoverflow. I’m trying to resize memmap arrays just as it works with ordinary arrays.

a = np.memmap('bla.bin', mode='w+', dtype=int, shape=10)
>>> memmap([0, 0, 0, 0, 0, 0, 0, 0, 0, 0])
a.resize(20, refcheck=False)
>>> ValueError: cannot resize this array: it does not own its data

I’m not sure about implications and side effects, but for me it looks like, if mmap supports resizing, np.memmap also should. I understand, that it might be hard to guarantee private access for a memmap. But if access can be excluded by the programmer, it should at least be possible to override any check by hand. And if resizing really shouldn’t be possible, at least the documentation could be clear about this point.

Issue Analytics

  • State:open
  • Created 10 years ago
  • Reactions:5
  • Comments:21 (5 by maintainers)

github_iconTop GitHub Comments

6reactions
ml31415commented, Jan 30, 2021

Any news about that stuff? It’s a while ago, but the issue remains, I guess.

3reactions
maciejkulacommented, Dec 25, 2014

I have the same problem. If this is not going to be addressed, perhaps the docs for http://docs.scipy.org/doc/numpy/reference/generated/numpy.memmap.resize.html should be amended? At the moment they strongly imply resizing memmaped arrays is something numpy supports in a very straightforward way.

Read more comments on GitHub >

github_iconTop Results From Across the Web

numpy.memmap.resize — NumPy v1.23 Manual
Change shape and size of array in-place. ... This reallocates space for the data area if necessary. Only contiguous arrays (data elements consecutive...
Read more >
Resizing numpy.memmap arrays - python - Stack Overflow
Resizing the underlying mmap buffer works perfectly fine. The problem is how to reflect these changes to the array object.
Read more >
numpy.memmap.resize
This reallocates space for the data area if necessary. Only contiguous arrays (data elements consecutive in memory) can be resized. The purpose of...
Read more >
[Solved]-Resize numpy.memmap inplace-numpy
Coding example for the question Resize numpy.memmap inplace-numpy. ... Try passing memmap a file object you load in a with block: with open('A_r.npy', ......
Read more >
class TempNumpyArrayFiles — Genome Contact Map Explorer
Update/resize all array files using given bigWig file ... array (numpy.memmap), where keys are chromosomes and values are respective numpy.memmap arrays.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found