Skip to content

numpy.load() feature upgrade #644

@hamza-712

Description

@hamza-712

numpy.load() feature upgrade
Hi,
Can you please add a very useful feature of using memmap to load only a part of numpy array from a file?
For example

  1. Let's create a memory-mapped array in write mode:
import numpy as np
nrows, ncols = 1000000, 100
f = np.memmap('memmapped.dat', dtype=np.float32,
              mode='w+', shape=(nrows, ncols))
  1. Let's feed the array with random values, one column at a time because our system's memory is limited!
for i in range(ncols):
    f[:, i] = np.random.rand(nrows)
x = f[:, -1]
del

### READING

f = np.memmap('memmapped.dat', dtype=np.float32,
              shape=(nrows, ncols))
np.array_equal(f[:, -1], x)
True
del f

Additional context
(https://numpy.org/doc/stable/reference/generated/numpy.load.html)
like using numpy.memmap inside numpy.load()

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions