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

Function test_tokenize_numpy_memmap

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

Source from the content-addressed store, hash-verified

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