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

Function block

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

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

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