def writeMatrix(outfile, matrix,
                format="full",
                separator="\t",
                value_format="%f",
                row_headers=None,
                col_headers=None):

    if format == "full":
        if col_headers:
            outfile.write(separator + separator.join(col_headers) + "\n")

        for x in range(0, matrix.shape[0]):
            if row_headers:
                outfile.write(row_headers[x] + separator)
            outfile.write(
                string.join(map(lambda x: value_format % x, matrix[x, ]), separator) + "\n")

    elif format == "phylip":
        if not row_headers:
            raise "phylip output requires row headers."

        nrows = len(row_headers)
        outfile.write("%i\n" % nrows)

        for x in range(0, nrows):
            outfile.write(row_headers[x] + separator)
            outfile.write(
                separator.join([value_format % y for y in matrix[x, ]]) + "\n")

    else:
        raise "unknown output format %s" % output_format
Generates the previous lexicographically ordered subset.
dataset/ETHPy150Open CGATOxford/cgat/CGAT/MatlabTools.py/writeMatrix--crossover with--dataset/ETHPy150Open sympy/sympy/sympy/combinatorics/subsets.py/Subset.prev_lexicographic