Map a function over blocks of arrays with some overlap We share neighboring zones between blocks of the array, map a function, and then trim away the neighboring strips. If depth is larger than any chunk along a particular axis, then the array is rechunked. Note that this funct
(
func,
*args,
depth=None,
boundary=None,
trim=True,
align_arrays=True,
allow_rechunk=True,
**kwargs,
)
| 499 | |
| 500 | |
| 501 | def map_overlap( |
| 502 | func, |
| 503 | *args, |
| 504 | depth=None, |
| 505 | boundary=None, |
| 506 | trim=True, |
| 507 | align_arrays=True, |
| 508 | allow_rechunk=True, |
| 509 | **kwargs, |
| 510 | ): |
| 511 | """Map a function over blocks of arrays with some overlap |
| 512 | |
| 513 | We share neighboring zones between blocks of the array, map a |
| 514 | function, and then trim away the neighboring strips. If depth is |
| 515 | larger than any chunk along a particular axis, then the array is |
| 516 | rechunked. |
| 517 | |
| 518 | Note that this function will attempt to automatically determine the output |
| 519 | array type before computing it, please refer to the ``meta`` keyword argument |
| 520 | in ``map_blocks`` if you expect that the function will not succeed when |
| 521 | operating on 0-d arrays. |
| 522 | |
| 523 | Parameters |
| 524 | ---------- |
| 525 | func: function |
| 526 | The function to apply to each extended block. |
| 527 | If multiple arrays are provided, then the function should expect to |
| 528 | receive chunks of each array in the same order. |
| 529 | args : dask arrays |
| 530 | depth: int, tuple, dict or list, keyword only |
| 531 | The number of elements that each block should share with its neighbors |
| 532 | If a tuple or dict then this can be different per axis. |
| 533 | If a list then each element of that list must be an int, tuple or dict |
| 534 | defining depth for the corresponding array in `args`. |
| 535 | Asymmetric depths may be specified using a dict value of (-/+) tuples. |
| 536 | Note that asymmetric depths are currently only supported when |
| 537 | ``boundary`` is 'none'. |
| 538 | The default value is 0. |
| 539 | boundary: str, tuple, dict or list, keyword only |
| 540 | How to handle the boundaries. |
| 541 | Values include 'reflect', 'periodic', 'nearest', 'none', |
| 542 | or any constant value like 0 or np.nan. |
| 543 | If a list then each element must be a str, tuple or dict defining the |
| 544 | boundary for the corresponding array in `args`. |
| 545 | trim: bool, keyword only |
| 546 | Whether or not to trim ``depth`` elements from each block after |
| 547 | calling the map function. |
| 548 | Set this to False if your mapping function already does this for you |
| 549 | align_arrays: bool, keyword only |
| 550 | Whether or not to align chunks along equally sized dimensions when |
| 551 | multiple arrays are provided. This allows for larger chunks in some |
| 552 | arrays to be broken into smaller ones that match chunk sizes in other |
| 553 | arrays such that they are compatible for block function mapping. If |
| 554 | this is false, then an error will be thrown if arrays do not already |
| 555 | have the same number of blocks in each dimension. |
| 556 | allow_rechunk: bool, keyword only |
| 557 | Allows rechunking, otherwise chunk sizes need to match and core |
| 558 | dimensions are to consist only of one chunk. |
no test coverage detected