def triu2flat(m):
    """ Flattens an upper triangular matrix, returning a vector of the
    non-zero elements. """
    dim = m.shape[0]
    res = zeros(dim * (dim + 1) / 2)
    index = 0
    for row in range(dim):
        res[index:index + dim - row] = m[row, row:]
        index += row - dim
    return res
dataset/ETHPy150Open pybrain/pybrain/pybrain/utilities.py/triu2flat/swapped operands of `-`