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

Function from_npy_stack

dask/array/core.py:6122–6151  ·  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

6120
6121
6122def from_npy_stack(dirname, mmap_mode="r"):
6123 """Load dask array from stack of npy files
6124
6125 Parameters
6126 ----------
6127 dirname: string
6128 Directory of .npy files
6129 mmap_mode: (None or 'r')
6130 Read data in memory map mode
6131
6132 See Also
6133 --------
6134 to_npy_stack
6135 """
6136 with open(os.path.join(dirname, "info"), "rb") as f:
6137 info = pickle.load(f)
6138
6139 dtype = info["dtype"]
6140 chunks = info["chunks"]
6141 axis = info["axis"]
6142
6143 name = f"from-npy-stack-{dirname}"
6144 keys = list(product([name], *[range(len(c)) for c in chunks]))
6145 values = [
6146 (np.load, os.path.join(dirname, f"{i}.npy"), mmap_mode)
6147 for i in range(len(chunks[axis]))
6148 ]
6149 dsk = dict(zip(keys, values))
6150
6151 return Array(dsk, name, chunks, dtype)
6152
6153
6154def 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