MCPcopy
hub / github.com/dask/dask / test_tokenize_numpy_memmap

Function test_tokenize_numpy_memmap

dask/tests/test_tokenize.py:221–246  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

219
220@pytest.mark.skipif("not np")
221def test_tokenize_numpy_memmap():
222 with tmpfile(".npy") as fn:
223 x1 = np.arange(5)
224 np.save(fn, x1)
225 y = check_tokenize(np.load(fn, mmap_mode="r"))
226
227 with tmpfile(".npy") as fn:
228 x2 = np.arange(5)
229 np.save(fn, x2)
230 z = check_tokenize(np.load(fn, mmap_mode="r"))
231
232 assert check_tokenize(x1) == check_tokenize(x2)
233 assert y == z
234
235 with tmpfile(".npy") as fn:
236 x = np.random.normal(size=(10, 10))
237 np.save(fn, x)
238 mm = np.load(fn, mmap_mode="r")
239 mm2 = np.load(fn, mmap_mode="r")
240 a = check_tokenize(mm[0, :])
241 b = check_tokenize(mm[1, :])
242 c = check_tokenize(mm[0:3, :])
243 d = check_tokenize(mm[:, 0])
244 assert len({a, b, c, d}) == 4
245 assert check_tokenize(mm) == check_tokenize(mm2)
246 assert check_tokenize(mm[1, :]) == check_tokenize(mm2[1, :])
247
248
249@pytest.mark.skipif("not np")

Callers

nothing calls this directly

Calls 5

tmpfileFunction · 0.90
check_tokenizeFunction · 0.85
loadMethod · 0.80
arangeMethod · 0.45
normalMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…