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