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

Method test_load_non_npy

numpy/lib/tests/test_io.py:215–229  ·  view source on GitHub ↗

Test loading non-.npy files and name mapping in .npz.

(self)

Source from the content-addressed store, hash-verified

213 os.remove(arr_reloaded.fid.name)
214
215 def test_load_non_npy(self):
216 """Test loading non-.npy files and name mapping in .npz."""
217 with temppath(prefix="numpy_test_npz_load_non_npy_", suffix=".npz") as tmp:
218 with zipfile.ZipFile(tmp, "w") as npz:
219 with npz.open("test1.npy", "w") as out_file:
220 np.save(out_file, np.arange(10))
221 with npz.open("test2", "w") as out_file:
222 np.save(out_file, np.arange(10))
223 with npz.open("metadata", "w") as out_file:
224 out_file.write(b"Name: Test")
225 with np.load(tmp) as npz:
226 assert len(npz["test1"]) == 10
227 assert len(npz["test1.npy"]) == 10
228 assert len(npz["test2"]) == 10
229 assert npz["metadata"] == b"Name: Test"
230
231 @pytest.mark.skipif(not IS_64BIT, reason="Needs 64bit platform")
232 @pytest.mark.slow

Callers

nothing calls this directly

Calls 3

temppathFunction · 0.90
openMethod · 0.45
writeMethod · 0.45

Tested by

no test coverage detected