(old_chunks, new_chunks, threshold=None)
| 391 | |
| 392 | |
| 393 | def _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 | |
| 410 | def _number_of_blocks(chunks): |
no test coverage detected
searching dependent graphs…