-
-
Notifications
You must be signed in to change notification settings - Fork 363
Closed
Labels
bugPotential issues with the zarr-python libraryPotential issues with the zarr-python library
Description
Zarr version
v3
Numcodecs version
n/a
Python Version
n/a
Operating System
n/a
Installation
n/a
Description
MemoryStore.list_dir incorrectly includes an entry for each nested child of a group. This differs from the behavior of LocalStore.list_dir
Steps to reproduce
This program sets up a store with some nested objects:
import zarr.store
import zarr.core.buffer
async def main():
local = zarr.store.LocalStore("/tmp/foo", mode="w")
mem = zarr.store.MemoryStore({}, mode="w")
paths = [
'root/a0/zarr.json',
'root/g0/zarr.json',
'root/g0/a1/zarr.json',
'root/g0/g1/zarr.json',
'root/g0/g1/a2/zarr.json',
'root/g0/g1/g2/zarr.json',
]
for store in [local, mem]:
for path in paths:
await store.set(path, zarr.core.buffer.Buffer.from_bytes(b""))
print(type(store).__name__)
print([x async for x in store.list_dir("root")])
print("-" * 80)
if __name__ == "__main__":
import asyncio
asyncio.run(main())
Here's the output:
LocalStore
['g0', 'a0']
--------------------------------------------------------------------------------
MemoryStore
['a0', 'g0', 'g0', 'g0', 'g0', 'g0']
--------------------------------------------------------------------------------
The g0
group is repeated once per child.
Additional output
I'll have a PR shortly.
Metadata
Metadata
Assignees
Labels
bugPotential issues with the zarr-python libraryPotential issues with the zarr-python library