MCPcopy Create free account
hub / github.com/numpy/numpy / test_save_load_memmap_readwrite

Method test_save_load_memmap_readwrite

numpy/lib/tests/test_io.py:2570–2584  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

2568
2569 @pytest.mark.xfail(IS_WASM, reason="memmap doesn't work correctly")
2570 def test_save_load_memmap_readwrite(self):
2571 # Test that pathlib.Path instances can be written mem-mapped.
2572 with temppath(suffix='.npy') as path:
2573 path = Path(path)
2574 a = np.array([[1, 2], [3, 4]], int)
2575 np.save(path, a)
2576 b = np.load(path, mmap_mode='r+')
2577 a[0][0] = 5
2578 b[0][0] = 5
2579 del b # closes the file
2580 if IS_PYPY:
2581 break_cycles()
2582 break_cycles()
2583 data = np.load(path)
2584 assert_array_equal(data, a)
2585
2586 def test_savez_load(self):
2587 # Test that pathlib.Path instances can be used with savez.

Callers

nothing calls this directly

Calls 3

temppathFunction · 0.90
break_cyclesFunction · 0.90
assert_array_equalFunction · 0.90

Tested by

no test coverage detected