MCPcopy Create free account
hub / github.com/dask/dask / map_blocks

Function map_blocks

dask/array/core.py:546–1020  ·  view source on GitHub ↗

Map a function across all blocks of a dask array. Note that ``map_blocks`` will attempt to automatically determine the output array type by calling ``func`` on 0-d versions of the inputs. Please refer to the ``meta`` keyword argument below if you expect that the function will not su

(
    func,
    *args,
    name=None,
    token=None,
    dtype=None,
    chunks=None,
    drop_axis=None,
    new_axis=None,
    enforce_ndim=False,
    meta=None,
    **kwargs,
)

Source from the content-addressed store, hash-verified

544
545
546def map_blocks(
547 func,
548 *args,
549 name=None,
550 token=None,
551 dtype=None,
552 chunks=None,
553 drop_axis=None,
554 new_axis=None,
555 enforce_ndim=False,
556 meta=None,
557 **kwargs,
558):
559 """Map a function across all blocks of a dask array.
560
561 Note that ``map_blocks`` will attempt to automatically determine the output
562 array type by calling ``func`` on 0-d versions of the inputs. Please refer to
563 the ``meta`` keyword argument below if you expect that the function will not
564 succeed when operating on 0-d arrays.
565
566 Parameters
567 ----------
568 func : callable
569 Function to apply to every block in the array.
570 If ``func`` accepts ``block_info=`` or ``block_id=``
571 as keyword arguments, these will be passed dictionaries
572 containing information about input and output chunks/arrays
573 during computation. See examples for details.
574 args : dask arrays or other objects
575 dtype : np.dtype, optional
576 The ``dtype`` of the output array. It is recommended to provide this.
577 If not provided, will be inferred by applying the function to a small
578 set of fake data.
579 chunks : tuple, optional
580 Chunk shape of resulting blocks if the function does not preserve
581 shape. If not provided, the resulting array is assumed to have the same
582 block structure as the first input array.
583 drop_axis : number or iterable, optional
584 Dimensions lost by the function.
585 new_axis : number or iterable, optional
586 New dimensions created by the function. Note that these are applied
587 after ``drop_axis`` (if present). The size of each chunk along this
588 dimension will be set to 1. Please specify ``chunks`` if the individual
589 chunks have a different size.
590 enforce_ndim : bool, default False
591 Whether to enforce at runtime that the dimensionality of the array
592 produced by ``func`` actually matches that of the array returned by
593 ``map_blocks``.
594 If True, this will raise an error when there is a mismatch.
595 token : string, optional
596 The key prefix to use for the output array. If not provided, will be
597 determined from the function name.
598 name : string, optional
599 The key name to use for the output array. Note that this fully
600 specifies the output key name, and must be unique. If not provided,
601 will be determined by a hash of the arguments.
602 meta : array-like, optional
603 The ``meta`` of the output array, when specified is expected to be an

Callers 6

masked_valuesFunction · 0.90
trim_internalFunction · 0.90
map_overlapFunction · 0.90
aroundFunction · 0.90
piecewiseFunction · 0.90
map_blocksMethod · 0.70

Calls 13

funcnameFunction · 0.90
maxFunction · 0.90
compute_metaFunction · 0.90
anyFunction · 0.90
blockwiseFunction · 0.90
has_keywordFunction · 0.90
ArrayBlockIdDepClass · 0.90
ArrayValuesDepClass · 0.90
cached_cumsumFunction · 0.90
apply_infer_dtypeFunction · 0.85
concatFunction · 0.50
itemsMethod · 0.45

Tested by

no test coverage detected