zarr-python
zarr-python copied to clipboard
`recurse` option for `array_keys` does not work as expected
Zarr version
v2.17.2
Numcodecs version
v0.12.1 (not relevant?)
Python Version
3.12
Operating System
Mac (not relevant?)
Installation
pip in virtual environment
Description
Not sure if this is a bug or feature, but given a group g the g.array_keys(recurse=True) method appears totally useless to me, if nested groups are present. In fact with the current implementation the returned keys are relative to the subgroups and not to g, so that g[k] does not work as expected.
See #260.
Steps to reproduce
import zarr
gtop = zarr.group()
gnested = gtop.create_group("nested")
gnested.empty("foo", shape=())
print("- array_keys")
for k in gtop.array_keys(recurse=True):
print(k)
print("- arrays name, value")
for n, v in gtop.arrays(recurse=True):
print(n, v.name)
The output is
- array_keys
foo
- arrays name, value
foo /nested/foo
I would expect instead
- array_keys
nested/foo
- arrays name, value
nested/foo /nested/foo
so that the returned keys can be used as gtop[k]
Additional output
No response