Skip to content

Commit 6f11ae7

Browse files
authored
use store dimension separtor in DirectoryStore.listdir (#1335)
* use store dimension separtor in DirectoryStore.listdir NestedDirectoryStore which inherits from DirectoryStore only supports '/' as a dimension separator. However listdir uses the parent DirectoryStore.listdir which produces keys with an incorrect separator '.' Fixes #1334 * update release note
1 parent 0bf0b3b commit 6f11ae7

File tree

3 files changed

+12
-1
lines changed

3 files changed

+12
-1
lines changed

docs/release.rst

+2
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,8 @@ Bug fixes
2828

2929
* Ensure contiguous data is give to ``FSStore``. Only copying if needed.
3030
By :user:`Mads R. B. Kristensen <madsbk>` :issue:`1285`.
31+
* NestedDirectoryStore.listdir now returns chunk keys with the correct '/' dimension_separator.
32+
By :user:`Brett Graham <braingram>` :issue:`1334`.
3133

3234
.. _release_2.13.6:
3335

zarr/storage.py

+3-1
Original file line numberDiff line numberDiff line change
@@ -1204,7 +1204,9 @@ def _nested_listdir(self, path=None):
12041204
for file_name in file_names:
12051205
file_path = os.path.join(dir_path, file_name)
12061206
rel_path = file_path.split(root_path + os.path.sep)[1]
1207-
new_children.append(rel_path.replace(os.path.sep, '.'))
1207+
new_children.append(rel_path.replace(
1208+
os.path.sep,
1209+
self._dimension_separator or '.'))
12081210
else:
12091211
new_children.append(entry)
12101212
return sorted(new_children)

zarr/tests/test_storage.py

+7
Original file line numberDiff line numberDiff line change
@@ -1442,6 +1442,13 @@ def test_chunk_nesting(self):
14421442
store[self.root + '42'] = b'zzz'
14431443
assert b'zzz' == store[self.root + '42']
14441444

1445+
def test_listdir(self):
1446+
store = self.create_store()
1447+
z = zarr.zeros((10, 10), chunks=(5, 5), store=store)
1448+
z[:] = 1 # write to all chunks
1449+
for k in store.listdir():
1450+
assert store.get(k) is not None
1451+
14451452

14461453
class TestNestedDirectoryStoreNone:
14471454

0 commit comments

Comments
 (0)