bundles / scipy 1.17.1 / scipy / sparse / _construct / block_array
function
scipy.sparse._construct:block_array
Signature
def block_array ( blocks , * , format = None , dtype = None ) Summary
Build a sparse array from sparse sub-blocks
Parameters
blocks: array_likeGrid of sparse arrays with compatible shapes. An entry of None implies an all-zero array.
format: {'bsr', 'coo', 'csc', 'csr', 'dia', 'dok', 'lil'}, optionalThe 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, optionalThe 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