Skip to content

Commit d1be12b

Browse files
committed
chore: tests
1 parent e61b367 commit d1be12b

1 file changed

Lines changed: 15 additions & 0 deletions

File tree

tests/test_io_elementwise.py

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -947,6 +947,21 @@ def test_write_auto_sharded_default_warns(tmp_path: Path):
947947
):
948948
adata.write_zarr(path)
949949

950+
@pytest.mark.zarr_io
951+
@pytest.mark.skipif(
952+
Version(version("zarr")) < Version("3.1.4"),
953+
reason="autosharding with chosen size was not available",
954+
)
955+
def test_write_auto_sharded_size_sparse(tmp_path: Path):
956+
path = "memory://check_shards.zarr"
957+
z = zarr.open(path)
958+
mat = sparse.random(1000, 1000, density=.5, format="csr", random_state=np.random.default_rng(42))
959+
ad.io.write_elem(z, "two_shards_per_sub_element", mat)
960+
# i.e., there are at most two shards since one shard will contain two chunks,
961+
# and the other the last elements, since the target size is 1GB uncompressed.
962+
for sub_element in ["indices", "data", "indptr"]:
963+
assert (z["two_shards_per_sub_element"][sub_element].shape[0] / z["two_shards_per_sub_element"][sub_element].shards[0]) < 2, sub_element
964+
950965

951966
@pytest.mark.zarr_io
952967
def test_write_auto_sharded_does_not_override(tmp_path: Path):

0 commit comments

Comments
 (0)