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

Function add_dummy_padding

dask/array/overlap.py:464–498  ·  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

462
463
464def add_dummy_padding(x, depth, boundary):
465 """
466 Pads an array which has 'none' as the boundary type.
467 Used to simplify trimming arrays which use 'none'.
468
469 >>> import dask.array as da
470 >>> x = da.arange(6, chunks=3)
471 >>> add_dummy_padding(x, {0: 1}, {0: 'none'}).compute() # doctest: +NORMALIZE_WHITESPACE
472 array([..., 0, 1, 2, 3, 4, 5, ...])
473 """
474 for k, v in boundary.items():
475 d = depth.get(k, 0)
476 if v == "none" and d > 0:
477 empty_shape = list(x.shape)
478 empty_shape[k] = d
479
480 empty_chunks = list(x.chunks)
481 empty_chunks[k] = (d,)
482
483 empty = empty_like(
484 getattr(x, "_meta", x),
485 shape=empty_shape,
486 chunks=empty_chunks,
487 dtype=x.dtype,
488 )
489
490 out_chunks = list(x.chunks)
491 ax_chunks = list(out_chunks[k])
492 ax_chunks[0] += d
493 ax_chunks[-1] += d
494 out_chunks[k] = tuple(ax_chunks)
495
496 x = concatenate([empty, x, empty], axis=k)
497 x = x.rechunk(out_chunks)
498 return x
499
500
501def 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…