Skip to content

Commit 5fb4829

Browse files
committed
tweak example
1 parent 56cafc3 commit 5fb4829

File tree

1 file changed

+9
-7
lines changed

1 file changed

+9
-7
lines changed

zarr/convenience.py

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -396,8 +396,9 @@ def copy_store(source, dest, source_path='', dest_path='', excludes=None,
396396
"""Copy data directly from the `source` store to the `dest` store. Use this
397397
function when you want to copy a group or array in the most efficient way,
398398
preserving all configuration and attributes. This function is more efficient
399-
because it avoids de-compressing and re-compressing data, rather the compressed
400-
chunk data for each array are copied directly between stores.
399+
than the copy() or copy_all() functions because it avoids de-compressing and
400+
re-compressing data, rather the compressed chunk data for each array are copied
401+
directly between stores.
401402
402403
Parameters
403404
----------
@@ -423,7 +424,8 @@ def copy_store(source, dest, source_path='', dest_path='', excludes=None,
423424
Examples
424425
--------
425426
>>> import zarr
426-
>>> root = zarr.group()
427+
>>> store1 = zarr.DirectoryStore('data/example.zarr')
428+
>>> root = zarr.group(store1, overwrite=True)
427429
>>> foo = root.create_group('foo')
428430
>>> bar = foo.create_group('bar')
429431
>>> baz = bar.create_dataset('baz', shape=100, chunks=50, dtype='i8')
@@ -434,24 +436,24 @@ def copy_store(source, dest, source_path='', dest_path='', excludes=None,
434436
└── foo
435437
└── bar
436438
└── baz (100,) int64
437-
>>> source = root.store
438-
>>> dest = dict() # or could be any other type of store
439439
>>> import sys
440-
>>> zarr.copy_store(source, dest, log=sys.stdout)
440+
>>> store2 = zarr.ZipStore('data/example.zip', mode='w') # or any type of store
441+
>>> zarr.copy_store(store1, store2, log=sys.stdout)
441442
.zgroup -> .zgroup
442443
foo/.zgroup -> foo/.zgroup
443444
foo/bar/.zgroup -> foo/bar/.zgroup
444445
foo/bar/baz/.zarray -> foo/bar/baz/.zarray
445446
foo/bar/baz/0 -> foo/bar/baz/0
446447
foo/bar/baz/1 -> foo/bar/baz/1
447-
>>> new_root = zarr.group(dest)
448+
>>> new_root = zarr.group(store2)
448449
>>> new_root.tree()
449450
/
450451
└── foo
451452
└── bar
452453
└── baz (100,) int64
453454
>>> new_root['foo/bar/baz'][:]
454455
array([ 0, 1, 2, ..., 97, 98, 99])
456+
>>> store2.close() # zip stores need to be closed
455457
456458
"""
457459

0 commit comments

Comments
 (0)