File tree Expand file tree Collapse file tree 3 files changed +28
-0
lines changed Expand file tree Collapse file tree 3 files changed +28
-0
lines changed Original file line number Diff line number Diff line change @@ -16,6 +16,7 @@ Groups (``zarr.hierarchy``)
16
16
.. automethod :: array_keys
17
17
.. automethod :: arrays
18
18
.. automethod :: visit
19
+ .. automethod :: visitkeys
19
20
.. automethod :: visitvalues
20
21
.. automethod :: visititems
21
22
.. automethod :: create_group
Original file line number Diff line number Diff line change @@ -57,6 +57,7 @@ class Group(MutableMapping):
57
57
array_keys
58
58
arrays
59
59
visit
60
+ visitkeys
60
61
visitvalues
61
62
visititems
62
63
create_group
@@ -497,6 +498,12 @@ def visit(self, func):
497
498
base_len = len (self .name )
498
499
return self .visitvalues (lambda o : func (o .name [base_len :].lstrip ("/" )))
499
500
501
+ def visitkeys (self , func ):
502
+ """An alias for :py:meth:`~Group.visit`.
503
+ """
504
+
505
+ return self .visit (func )
506
+
500
507
def visititems (self , func ):
501
508
"""Run ``func`` on each object's path and the object itself.
502
509
Original file line number Diff line number Diff line change @@ -521,6 +521,24 @@ def visitor4(name, obj):
521
521
"baz" ,
522
522
], items )
523
523
524
+ del items [:]
525
+ g1 .visitkeys (visitor3 )
526
+ eq ([
527
+ "a" ,
528
+ "a/b" ,
529
+ "a/b/c" ,
530
+ "foo" ,
531
+ "foo/bar" ,
532
+ "foo/baz" ,
533
+ ], items )
534
+
535
+ del items [:]
536
+ g1 ["foo" ].visitkeys (visitor3 )
537
+ eq ([
538
+ "bar" ,
539
+ "baz" ,
540
+ ], items )
541
+
524
542
del items [:]
525
543
g1 .visititems (visitor3 )
526
544
eq ([
@@ -563,9 +581,11 @@ def visitor1(val, *args):
563
581
return True # pragma: no cover
564
582
565
583
eq (None , g1 .visit (visitor0 ))
584
+ eq (None , g1 .visitkeys (visitor0 ))
566
585
eq (None , g1 .visitvalues (visitor0 ))
567
586
eq (None , g1 .visititems (visitor0 ))
568
587
eq (True , g1 .visit (visitor1 ))
588
+ eq (True , g1 .visitkeys (visitor1 ))
569
589
eq (True , g1 .visitvalues (visitor1 ))
570
590
eq (True , g1 .visititems (visitor1 ))
571
591
You can’t perform that action at this time.
0 commit comments