MCPcopy Create free account
hub / github.com/dask/dask / from_npy_stack

Function from_npy_stack

dask/array/core.py:5922–5951  ·  view source on GitHub ↗

Load dask array from stack of npy files Parameters ---------- dirname: string Directory of .npy files mmap_mode: (None or 'r') Read data in memory map mode See Also -------- to_npy_stack

(dirname, mmap_mode="r")

Source from the content-addressed store, hash-verified

5920
5921
5922def from_npy_stack(dirname, mmap_mode="r"):
5923 """Load dask array from stack of npy files
5924
5925 Parameters
5926 ----------
5927 dirname: string
5928 Directory of .npy files
5929 mmap_mode: (None or 'r')
5930 Read data in memory map mode
5931
5932 See Also
5933 --------
5934 to_npy_stack
5935 """
5936 with open(os.path.join(dirname, "info"), "rb") as f:
5937 info = pickle.load(f)
5938
5939 dtype = info["dtype"]
5940 chunks = info["chunks"]
5941 axis = info["axis"]
5942
5943 name = "from-npy-stack-%s" % dirname
5944 keys = list(product([name], *[range(len(c)) for c in chunks]))
5945 values = [
5946 (np.load, os.path.join(dirname, "%d.npy" % i), mmap_mode)
5947 for i in range(len(chunks[axis]))
5948 ]
5949 dsk = dict(zip(keys, values))
5950
5951 return Array(dsk, name, chunks, dtype)
5952
5953
5954def new_da_object(dsk, name, chunks, meta=None, dtype=None):

Callers

nothing calls this directly

Calls 3

loadMethod · 0.80
ArrayClass · 0.70
joinMethod · 0.45

Tested by

no test coverage detected