MCPcopy Index your code
hub / github.com/dask/dask / test_zarr_sharding_roundtrip

Function test_zarr_sharding_roundtrip

dask/array/tests/test_array_core.py:4976–5002  ·  view source on GitHub ↗

Test sharding with various chunk and shard combinations

(tmp_path, chunks, shards)

Source from the content-addressed store, hash-verified

4974 ],
4975)
4976def test_zarr_sharding_roundtrip(tmp_path, chunks, shards):
4977 """Test sharding with various chunk and shard combinations"""
4978 zarr = pytest.importorskip("zarr", minversion="3.0.0")
4979
4980 a = da.zeros((60, 60), chunks=chunks)
4981 zarr_array_kwargs = {"shards": shards}
4982
4983 a.to_zarr(tmp_path, **zarr_array_kwargs)
4984
4985 store = zarr.storage.FsspecStore.from_url(tmp_path)
4986 z = zarr.open_array(store)
4987
4988 assert z.shards == shards
4989
4990 a2 = da.from_zarr(tmp_path)
4991 assert_eq(a, a2)
4992 assert a2.chunks == a.chunks
4993
4994 b = da.ones((60, 60), chunks=chunks)
4995 with pytest.raises(ValueError, match="Cannot use"):
4996 b.to_zarr(tmp_path, mode="r")
4997
4998 b.to_zarr(tmp_path, mode="w", **zarr_array_kwargs)
4999
5000 b2 = da.from_zarr(tmp_path)
5001 assert_eq(b, b2)
5002 assert b2.chunks == b.chunks
5003
5004
5005@pytest.mark.parametrize("zarr_format", [2, 3])

Callers

nothing calls this directly

Calls 4

assert_eqFunction · 0.90
to_zarrMethod · 0.80
zerosMethod · 0.45
onesMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…