13
13
from zarr .v3 .indexing import morton_order_iter
14
14
from zarr .v3 .metadata import CodecMetadata , ShardingCodecIndexLocation , runtime_configuration
15
15
16
- from zarr .v3 .store import MemoryStore , Store
16
+ from zarr .v3 .abc .store import Store
17
+ from zarr .v3 .store import MemoryStore , StorePath
17
18
18
19
19
20
@frozen
@@ -38,7 +39,7 @@ async def set(self, value: np.ndarray):
38
39
39
40
@pytest .fixture
40
41
def store () -> Iterator [Store ]:
41
- yield MemoryStore ()
42
+ yield StorePath ( MemoryStore () )
42
43
43
44
44
45
@pytest .fixture
@@ -283,7 +284,7 @@ async def test_order(
283
284
fill_value = 1 ,
284
285
)
285
286
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" ]
287
288
288
289
289
290
@pytest .mark .parametrize ("input_order" , ["F" , "C" ])
@@ -395,7 +396,7 @@ async def test_transpose(
395
396
fill_value = 1 ,
396
397
)
397
398
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 ( )
399
400
400
401
401
402
def test_transpose_invalid (
@@ -606,7 +607,7 @@ async def test_delete_empty_chunks(store: Store):
606
607
await _AsyncArrayProxy (a )[:16 , :16 ].set (np .zeros ((16 , 16 )))
607
608
await _AsyncArrayProxy (a )[:16 , :16 ].set (data )
608
609
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
610
611
611
612
612
613
@pytest .mark .asyncio
@@ -630,8 +631,8 @@ async def test_delete_empty_sharded_chunks(store: Store):
630
631
data = np .ones ((16 , 16 ), dtype = "uint16" )
631
632
data [:8 , :8 ] = 0
632
633
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 ( )
635
636
assert chunk_bytes is not None and len (chunk_bytes ) == 16 * 2 + 8 * 8 * 2 + 4
636
637
637
638
@@ -661,10 +662,10 @@ async def test_zarr_compat(store: Store):
661
662
assert np .array_equal (data , await _AsyncArrayProxy (a )[:16 , :18 ].get ())
662
663
assert np .array_equal (data , z2 [:16 , :18 ])
663
664
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 ( )
668
669
669
670
670
671
@pytest .mark .asyncio
@@ -695,10 +696,10 @@ async def test_zarr_compat_F(store: Store):
695
696
assert np .array_equal (data , await _AsyncArrayProxy (a )[:16 , :18 ].get ())
696
697
assert np .array_equal (data , z2 [:16 , :18 ])
697
698
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 ( )
702
703
703
704
704
705
@pytest .mark .asyncio
@@ -728,7 +729,7 @@ async def test_dimension_names(store: Store):
728
729
)
729
730
730
731
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 ()
732
733
assert zarr_json_bytes is not None
733
734
assert "dimension_names" not in json .loads (zarr_json_bytes )
734
735
@@ -794,7 +795,7 @@ async def test_endian(store: Store, endian: Literal["big", "little"]):
794
795
fill_value = 1 ,
795
796
)
796
797
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" ]
798
799
799
800
800
801
@pytest .mark .parametrize ("dtype_input_endian" , [">u2" , "<u2" ])
@@ -830,7 +831,7 @@ async def test_endian_write(
830
831
fill_value = 1 ,
831
832
)
832
833
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" ]
834
835
835
836
836
837
def test_invalid_metadata (store : Store ):
@@ -932,17 +933,17 @@ async def test_resize(store: Store):
932
933
)
933
934
934
935
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
939
940
940
941
a = await a .resize ((10 , 12 ))
941
942
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
946
947
947
948
948
949
def test_exists_ok (store : Store ):
0 commit comments