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

Function find_split_rechunk

dask/array/rechunk.py:574–599  ·  view source on GitHub ↗

Find an intermediate rechunk that would split some chunks to get us nearer *new_chunks*, without violating the *graph_size_limit*.

(old_chunks, new_chunks, graph_size_limit)

Source from the content-addressed store, hash-verified

572
573
574def find_split_rechunk(old_chunks, new_chunks, graph_size_limit):
575 """
576 Find an intermediate rechunk that would split some chunks to
577 get us nearer *new_chunks*, without violating the *graph_size_limit*.
578 """
579 ndim = len(old_chunks)
580
581 chunks = list(old_chunks)
582
583 for dim in range(ndim):
584 graph_size = estimate_graph_size(chunks, new_chunks)
585 if graph_size > graph_size_limit:
586 break
587 if len(old_chunks[dim]) > len(new_chunks[dim]):
588 # It's not interesting to split
589 continue
590 # Merge the new chunks so as to stay within the graph size budget
591 max_number = int(len(old_chunks[dim]) * graph_size_limit / graph_size)
592 c = merge_to_number(new_chunks[dim], max_number)
593 assert len(c) <= max_number
594 # Consider the merge successful if its result has a greater length
595 # and smaller max width than the old chunks
596 if len(c) >= len(old_chunks[dim]) and max(c) <= max(old_chunks[dim]):
597 chunks[dim] = c
598
599 return tuple(chunks)
600
601
602def plan_rechunk(

Callers 1

plan_rechunkFunction · 0.85

Calls 3

estimate_graph_sizeFunction · 0.85
merge_to_numberFunction · 0.85
maxFunction · 0.85

Tested by

no test coverage detected