You are viewing an older version (1.17.1).Go to latest (1.18.0)
{ } Raw JSON

bundles / scipy 1.17.1 / scipy / sparse / _construct / block_array

function

scipy.sparse._construct:block_array

source: /scipy/sparse/_construct.py:1171

Signature

def block_array(blocks, *, format = None, dtype = None)

Summary

Build a sparse array from sparse sub-blocks

Parameters

blocks : array_like

Grid of sparse arrays with compatible shapes. An entry of None implies an all-zero array.

format : {'bsr', 'coo', 'csc', 'csr', 'dia', 'dok', 'lil'}, optional

The sparse format of the result (e.g. "csr"). By default an appropriate sparse array format is returned. This choice is subject to change.

dtype : dtype, optional

The data-type of the output array. If not given, the dtype is determined from that of blocks.

Returns

block : sparse array

Examples

from scipy.sparse import coo_array, block_array
A = coo_array([[1, 2], [3, 4]])
B = coo_array([[5], [6]])
C = coo_array([[7]])
block_array([[A, B], [None, C]]).toarray()
✓
block_array([[A, None], [None, C]]).toarray()
✓

See also

block_diag

specify blocks along the main diagonals

diags

specify (possibly offset) diagonals

Aliases

  • scipy.sparse.block_array

Referenced by