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

Function map_blocks

dask/array/core.py:549–1023  ·  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

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