MCPcopy
hub / github.com/dask/dask / block

Function block

dask/array/core.py:4452–4615  ·  view source on GitHub ↗

Assemble an nd-array from nested lists of blocks. Blocks in the innermost lists are concatenated along the last dimension (-1), then these are concatenated along the second-last dimension (-2), and so on until the outermost list is reached Blocks can be of any dimension, but w

(arrays, allow_unknown_chunksizes=False)

Source from the content-addressed store, hash-verified

4450
4451
4452def block(arrays, allow_unknown_chunksizes=False):
4453 """
4454 Assemble an nd-array from nested lists of blocks.
4455
4456 Blocks in the innermost lists are concatenated along the last
4457 dimension (-1), then these are concatenated along the second-last
4458 dimension (-2), and so on until the outermost list is reached
4459
4460 Blocks can be of any dimension, but will not be broadcasted using the normal
4461 rules. Instead, leading axes of size 1 are inserted, to make ``block.ndim``
4462 the same for all blocks. This is primarily useful for working with scalars,
4463 and means that code like ``block([v, 1])`` is valid, where
4464 ``v.ndim == 1``.
4465
4466 When the nested list is two levels deep, this allows block matrices to be
4467 constructed from their components.
4468
4469 Parameters
4470 ----------
4471 arrays : nested list of array_like or scalars (but not tuples)
4472 If passed a single ndarray or scalar (a nested list of depth 0), this
4473 is returned unmodified (and not copied).
4474
4475 Elements shapes must match along the appropriate axes (without
4476 broadcasting), but leading 1s will be prepended to the shape as
4477 necessary to make the dimensions match.
4478
4479 allow_unknown_chunksizes: bool
4480 Allow unknown chunksizes, such as come from converting from dask
4481 dataframes. Dask.array is unable to verify that chunks line up. If
4482 data comes from differently aligned sources then this can cause
4483 unexpected results.
4484
4485 Returns
4486 -------
4487 block_array : ndarray
4488 The array assembled from the given blocks.
4489
4490 The dimensionality of the output is equal to the greatest of:
4491 * the dimensionality of all the inputs
4492 * the depth to which the input list is nested
4493
4494 Raises
4495 ------
4496 ValueError
4497 * If list depths are mismatched - for instance, ``[[a, b], c]`` is
4498 illegal, and should be spelt ``[[a, b], [c]]``
4499 * If lists are empty - for instance, ``[[a, b], []]``
4500
4501 See Also
4502 --------
4503 concatenate : Join a sequence of arrays together.
4504 stack : Stack arrays in sequence along a new dimension.
4505 hstack : Stack arrays in sequence horizontally (column wise).
4506 vstack : Stack arrays in sequence vertically (row wise).
4507 dstack : Stack arrays in sequence depth wise (along third dimension).
4508 vsplit : Split array into a list of multiple sub-arrays vertically.
4509

Callers 3

tileFunction · 0.90
pad_reuseFunction · 0.90
pad_statsFunction · 0.90

Calls 7

_RecurserClass · 0.90
maxFunction · 0.90
format_indexFunction · 0.85
atleast_ndFunction · 0.85
map_reduceMethod · 0.80
concatenateFunction · 0.70
walkMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…