Skip to content

Commit e00ce0b

Browse files
committed
make all tests pass
1 parent f47c872 commit e00ce0b

File tree

6 files changed

+726
-721
lines changed

6 files changed

+726
-721
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,5 +78,6 @@ src/zarr/_version.py
7878
#doesnotexist
7979
#test_sync*
8080
data/*
81+
src/fixture/
8182

8283
.DS_Store

src/zarr/v3/codecs/sharding.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -354,7 +354,7 @@ async def decode_partial(
354354
for chunk_coords in all_chunk_coords:
355355
chunk_byte_slice = shard_index.get_chunk_slice(chunk_coords)
356356
if chunk_byte_slice:
357-
chunk_bytes = await store_path.get_async(chunk_byte_slice)
357+
chunk_bytes = await store_path.get(chunk_byte_slice)
358358
if chunk_bytes:
359359
shard_dict[chunk_coords] = chunk_bytes
360360

@@ -533,9 +533,9 @@ async def _write_chunk(
533533
)
534534

535535
if shard_builder.index.is_all_empty():
536-
await store_path.delete_async()
536+
await store_path.delete()
537537
else:
538-
await store_path.set_async(
538+
await store_path.set(
539539
await shard_builder.finalize(
540540
self.configuration.index_location,
541541
self._encode_shard_index,
@@ -561,9 +561,9 @@ def _shard_index_size(self) -> int:
561561
async def _load_shard_index_maybe(self, store_path: StorePath) -> Optional[_ShardIndex]:
562562
shard_index_size = self._shard_index_size()
563563
if self.configuration.index_location == ShardingCodecIndexLocation.start:
564-
index_bytes = await store_path.get_async((0, shard_index_size))
564+
index_bytes = await store_path.get((0, shard_index_size))
565565
else:
566-
index_bytes = await store_path.get_async((-shard_index_size, None))
566+
index_bytes = await store_path.get((-shard_index_size, None))
567567
if index_bytes is not None:
568568
return await self._decode_shard_index(index_bytes)
569569
return None
@@ -574,7 +574,7 @@ async def _load_shard_index(self, store_path: StorePath) -> _ShardIndex:
574574
)
575575

576576
async def _load_full_shard_maybe(self, store_path: StorePath) -> Optional[_ShardProxy]:
577-
shard_bytes = await store_path.get_async()
577+
shard_bytes = await store_path.get()
578578

579579
return await _ShardProxy.from_bytes(shard_bytes, self) if shard_bytes else None
580580

src/zarr/v3/group.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -191,7 +191,7 @@ async def delitem(self, key: str) -> None:
191191

192192
async def _save_metadata(self) -> None:
193193
to_save = self.metadata.to_bytes()
194-
awaitables = [(self.store_path / key).set_async(value) for key, value in to_save.items()]
194+
awaitables = [(self.store_path / key).set(value) for key, value in to_save.items()]
195195
await asyncio.gather(*awaitables)
196196

197197
@property
@@ -227,9 +227,9 @@ async def update_attributes(self, new_attributes: Dict[str, Any]):
227227
to_save = self.metadata.to_bytes()
228228
if self.metadata.zarr_format == 2:
229229
# only save the .zattrs object
230-
await (self.store_path / ZATTRS_JSON).set_async(to_save[ZATTRS_JSON])
230+
await (self.store_path / ZATTRS_JSON).set(to_save[ZATTRS_JSON])
231231
else:
232-
await (self.store_path / ZARR_JSON).set_async(to_save[ZARR_JSON])
232+
await (self.store_path / ZARR_JSON).set(to_save[ZARR_JSON])
233233

234234
self.metadata.attributes.clear()
235235
self.metadata.attributes.update(new_attributes)

src/zarr/v3/store/memory.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ async def get(
3434
value = value[byte_range[0] : byte_range[1]]
3535
return value
3636
except KeyError:
37-
return None # Q(JH): why not raise?
37+
return None
3838

3939
async def get_partial_values(
4040
self, key_ranges: List[Tuple[str, Tuple[int, int]]]

tests/test_codecs_v3.py

Lines changed: 27 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,8 @@
1313
from zarr.v3.indexing import morton_order_iter
1414
from zarr.v3.metadata import CodecMetadata, ShardingCodecIndexLocation, runtime_configuration
1515

16-
from zarr.v3.store import MemoryStore, Store
16+
from zarr.v3.abc.store import Store
17+
from zarr.v3.store import MemoryStore, StorePath
1718

1819

1920
@frozen
@@ -38,7 +39,7 @@ async def set(self, value: np.ndarray):
3839

3940
@pytest.fixture
4041
def store() -> Iterator[Store]:
41-
yield MemoryStore()
42+
yield StorePath(MemoryStore())
4243

4344

4445
@pytest.fixture
@@ -283,7 +284,7 @@ async def test_order(
283284
fill_value=1,
284285
)
285286
z[:, :] = data
286-
assert await store.get_async("order/0.0") == z._store["0.0"]
287+
assert await (store / "order/0.0").get() == z._store["0.0"]
287288

288289

289290
@pytest.mark.parametrize("input_order", ["F", "C"])
@@ -395,7 +396,7 @@ async def test_transpose(
395396
fill_value=1,
396397
)
397398
z[:, :] = data
398-
assert await store.get_async("transpose/0.0") == await store.get_async("transpose_zarr/0.0")
399+
assert await (store / "transpose/0.0").get() == await (store / "transpose_zarr/0.0").get()
399400

400401

401402
def test_transpose_invalid(
@@ -606,7 +607,7 @@ async def test_delete_empty_chunks(store: Store):
606607
await _AsyncArrayProxy(a)[:16, :16].set(np.zeros((16, 16)))
607608
await _AsyncArrayProxy(a)[:16, :16].set(data)
608609
assert np.array_equal(await _AsyncArrayProxy(a)[:16, :16].get(), data)
609-
assert await store.get_async("delete_empty_chunks/c0/0") is None
610+
assert await (store / "delete_empty_chunks/c0/0").get() is None
610611

611612

612613
@pytest.mark.asyncio
@@ -630,8 +631,8 @@ async def test_delete_empty_sharded_chunks(store: Store):
630631
data = np.ones((16, 16), dtype="uint16")
631632
data[:8, :8] = 0
632633
assert np.array_equal(data, await _AsyncArrayProxy(a)[:, :].get())
633-
assert await store.get_async("delete_empty_sharded_chunks/c/1/0") is None
634-
chunk_bytes = await store.get_async("delete_empty_sharded_chunks/c/0/0")
634+
assert await (store / "delete_empty_sharded_chunks/c/1/0").get() is None
635+
chunk_bytes = await (store / "delete_empty_sharded_chunks/c/0/0").get()
635636
assert chunk_bytes is not None and len(chunk_bytes) == 16 * 2 + 8 * 8 * 2 + 4
636637

637638

@@ -661,10 +662,10 @@ async def test_zarr_compat(store: Store):
661662
assert np.array_equal(data, await _AsyncArrayProxy(a)[:16, :18].get())
662663
assert np.array_equal(data, z2[:16, :18])
663664

664-
assert z2._store["0.0"] == await store.get_async("zarr_compat3/0.0")
665-
assert z2._store["0.1"] == await store.get_async("zarr_compat3/0.1")
666-
assert z2._store["1.0"] == await store.get_async("zarr_compat3/1.0")
667-
assert z2._store["1.1"] == await store.get_async("zarr_compat3/1.1")
665+
assert z2._store["0.0"] == await (store / "zarr_compat3/0.0").get()
666+
assert z2._store["0.1"] == await (store / "zarr_compat3/0.1").get()
667+
assert z2._store["1.0"] == await (store / "zarr_compat3/1.0").get()
668+
assert z2._store["1.1"] == await (store / "zarr_compat3/1.1").get()
668669

669670

670671
@pytest.mark.asyncio
@@ -695,10 +696,10 @@ async def test_zarr_compat_F(store: Store):
695696
assert np.array_equal(data, await _AsyncArrayProxy(a)[:16, :18].get())
696697
assert np.array_equal(data, z2[:16, :18])
697698

698-
assert z2._store["0.0"] == await store.get_async("zarr_compatF3/0.0")
699-
assert z2._store["0.1"] == await store.get_async("zarr_compatF3/0.1")
700-
assert z2._store["1.0"] == await store.get_async("zarr_compatF3/1.0")
701-
assert z2._store["1.1"] == await store.get_async("zarr_compatF3/1.1")
699+
assert z2._store["0.0"] == await (store / "zarr_compatF3/0.0").get()
700+
assert z2._store["0.1"] == await (store / "zarr_compatF3/0.1").get()
701+
assert z2._store["1.0"] == await (store / "zarr_compatF3/1.0").get()
702+
assert z2._store["1.1"] == await (store / "zarr_compatF3/1.1").get()
702703

703704

704705
@pytest.mark.asyncio
@@ -728,7 +729,7 @@ async def test_dimension_names(store: Store):
728729
)
729730

730731
assert (await AsyncArray.open(store / "dimension_names2")).metadata.dimension_names is None
731-
zarr_json_bytes = await (store / "dimension_names2" / "zarr.json").get_async()
732+
zarr_json_bytes = await (store / "dimension_names2" / "zarr.json").get()
732733
assert zarr_json_bytes is not None
733734
assert "dimension_names" not in json.loads(zarr_json_bytes)
734735

@@ -794,7 +795,7 @@ async def test_endian(store: Store, endian: Literal["big", "little"]):
794795
fill_value=1,
795796
)
796797
z[:, :] = data
797-
assert await store.get_async("endian/0.0") == z._store["0.0"]
798+
assert await (store / "endian/0.0").get() == z._store["0.0"]
798799

799800

800801
@pytest.mark.parametrize("dtype_input_endian", [">u2", "<u2"])
@@ -830,7 +831,7 @@ async def test_endian_write(
830831
fill_value=1,
831832
)
832833
z[:, :] = data
833-
assert await store.get_async("endian/0.0") == z._store["0.0"]
834+
assert await (store / "endian/0.0").get() == z._store["0.0"]
834835

835836

836837
def test_invalid_metadata(store: Store):
@@ -932,17 +933,17 @@ async def test_resize(store: Store):
932933
)
933934

934935
await _AsyncArrayProxy(a)[:16, :18].set(data)
935-
assert await store.get_async("resize/0.0") is not None
936-
assert await store.get_async("resize/0.1") is not None
937-
assert await store.get_async("resize/1.0") is not None
938-
assert await store.get_async("resize/1.1") is not None
936+
assert await (store / "resize/0.0").get() is not None
937+
assert await (store / "resize/0.1").get() is not None
938+
assert await (store / "resize/1.0").get() is not None
939+
assert await (store / "resize/1.1").get() is not None
939940

940941
a = await a.resize((10, 12))
941942
assert a.metadata.shape == (10, 12)
942-
assert await store.get_async("resize/0.0") is not None
943-
assert await store.get_async("resize/0.1") is not None
944-
assert await store.get_async("resize/1.0") is None
945-
assert await store.get_async("resize/1.1") is None
943+
assert await (store / "resize/0.0").get() is not None
944+
assert await (store / "resize/0.1").get() is not None
945+
assert await (store / "resize/1.0").get() is None
946+
assert await (store / "resize/1.1").get() is None
946947

947948

948949
def test_exists_ok(store: Store):

0 commit comments

Comments
 (0)