MCPcopy
hub / github.com/dask/dask / from_npy_stack

Function from_npy_stack

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

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

Used in the wild real call sites across dependent graphs

searching dependent graphs…