MCPcopy Index your code
hub / github.com/dask/dask / intersect_chunks

Function intersect_chunks

dask/array/rechunk.py:218–240  ·  view source on GitHub ↗

Make dask.array slices as intersection of old and new chunks. >>> intersections = intersect_chunks(((4, 4), (2,)), ... ((8,), (1, 1))) >>> list(intersections) # doctest: +NORMALIZE_WHITESPACE [(((0, slice(0, 4, None)), (0, slice(0, 1, None))),

(old_chunks, new_chunks)

Source from the content-addressed store, hash-verified

216
217
218def intersect_chunks(old_chunks, new_chunks):
219 """
220 Make dask.array slices as intersection of old and new chunks.
221
222 >>> intersections = intersect_chunks(((4, 4), (2,)),
223 ... ((8,), (1, 1)))
224 >>> list(intersections) # doctest: +NORMALIZE_WHITESPACE
225 [(((0, slice(0, 4, None)), (0, slice(0, 1, None))),
226 ((1, slice(0, 4, None)), (0, slice(0, 1, None)))),
227 (((0, slice(0, 4, None)), (0, slice(1, 2, None))),
228 ((1, slice(0, 4, None)), (0, slice(1, 2, None))))]
229
230 Parameters
231 ----------
232
233 old_chunks : iterable of tuples
234 block sizes along each dimension (convert from old_chunks)
235 new_chunks: iterable of tuples
236 block sizes along each dimension (converts to new_chunks)
237 """
238 cross1 = product(*old_to_new(old_chunks, new_chunks))
239 cross = chain(tuple(product(*cr)) for cr in cross1)
240 return cross
241
242
243def _validate_rechunk(old_chunks, new_chunks):

Callers 9

test_intersect_1Function · 0.90
test_intersect_2Function · 0.90
test_intersect_nanFunction · 0.90
test_intersect_nan_longFunction · 0.90
_compute_rechunkFunction · 0.90
_compute_rechunkFunction · 0.85

Calls 1

old_to_newFunction · 0.85

Tested by 7

test_intersect_1Function · 0.72
test_intersect_2Function · 0.72
test_intersect_nanFunction · 0.72
test_intersect_nan_longFunction · 0.72

Used in the wild real call sites across dependent graphs

searching dependent graphs…