Skip to content

Commit c24ef68

Browse files
DOC: Fix code blocks in posting-issues.md (#2621)
1 parent 031c5be commit c24ef68

1 file changed

Lines changed: 7 additions & 2 deletions

File tree

docs/development/posting-issues.md

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -70,10 +70,14 @@ ds = xr.open_dataset("my_dataset.nc") # or xr.open_zarr(...), etc.
7070
# except_for=None — remove all arrays (useful to know about dtypes, structure, and metadata). This is the default for the function.
7171
ds_trimmed = replace_arrays_with_zeros(ds, except_for = None)
7272
73-
# Save to a zipped Zarr store - replace `my_dataset` with a more informative name
74-
with zarr.storage.ZipStore("my_dataset.zip", mode='w') as store:
73+
# Save to a Zip. Note cannot use `zarr.storage.ZipStore` due to https://github.com/zarr-developers/zarr-python/issues/3516
74+
with zarr.storage.LocalStore("my_dataset_unzipped") as store:
7575
ds_trimmed.to_zarr(store)
7676
77+
import shutil
78+
79+
shutil.make_archive("my_dataset", "zip", "my_dataset_unzipped")
80+
7781
size_mb_original = os.path.getsize("my_dataset.nc") / 1e6
7882
print(f"Original size: {size_mb_original:.1f} MB")
7983
@@ -108,6 +112,7 @@ del ds
108112
from pathlib import Path
109113
Path("my_dataset.zip").unlink()
110114
Path("my_dataset.nc").unlink()
115+
shutil.rmtree("my_dataset_unzipped")
111116
112117
```
113118

0 commit comments

Comments
 (0)