SciPy

scipy.sparse.bsr_matrix.reshape

bsr_matrix.reshape(self, shape, order='C', copy=False)[source]

Gives a new shape to a sparse matrix without changing its data.

Parameters:
shape : length-2 tuple of ints

The new shape should be compatible with the original shape.

order : {‘C’, ‘F’}, optional

Read the elements using this index order. ‘C’ means to read and write the elements using C-like index order; e.g. read entire first row, then second row, etc. ‘F’ means to read and write the elements using Fortran-like index order; e.g. read entire first column, then second column, etc.

copy : bool, optional

Indicates whether or not attributes of self should be copied whenever possible. The degree to which attributes are copied varies depending on the type of sparse matrix being used.

Returns:
reshaped_matrix : sparse matrix

A sparse matrix with the given shape, not necessarily of the same format as the current object.

See also

np.matrix.reshape
NumPy’s implementation of ‘reshape’ for matrices