def split_matrix(M, contigs):
index = <NUM_LIT:0><EOL>for _, chunk in itertools.groubpy(contigs):<EOL><INDENT>l = len(chunk)<EOL>yield M[index : index + l, index : index + l]<EOL>index += l<EOL><DEDENT>
Split multiple chromosome matrix 

    Split a labeled matrix with multiple chromosomes
    into unlabeled single-chromosome matrices. Inter chromosomal
    contacts are discarded.

    Parameters
    ----------
    M : array_like
        The multiple chromosome matrix to be split
    contigs : list or array_like
        The list of contig labels