This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from scipy import sparse | |
def permute_sparse_matrix(M, row_order=None, col_order=None): | |
""" | |
Reorders the rows and/or columns in a scipy sparse matrix to the specified order. | |
""" | |
if row_order is None and col_order is None: | |
return M | |
new_M = M |