Skip to content

Commit 0903630

Browse files
Write zarr file to temp dir
1 parent 65eec0c commit 0903630

File tree

1 file changed

+9
-2
lines changed

1 file changed

+9
-2
lines changed

doc/user-guide/io.rst

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1085,18 +1085,25 @@ zarr <https://zarr.readthedocs.io/en/stable/user-guide/arrays.html#compressors>`
10851085
These options can be passed to the ``to_zarr`` method as variable encoding.
10861086
For example:
10871087

1088+
.. jupyter-execute::
1089+
1090+
zarr_filename = "foo.zarr"
1091+
10881092
.. jupyter-execute::
10891093
:hide-code:
10901094

1091-
! rm -rf foo.zarr
1095+
import os.path
1096+
import tempfile
1097+
tempdir = tempfile.TemporaryDirectory()
1098+
zarr_filename = os.path.join(tempdir.name, zarr_filename)
10921099

10931100
.. jupyter-execute::
10941101

10951102
import zarr
10961103
from zarr.codecs import BloscCodec
10971104

10981105
compressor = BloscCodec(cname="zstd", clevel=3, shuffle="shuffle")
1099-
ds.to_zarr("foo.zarr", consolidated=False, encoding={"foo": {"compressors": [compressor]}})
1106+
ds.to_zarr(zarr_filename, consolidated=False, encoding={"foo": {"compressors": [compressor]}})
11001107

11011108
.. note::
11021109

0 commit comments

Comments
 (0)