MCPcopy Create free account
hub / github.com/dask/dask / test_zarr_regions

Function test_zarr_regions

dask/array/tests/test_array_core.py:5117–5143  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

5115
5116
5117def test_zarr_regions():
5118 zarr = pytest.importorskip("zarr")
5119
5120 a = da.arange(16).reshape((4, 4)).rechunk(2)
5121 z = zarr.zeros_like(a, chunks=2)
5122
5123 a[:2, :2].to_zarr(z, region=(slice(2), slice(2)))
5124 a2 = da.from_zarr(z)
5125 expected = [[0, 1, 0, 0], [4, 5, 0, 0], [0, 0, 0, 0], [0, 0, 0, 0]]
5126 assert_eq(a2, expected)
5127 assert a2.chunks == a.chunks
5128
5129 a[:3, 3:4].to_zarr(z, region=(slice(1, 4), slice(2, 3)))
5130 a2 = da.from_zarr(z)
5131 expected = [[0, 1, 0, 0], [4, 5, 3, 0], [0, 0, 7, 0], [0, 0, 11, 0]]
5132 assert_eq(a2, expected)
5133 assert a2.chunks == a.chunks
5134
5135 a[3:, 3:].to_zarr(z, region=(slice(2, 3), slice(1, 2)))
5136 a2 = da.from_zarr(z)
5137 expected = [[0, 1, 0, 0], [4, 5, 3, 0], [0, 15, 7, 0], [0, 0, 11, 0]]
5138 assert_eq(a2, expected)
5139 assert a2.chunks == a.chunks
5140
5141 with pytest.raises(ValueError):
5142 with tmpdir() as d:
5143 a.to_zarr(d, region=(slice(2), slice(2)))
5144
5145
5146def test_tiledb_roundtrip():

Callers

nothing calls this directly

Calls 6

assert_eqFunction · 0.90
tmpdirFunction · 0.90
reshapeMethod · 0.80
to_zarrMethod · 0.80
rechunkMethod · 0.45
arangeMethod · 0.45

Tested by

no test coverage detected