# dask.array.block

### dask.array.block(arrays, allow_unknown_chunksizes=False)

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 will not be broadcasted using the normal
rules. Instead, leading axes of size 1 are inserted, to make `block.ndim`
the same for all blocks. This is primarily useful for working with scalars,
and means that code like `block([v, 1])` is valid, where
`v.ndim == 1`.

When the nested list is two levels deep, this allows block matrices to be
constructed from their components.

* **Parameters:**
  **arrays**
  : If passed a single ndarray or scalar (a nested list of depth 0), this
    is returned unmodified (and not copied).
    <br/>
    Elements shapes must match along the appropriate axes (without
    broadcasting), but leading 1s will be prepended to the shape as
    necessary to make the dimensions match.

  **allow_unknown_chunksizes: bool**
  : Allow unknown chunksizes, such as come from converting from dask
    dataframes.  Dask.array is unable to verify that chunks line up.  If
    data comes from differently aligned sources then this can cause
    unexpected results.
* **Returns:**
  **block_array**
  : The array assembled from the given blocks.
    <br/>
    The dimensionality of the output is equal to the greatest of:
    \* the dimensionality of all the inputs
    \* the depth to which the input list is nested
* **Raises:**
  ValueError
  : * If list depths are mismatched - for instance, `[[a, b], c]` is
      illegal, and should be spelt `[[a, b], [c]]`
    * If lists are empty - for instance, `[[a, b], []]`

#### SEE ALSO
[`concatenate`](dask.array.concatenate.html.md#dask.array.concatenate)
: Join a sequence of arrays together.

[`stack`](dask.array.stack.html.md#dask.array.stack)
: Stack arrays in sequence along a new dimension.

[`hstack`](dask.array.hstack.html.md#dask.array.hstack)
: Stack arrays in sequence horizontally (column wise).

[`vstack`](dask.array.vstack.html.md#dask.array.vstack)
: Stack arrays in sequence vertically (row wise).

[`dstack`](dask.array.dstack.html.md#dask.array.dstack)
: Stack arrays in sequence depth wise (along third dimension).

`vsplit`
: Split array into a list of multiple sub-arrays vertically.

### Notes

When called with only scalars, `block` is equivalent to an ndarray
call. So `block([[1, 2], [3, 4]])` is equivalent to
`array([[1, 2], [3, 4]])`.

This function does not enforce that the blocks lie on a fixed grid.
`block([[a, b], [c, d]])` is not restricted to arrays of the form:

```default
AAAbb
AAAbb
cccDD
```

But is also allowed to produce, for some `a, b, c, d`:

```default
AAAbb
AAAbb
cDDDD
```

Since concatenation happens along the last axis first, block is \_not_
capable of producing the following directly:

```default
AAAbb
cccbb
cccDD
```

Matlab’s “square bracket stacking”, `[A, B, ...; p, q, ...]`, is
equivalent to `block([[A, B, ...], [p, q, ...]])`.

<!-- !! processed by numpydoc !! -->
