MCPcopy Index your code
hub / github.com/pydata/xarray / grid_rechunk

Function grid_rechunk

xarray/backends/chunks.py:156–181  ·  view source on GitHub ↗
(
    v: Variable,
    enc_chunks: tuple[int, ...],
    region: tuple[slice, ...],
)

Source from the content-addressed store, hash-verified

154
155
156def grid_rechunk(
157 v: Variable,
158 enc_chunks: tuple[int, ...],
159 region: tuple[slice, ...],
160) -> Variable:
161 nd_v_chunks = v.chunks
162 if not nd_v_chunks:
163 return v
164
165 nd_grid_chunks = tuple(
166 build_grid_chunks(
167 v_size,
168 region=interval,
169 chunk_size=chunk_size,
170 )
171 for v_size, chunk_size, interval in zip(
172 v.shape, enc_chunks, region, strict=True
173 )
174 )
175
176 nd_aligned_chunks = align_nd_chunks(
177 nd_v_chunks=nd_v_chunks,
178 nd_backend_chunks=nd_grid_chunks,
179 )
180 v = v.chunk(dict(zip(v.dims, nd_aligned_chunks, strict=True)))
181 return v
182
183
184def validate_grid_chunks_alignment(

Callers 2

set_variablesMethod · 0.90
test_grid_rechunkFunction · 0.90

Calls 3

build_grid_chunksFunction · 0.85
align_nd_chunksFunction · 0.85
chunkMethod · 0.45

Tested by 1

test_grid_rechunkFunction · 0.72

Used in the wild real call sites across dependent graphs

searching dependent graphs…