(path: str, arr_name: str)
| 258 | |
| 259 | @contextmanager |
| 260 | def open_array(path: str, arr_name: str): |
| 261 | with open(path, "rb") as f: |
| 262 | with zipfile.ZipFile(f, "r") as zip_f: |
| 263 | if f"{arr_name}.npy" not in zip_f.namelist(): |
| 264 | raise ValueError(f"missing {arr_name} in npz file") |
| 265 | with zip_f.open(f"{arr_name}.npy", "r") as arr_f: |
| 266 | yield arr_f |
| 267 | |
| 268 | |
| 269 | def _dict_batch_size(objs: Dict[str, np.ndarray]) -> int: |