SciPy

scipy.sparse.bsr_matrix.diagonal

bsr_matrix.diagonal()[source]

Returns the main diagonal of the matrix