MCPcopy
hub / github.com/dask/dask / test_zarr_regions

Function test_zarr_regions

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

Source from the content-addressed store, hash-verified

5289
5290
5291def test_zarr_regions():
5292 zarr = pytest.importorskip("zarr")
5293
5294 a = da.arange(16).reshape((4, 4)).rechunk(2)
5295 z = zarr.zeros_like(a, chunks=2)
5296
5297 a[:2, :2].to_zarr(z, region=(slice(2), slice(2)))
5298 a2 = da.from_zarr(z)
5299 expected = [[0, 1, 0, 0], [4, 5, 0, 0], [0, 0, 0, 0], [0, 0, 0, 0]]
5300 assert_eq(a2, expected)
5301 assert a2.chunks == a.chunks
5302
5303 with pytest.warns(PerformanceWarning):
5304 a[:3, 3:4].to_zarr(z, region=(slice(1, 4), slice(2, 3)))
5305
5306 a2 = da.from_zarr(z)
5307 expected = [[0, 1, 0, 0], [4, 5, 3, 0], [0, 0, 7, 0], [0, 0, 11, 0]]
5308 assert_eq(a2, expected)
5309 assert a2.chunks == a.chunks
5310
5311 with pytest.warns(PerformanceWarning):
5312 a[3:, 3:].to_zarr(z, region=(slice(2, 3), slice(1, 2)))
5313
5314 a2 = da.from_zarr(z)
5315 expected = [[0, 1, 0, 0], [4, 5, 3, 0], [0, 15, 7, 0], [0, 0, 11, 0]]
5316 assert_eq(a2, expected)
5317 assert a2.chunks == a.chunks
5318
5319 with pytest.raises(ValueError):
5320 with tmpdir() as d:
5321 a.to_zarr(d, region=(slice(2), slice(2)))
5322
5323
5324def 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

Used in the wild real call sites across dependent graphs

searching dependent graphs…