Skip to content

Commit fd1e5df

Browse files
committed
simplify returns
1 parent 6e7cb4e commit fd1e5df

File tree

1 file changed

+38
-8
lines changed

1 file changed

+38
-8
lines changed

zarr/convenience.py

Lines changed: 38 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -425,6 +425,7 @@ def tree(grp, expand=False, level=None):
425425
>>> import h5py
426426
>>> h5f = h5py.File('data/example.h5', mode='w')
427427
>>> zarr.copy_all(g1, h5f)
428+
(5, 0, 800)
428429
>>> zarr.tree(h5f)
429430
/
430431
├── bar
@@ -493,6 +494,15 @@ def copy_store(source, dest, source_path='', dest_path='', excludes=None,
493494
log : callable, file path or file-like object, optional
494495
If provided, will be used to log progress information.
495496
497+
Returns
498+
-------
499+
n_copied : int
500+
Number of items copied.
501+
n_skipped : int
502+
Number of items skipped.
503+
n_bytes_copied : int
504+
Number of bytes of data that were actually copied.
505+
496506
Examples
497507
--------
498508
@@ -519,6 +529,7 @@ def copy_store(source, dest, source_path='', dest_path='', excludes=None,
519529
copy foo/bar/baz/0
520530
copy foo/bar/baz/1
521531
all done: 6 copied, 0 skipped, 566 bytes copied
532+
(6, 0, 566)
522533
>>> new_root = zarr.group(store2)
523534
>>> new_root.tree()
524535
/
@@ -558,9 +569,7 @@ def copy_store(source, dest, source_path='', dest_path='', excludes=None,
558569
.format(valid_if_exists, if_exists))
559570

560571
# setup counting variables
561-
n_copied = 0
562-
n_skipped = 0
563-
n_bytes_copied = 0
572+
n_copied = n_skipped = n_bytes_copied = 0
564573

565574
# setup logging
566575
with _LogWriter(log) as log:
@@ -619,9 +628,11 @@ def copy_store(source, dest, source_path='', dest_path='', excludes=None,
619628
# log a final message with a summary of what happened
620629
_log_copy_summary(log, dry_run, n_copied, n_skipped, n_bytes_copied)
621630

631+
return n_copied, n_skipped, n_bytes_copied
632+
622633

623634
def copy(source, dest, name=None, shallow=False, without_attrs=False, log=None,
624-
if_exists='raise', dry_run=False, return_stats=False, **create_kws):
635+
if_exists='raise', dry_run=False, **create_kws):
625636
"""Copy the `source` array or group into the `dest` group.
626637
627638
Parameters
@@ -649,11 +660,18 @@ def copy(source, dest, name=None, shallow=False, without_attrs=False, log=None,
649660
dry_run : bool, optional
650661
If True, don't actually copy anything, just log what would have
651662
happened.
652-
return_stats : bool, optional
653-
If True, return n_copied, n_skipped, n_bytes_copied.
654663
**create_kws
655664
Passed through to the create_dataset method when copying an array/dataset.
656665
666+
Returns
667+
-------
668+
n_copied : int
669+
Number of items copied.
670+
n_skipped : int
671+
Number of items skipped.
672+
n_bytes_copied : int
673+
Number of bytes of data that were actually copied.
674+
657675
Examples
658676
--------
659677
>>> import h5py
@@ -676,6 +694,7 @@ def copy(source, dest, name=None, shallow=False, without_attrs=False, log=None,
676694
copy /foo/bar
677695
copy /foo/bar/baz (100,) int64
678696
all done: 3 copied, 0 skipped, 800 bytes copied
697+
(3, 0, 800)
679698
>>> dest.tree() # N.B., no spam
680699
/
681700
└── foo
@@ -697,8 +716,7 @@ def copy(source, dest, name=None, shallow=False, without_attrs=False, log=None,
697716
# log a final message with a summary of what happened
698717
_log_copy_summary(log, dry_run, n_copied, n_skipped, n_bytes_copied)
699718

700-
if return_stats:
701-
return n_copied, n_skipped, n_bytes_copied
719+
return n_copied, n_skipped, n_bytes_copied
702720

703721

704722
def _copy(log, source, dest, name, root, shallow, without_attrs, if_exists,
@@ -902,6 +920,15 @@ def copy_all(source, dest, shallow=False, without_attrs=False, log=None,
902920
Passed through to the create_dataset method when copying an
903921
array/dataset.
904922
923+
Returns
924+
-------
925+
n_copied : int
926+
Number of items copied.
927+
n_skipped : int
928+
Number of items skipped.
929+
n_bytes_copied : int
930+
Number of bytes of data that were actually copied.
931+
905932
Examples
906933
--------
907934
>>> import h5py
@@ -925,6 +952,7 @@ def copy_all(source, dest, shallow=False, without_attrs=False, log=None,
925952
copy /foo/bar/baz (100,) int64
926953
copy /spam (100,) int64
927954
all done: 4 copied, 0 skipped, 1,600 bytes copied
955+
(4, 0, 1600)
928956
>>> dest.tree()
929957
/
930958
├── foo
@@ -951,3 +979,5 @@ def copy_all(source, dest, shallow=False, without_attrs=False, log=None,
951979

952980
# log a final message with a summary of what happened
953981
_log_copy_summary(log, dry_run, n_copied, n_skipped, n_bytes_copied)
982+
983+
return n_copied, n_skipped, n_bytes_copied

0 commit comments

Comments
 (0)