MCPcopy Index your code
hub / github.com/dask/dask / map_blocks

Function map_blocks

dask/array/_array_expr/_map_blocks.py:16–491  ·  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

14
15
16def map_blocks(
17 func,
18 *args,
19 name=None,
20 token=None,
21 dtype=None,
22 chunks=None,
23 drop_axis=None,
24 new_axis=None,
25 enforce_ndim=False,
26 meta=None,
27 **kwargs,
28):
29 """Map a function across all blocks of a dask array.
30
31 Note that ``map_blocks`` will attempt to automatically determine the output
32 array type by calling ``func`` on 0-d versions of the inputs. Please refer to
33 the ``meta`` keyword argument below if you expect that the function will not
34 succeed when operating on 0-d arrays.
35
36 Parameters
37 ----------
38 func : callable
39 Function to apply to every block in the array.
40 If ``func`` accepts ``block_info=`` or ``block_id=``
41 as keyword arguments, these will be passed dictionaries
42 containing information about input and output chunks/arrays
43 during computation. See examples for details.
44 args : dask arrays or other objects
45 dtype : np.dtype, optional
46 The ``dtype`` of the output array. It is recommended to provide this.
47 If not provided, will be inferred by applying the function to a small
48 set of fake data.
49 chunks : tuple, optional
50 Chunk shape of resulting blocks if the function does not preserve
51 shape. If not provided, the resulting array is assumed to have the same
52 block structure as the first input array.
53 drop_axis : number or iterable, optional
54 Dimensions lost by the function.
55 new_axis : number or iterable, optional
56 New dimensions created by the function. Note that these are applied
57 after ``drop_axis`` (if present). The size of each chunk along this
58 dimension will be set to 1. Please specify ``chunks`` if the individual
59 chunks have a different size.
60 enforce_ndim : bool, default False
61 Whether to enforce at runtime that the dimensionality of the array
62 produced by ``func`` actually matches that of the array returned by
63 ``map_blocks``.
64 If True, this will raise an error when there is a mismatch.
65 token : string, optional
66 The key prefix to use for the output array. If not provided, will be
67 determined from the function name.
68 name : string, optional
69 The key name to use for the output array. Note that this fully
70 specifies the output key name, and must be unique. If not provided,
71 will be determined by a hash of the arguments.
72 meta : array-like, optional
73 The ``meta`` of the output array, when specified is expected to be an

Callers 3

trim_internalFunction · 0.90
map_overlapFunction · 0.90
map_blocksMethod · 0.90

Calls 13

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

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…