MCPcopy
hub / github.com/dask/dask / add_dummy_padding

Function add_dummy_padding

dask/array/_array_expr/_overlap.py:478–512  ·  view source on GitHub ↗

Pads an array which has 'none' as the boundary type. Used to simplify trimming arrays which use 'none'. >>> import dask.array as da >>> x = da.arange(6, chunks=3) >>> add_dummy_padding(x, {0: 1}, {0: 'none'}).compute() # doctest: +NORMALIZE_WHITESPACE array([..., 0, 1, 2,

(x, depth, boundary)

Source from the content-addressed store, hash-verified

476
477
478def add_dummy_padding(x, depth, boundary):
479 """
480 Pads an array which has 'none' as the boundary type.
481 Used to simplify trimming arrays which use 'none'.
482
483 >>> import dask.array as da
484 >>> x = da.arange(6, chunks=3)
485 >>> add_dummy_padding(x, {0: 1}, {0: 'none'}).compute() # doctest: +NORMALIZE_WHITESPACE
486 array([..., 0, 1, 2, 3, 4, 5, ...])
487 """
488 for k, v in boundary.items():
489 d = depth.get(k, 0)
490 if v == "none" and d > 0:
491 empty_shape = list(x.shape)
492 empty_shape[k] = d
493
494 empty_chunks = list(x.chunks)
495 empty_chunks[k] = (d,)
496
497 empty = empty_like(
498 getattr(x, "_meta", x),
499 shape=empty_shape,
500 chunks=empty_chunks,
501 dtype=x.dtype,
502 )
503
504 out_chunks = list(x.chunks)
505 ax_chunks = list(out_chunks[k])
506 ax_chunks[0] += d
507 ax_chunks[-1] += d
508 out_chunks[k] = tuple(ax_chunks)
509
510 x = concatenate([empty, x, empty], axis=k)
511 x = x.rechunk(out_chunks)
512 return x
513
514
515def map_overlap(

Callers

nothing calls this directly

Calls 5

empty_likeFunction · 0.90
concatenateFunction · 0.90
itemsMethod · 0.45
getMethod · 0.45
rechunkMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…