Skip to content

Commit e38789b

Browse files
committed
better test
1 parent 72b3b9a commit e38789b

File tree

1 file changed

+14
-16
lines changed

1 file changed

+14
-16
lines changed

tests/test_store/test_memory.py

Lines changed: 14 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
from typing import TYPE_CHECKING
44

5+
import numpy as np
56
import pytest
67

78
import zarr
@@ -57,22 +58,19 @@ def test_list_prefix(self, store: MemoryStore) -> None:
5758
async def test_deterministic_size(
5859
self, store: MemoryStore, dtype, zarr_format: ZarrFormat
5960
) -> None:
60-
def padding_size() -> int:
61-
a = zarr.empty(
62-
store=store,
63-
shape=(3,),
64-
chunks=(1000,),
65-
dtype=dtype,
66-
zarr_format=zarr_format,
67-
overwrite=True,
68-
)
69-
a[...] = 1
70-
key = "0" if zarr_format == 2 else "c/0"
71-
return len(store._store_dict[key])
72-
73-
l1 = padding_size()
74-
l2 = padding_size()
75-
assert l1 == l2
61+
a = zarr.empty(
62+
store=store,
63+
shape=(3,),
64+
chunks=(1000,),
65+
dtype=dtype,
66+
zarr_format=zarr_format,
67+
overwrite=True,
68+
)
69+
a[...] = 1
70+
a.resize((1000,))
71+
72+
np.testing.assert_array_equal(a[:3], 1)
73+
np.testing.assert_array_equal(a[3:], 0)
7674

7775

7876
@gpu_test

0 commit comments

Comments
 (0)