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

Function test_tokenize_numpy_memmap_offset

dask/tests/test_tokenize.py:196–218  ·  view source on GitHub ↗
(tmpdir)

Source from the content-addressed store, hash-verified

194
195@pytest.mark.skipif("not np")
196def test_tokenize_numpy_memmap_offset(tmpdir):
197 # Test two different memmaps into the same numpy file
198 fn = str(tmpdir.join("demo_data"))
199
200 with open(fn, "wb") as f:
201 f.write(b"ashekwicht")
202
203 with open(fn, "rb") as f:
204 mmap1 = np.memmap(f, dtype=np.uint8, mode="r", offset=0, shape=5)
205 mmap2 = np.memmap(f, dtype=np.uint8, mode="r", offset=5, shape=5)
206 mmap3 = np.memmap(f, dtype=np.uint8, mode="r", offset=0, shape=5)
207 assert check_tokenize(mmap1) == check_tokenize(mmap1)
208 assert check_tokenize(mmap1) == check_tokenize(mmap3)
209 assert check_tokenize(mmap1) != check_tokenize(mmap2)
210 # also make sure that they tokenize correctly when taking sub-arrays
211 assert check_tokenize(mmap1[1:-1]) == check_tokenize(mmap1[1:-1])
212 assert check_tokenize(mmap1[1:-1]) == check_tokenize(mmap3[1:-1])
213 assert check_tokenize(mmap1[1:2]) == check_tokenize(mmap3[1:2])
214 assert check_tokenize(mmap1[1:2]) != check_tokenize(mmap1[1:3])
215 assert check_tokenize(mmap1[1:2]) != check_tokenize(mmap3[1:3])
216 sub1 = mmap1[1:-1]
217 sub2 = mmap2[1:-1]
218 assert check_tokenize(sub1) != check_tokenize(sub2)
219
220
221@pytest.mark.skipif("not np")

Callers

nothing calls this directly

Calls 2

check_tokenizeFunction · 0.85
joinMethod · 0.45

Tested by

no test coverage detected