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

Function test_zarr_regions

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

Source from the content-addressed store, hash-verified

5268
5269
5270def test_zarr_regions():
5271 zarr = pytest.importorskip("zarr")
5272
5273 a = da.arange(16).reshape((4, 4)).rechunk(2)
5274 z = zarr.zeros_like(a, chunks=2)
5275
5276 a[:2, :2].to_zarr(z, region=(slice(2), slice(2)))
5277 a2 = da.from_zarr(z)
5278 expected = [[0, 1, 0, 0], [4, 5, 0, 0], [0, 0, 0, 0], [0, 0, 0, 0]]
5279 assert_eq(a2, expected)
5280 assert a2.chunks == a.chunks
5281
5282 with pytest.warns(PerformanceWarning):
5283 a[:3, 3:4].to_zarr(z, region=(slice(1, 4), slice(2, 3)))
5284
5285 a2 = da.from_zarr(z)
5286 expected = [[0, 1, 0, 0], [4, 5, 3, 0], [0, 0, 7, 0], [0, 0, 11, 0]]
5287 assert_eq(a2, expected)
5288 assert a2.chunks == a.chunks
5289
5290 with pytest.warns(PerformanceWarning):
5291 a[3:, 3:].to_zarr(z, region=(slice(2, 3), slice(1, 2)))
5292
5293 a2 = da.from_zarr(z)
5294 expected = [[0, 1, 0, 0], [4, 5, 3, 0], [0, 15, 7, 0], [0, 0, 11, 0]]
5295 assert_eq(a2, expected)
5296 assert a2.chunks == a.chunks
5297
5298 with pytest.raises(ValueError):
5299 with tmpdir() as d:
5300 a.to_zarr(d, region=(slice(2), slice(2)))
5301
5302
5303def 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