MCPcopy Create free account
hub / github.com/pydata/xarray / test_grid_rechunk

Function test_grid_rechunk

xarray/tests/test_backends_chunks.py:98–116  ·  view source on GitHub ↗
(enc_chunks, region, nd_v_chunks, expected_chunks)

Source from the content-addressed store, hash-verified

96 ],
97)
98def test_grid_rechunk(enc_chunks, region, nd_v_chunks, expected_chunks):
99 dims = [f"dim_{i}" for i in range(len(region))]
100 coords = {
101 dim: list(range(r.start, r.stop)) for dim, r in zip(dims, region, strict=False)
102 }
103 shape = tuple(r.stop - r.start for r in region)
104 arr = xr.DataArray(
105 np.arange(np.prod(shape)).reshape(shape),
106 dims=dims,
107 coords=coords,
108 )
109 arr = arr.chunk(dict(zip(dims, nd_v_chunks, strict=False)))
110
111 result = grid_rechunk(
112 arr.variable,
113 enc_chunks=enc_chunks,
114 region=region,
115 )
116 assert result.chunks == expected_chunks

Callers

nothing calls this directly

Calls 4

chunkMethod · 0.95
grid_rechunkFunction · 0.90
arangeMethod · 0.80
prodMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…