Test loading non-.npy files and name mapping in .npz.
(self)
| 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 |