()
| 219 | |
| 220 | @pytest.mark.skipif("not np") |
| 221 | def 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") |
nothing calls this directly
no test coverage detected
searching dependent graphs…