This is a pre-release version (2.0.0.dev0+git20260907.41eeb59).Go to latest (1.18.0)
{ } Raw JSON

bundles / scipy 2.0.0.dev0+git20260907.41eeb59 / scipy / sparse / _construct / block_array

function

scipy.sparse._construct:block_array

source: build-install/usr/lib/python3.14/site-packages/scipy/sparse/_construct.py:1288

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

Sparse array formed from specified blocks.

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()
✓
array([[1, 2, 5],
       [3, 4, 6],
       [0, 0, 7]])
block_array([[A, None], [None, C]]).toarray()
✓
array([[1, 2, 0],
       [3, 4, 0],
       [0, 0, 7]])

See also

block_diag

specify blocks along the main diagonals

diags

specify (possibly offset) diagonals

Aliases

  • scipy.sparse.block_array

Referenced by