MCPcopy Index your code
hub / github.com/numpy/numpy / test_version_2_0_memmap

Function test_version_2_0_memmap

numpy/lib/tests/test_format.py:703–731  ·  view source on GitHub ↗
(tmpdir)

Source from the content-addressed store, hash-verified

701
702@pytest.mark.skipif(IS_WASM, reason="memmap doesn't work correctly")
703def test_version_2_0_memmap(tmpdir):
704 # requires more than 2 byte for header
705 dt = [(f"{i}" * 100, float) for i in range(500)]
706 d = np.ones(1000, dtype=dt)
707 tf1 = os.path.join(tmpdir, 'version2_01.npy')
708 tf2 = os.path.join(tmpdir, 'version2_02.npy')
709
710 # 1.0 requested but data cannot be saved this way
711 assert_raises(ValueError, format.open_memmap, tf1, mode='w+', dtype=d.dtype,
712 shape=d.shape, version=(1, 0))
713
714 ma = format.open_memmap(tf1, mode='w+', dtype=d.dtype,
715 shape=d.shape, version=(2, 0))
716 ma[...] = d
717 ma.flush()
718 ma = format.open_memmap(tf1, mode='r', max_header_size=200000)
719 assert_array_equal(ma, d)
720
721 with warnings.catch_warnings(record=True) as w:
722 warnings.filterwarnings('always', '', UserWarning)
723 ma = format.open_memmap(tf2, mode='w+', dtype=d.dtype,
724 shape=d.shape, version=None)
725 assert_(w[0].category is UserWarning)
726 ma[...] = d
727 ma.flush()
728
729 ma = format.open_memmap(tf2, mode='r', max_header_size=200000)
730
731 assert_array_equal(ma, d)
732
733@pytest.mark.parametrize("mmap_mode", ["r", None])
734def test_huge_header(tmpdir, mmap_mode):

Callers

nothing calls this directly

Calls 5

assert_raisesFunction · 0.90
assert_array_equalFunction · 0.90
assert_Function · 0.90
joinMethod · 0.80
flushMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…