Share boundaries between neighboring blocks Parameters ---------- x: da.Array A dask array depth: dict The size of the shared boundary per axis boundary: dict The boundary condition on each axis. Options are 'reflect', 'periodic', 'nearest', 'non
(x, depth, boundary, *, allow_rechunk=True)
| 388 | |
| 389 | |
| 390 | def overlap(x, depth, boundary, *, allow_rechunk=True): |
| 391 | """Share boundaries between neighboring blocks |
| 392 | |
| 393 | Parameters |
| 394 | ---------- |
| 395 | |
| 396 | x: da.Array |
| 397 | A dask array |
| 398 | depth: dict |
| 399 | The size of the shared boundary per axis |
| 400 | boundary: dict |
| 401 | The boundary condition on each axis. Options are 'reflect', 'periodic', |
| 402 | 'nearest', 'none', or an array value. Such a value will fill the |
| 403 | boundary with that value. |
| 404 | allow_rechunk: bool, keyword only |
| 405 | Allows rechunking, otherwise chunk sizes need to match and core |
| 406 | dimensions are to consist only of one chunk. |
| 407 | |
| 408 | The depth input informs how many cells to overlap between neighboring |
| 409 | blocks ``{0: 2, 2: 5}`` means share two cells in 0 axis, 5 cells in 2 axis. |
| 410 | Axes missing from this input will not be overlapped. |
| 411 | |
| 412 | Any axis containing chunks smaller than depth will be rechunked if |
| 413 | possible, provided the keyword ``allow_rechunk`` is True (recommended). |
| 414 | |
| 415 | Examples |
| 416 | -------- |
| 417 | >>> import numpy as np |
| 418 | >>> import dask.array as da |
| 419 | |
| 420 | >>> x = np.arange(64).reshape((8, 8)) |
| 421 | >>> d = da.from_array(x, chunks=(4, 4)) |
| 422 | >>> d.chunks |
| 423 | ((4, 4), (4, 4)) |
| 424 | |
| 425 | >>> g = da.overlap.overlap(d, depth={0: 2, 1: 1}, |
| 426 | ... boundary={0: 100, 1: 'reflect'}) |
| 427 | >>> g.chunks |
| 428 | ((8, 8), (6, 6)) |
| 429 | |
| 430 | >>> np.array(g) |
| 431 | array([[100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100], |
| 432 | [100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100], |
| 433 | [ 0, 0, 1, 2, 3, 4, 3, 4, 5, 6, 7, 7], |
| 434 | [ 8, 8, 9, 10, 11, 12, 11, 12, 13, 14, 15, 15], |
| 435 | [ 16, 16, 17, 18, 19, 20, 19, 20, 21, 22, 23, 23], |
| 436 | [ 24, 24, 25, 26, 27, 28, 27, 28, 29, 30, 31, 31], |
| 437 | [ 32, 32, 33, 34, 35, 36, 35, 36, 37, 38, 39, 39], |
| 438 | [ 40, 40, 41, 42, 43, 44, 43, 44, 45, 46, 47, 47], |
| 439 | [ 16, 16, 17, 18, 19, 20, 19, 20, 21, 22, 23, 23], |
| 440 | [ 24, 24, 25, 26, 27, 28, 27, 28, 29, 30, 31, 31], |
| 441 | [ 32, 32, 33, 34, 35, 36, 35, 36, 37, 38, 39, 39], |
| 442 | [ 40, 40, 41, 42, 43, 44, 43, 44, 45, 46, 47, 47], |
| 443 | [ 48, 48, 49, 50, 51, 52, 51, 52, 53, 54, 55, 55], |
| 444 | [ 56, 56, 57, 58, 59, 60, 59, 60, 61, 62, 63, 63], |
| 445 | [100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100], |
| 446 | [100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100]]) |
| 447 | """ |
searching dependent graphs…