Skip to content

Commit eab894e

Browse files
authored
Merge pull request #33 from braingram/to_internal_tests
Add another unit test, remove unused `reserve_blocks`
2 parents 8440041 + 842f712 commit eab894e

File tree

2 files changed

+16
-10
lines changed

2 files changed

+16
-10
lines changed

asdf_zarr/converter.py

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -83,13 +83,3 @@ def from_yaml_tree(self, node, tag, ctx):
8383
# TODO mode, version, path_str?
8484
obj = zarr.open(store=store, chunk_store=chunk_store)
8585
return obj
86-
87-
def reserve_blocks(self, obj, tag):
88-
if not isinstance(obj.chunk_store, storage.InternalStore):
89-
return []
90-
91-
# if this block uses a 'InternalStore' it uses blocks
92-
keys = list(obj.chunk_store._chunk_asdf_keys.keys())
93-
if obj.chunk_store._chunk_block_map_asdf_key is not None:
94-
keys.append(obj._chunk_block_map_asdf_key)
95-
return keys

asdf_zarr/tests/test_zarr.py

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -129,3 +129,19 @@ def test_open_mode(tmp_path, mode):
129129
af["arr"][0, 0] = 1
130130
else:
131131
raise Exception(f"Unknown mode {mode}")
132+
133+
134+
@pytest.mark.parametrize("meta_store", [True, False])
135+
def test_to_internal(meta_store):
136+
if meta_store:
137+
zarr = create_zarray(store=KVStore({}), chunk_store=TempStore())
138+
else:
139+
zarr = create_zarray(store=TempStore())
140+
internal = asdf_zarr.storage.to_internal(zarr)
141+
assert isinstance(internal.chunk_store, asdf_zarr.storage.InternalStore)
142+
# the store shouldn't be wrapped if it's not used for chunks
143+
if zarr.store is not zarr.chunk_store:
144+
assert isinstance(internal.store, KVStore)
145+
# calling it a second time shouldn't re-wrap the store
146+
same = asdf_zarr.storage.to_internal(internal)
147+
assert same.chunk_store is internal.chunk_store

0 commit comments

Comments
 (0)