MCPcopy
hub / github.com/dask/dask / _choose_rechunk_method

Function _choose_rechunk_method

dask/array/rechunk.py:393–407  ·  view source on GitHub ↗
(old_chunks, new_chunks, threshold=None)

Source from the content-addressed store, hash-verified

391
392
393def _choose_rechunk_method(old_chunks, new_chunks, threshold=None):
394 if method := config.get("array.rechunk.method", None):
395 return method
396 try:
397 from distributed import default_client
398
399 default_client()
400 except (ImportError, ValueError):
401 return "tasks"
402
403 _old_to_new = old_to_new(old_chunks, new_chunks)
404 graph_size = math.prod(sum(len(ins) for ins in axis) for axis in _old_to_new)
405 threshold = threshold or config.get("array.rechunk.threshold")
406 graph_size_threshold = _graph_size_threshold(old_chunks, new_chunks, threshold)
407 return "tasks" if graph_size < graph_size_threshold else "p2p"
408
409
410def _number_of_blocks(chunks):

Callers 2

_lowerMethod · 0.90
rechunkFunction · 0.85

Calls 5

old_to_newFunction · 0.85
_graph_size_thresholdFunction · 0.85
sumFunction · 0.70
getMethod · 0.45
prodMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…