MCPcopy Index your code
hub / github.com/dask/dask / test_tokenize_numpy_memmap_offset

Function test_tokenize_numpy_memmap_offset

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

Source from the content-addressed store, hash-verified

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

Used in the wild real call sites across dependent graphs

searching dependent graphs…