Concatenate the multidimensional chunks of an array. Can be used on chunks with unknown sizes. Parameters ---------- x : dask array Returns ------- dask array The concatenated dask array with one chunk.
(x)
| 1426 | |
| 1427 | |
| 1428 | def concatenate_array_chunks(x): |
| 1429 | """Concatenate the multidimensional chunks of an array. |
| 1430 | |
| 1431 | Can be used on chunks with unknown sizes. |
| 1432 | |
| 1433 | Parameters |
| 1434 | ---------- |
| 1435 | x : dask array |
| 1436 | |
| 1437 | Returns |
| 1438 | ------- |
| 1439 | dask array |
| 1440 | The concatenated dask array with one chunk. |
| 1441 | |
| 1442 | """ |
| 1443 | from dask.array.core import Array, concatenate_shaped |
| 1444 | |
| 1445 | if x.npartitions == 1: |
| 1446 | return x |
| 1447 | |
| 1448 | name = "concatenate-shaped-" + tokenize(x) |
| 1449 | d = { |
| 1450 | (name, 0): ( |
| 1451 | concatenate_shaped, |
| 1452 | list(core.flatten(x.__dask_keys__())), |
| 1453 | x.numblocks, |
| 1454 | ) |
| 1455 | } |
| 1456 | graph = HighLevelGraph.from_collections(name, d, dependencies=[x]) |
| 1457 | chunks = x.shape |
| 1458 | if not chunks: |
| 1459 | chunks = (1,) |
| 1460 | |
| 1461 | return Array(graph, name, chunks=(chunks,), dtype=x.dtype) |
| 1462 | |
| 1463 | |
| 1464 | def setitem_array(out_name, array, indices, value): |
no test coverage detected
searching dependent graphs…