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

Function block

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

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

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