Esempio n. 1
0
def qm_result_matrices(matrices, tmp_mean, multiprocessing=True):
    """builds the resulting matrices by looking at the rank of their
    original values and retrieving the means at the specified position"""
    if multiprocessing:
        # parallelized ranking
        with util.get_mp_pool() as pool:
            results = pool.map(rank_fun, [(matrix.values, matrix.row_names,
                                           matrix.column_names, tmp_mean)
                                          for matrix in matrices])
        return results
    else:
        # non-parallelized
        result = []
        for i in xrange(len(matrices)):
            matrix = matrices[i]
            values = matrix.values
            num_rows, num_cols = values.shape
            rankvals = util.rrank_matrix(values)
            values = np.reshape(tmp_mean[rankvals], (num_rows, num_cols))
            outmatrix = DataMatrix(num_rows,
                                   num_cols,
                                   matrix.row_names,
                                   matrix.column_names,
                                   values=values)
            result.append(outmatrix)
        return result
Esempio n. 2
0
def qm_result_matrices(matrices, tmp_mean, multiprocessing=True):
    """builds the resulting matrices by looking at the rank of their
    original values and retrieving the means at the specified position"""
    if multiprocessing:
        # parallelized ranking
        with util.get_mp_pool() as pool:
            results = pool.map(rank_fun,
                               [(matrix.values, matrix.row_names, matrix.column_names, tmp_mean)
                                for matrix in matrices])
        return results
    else:
        # non-parallelized
        result = []
        for i in xrange(len(matrices)):
            matrix = matrices[i]
            values = matrix.values
            num_rows, num_cols = values.shape
            rankvals = util.rrank_matrix(values)
            values = np.reshape(tmp_mean[rankvals], (num_rows, num_cols))
            outmatrix = DataMatrix(num_rows,
                                   num_cols,
                                   matrix.row_names,
                                   matrix.column_names,
                                   values=values)
            result.append(outmatrix)
        return result
Esempio n. 3
0
def rank_fun(mat_mean):
    """ranking function that is run within Pool.map()"""
    values, row_names, column_names, tmp_mean = mat_mean
    num_rows, num_cols = values.shape
    rankvals = util.rrank_matrix(values)
    values = np.reshape(tmp_mean[rankvals], (num_rows, num_cols))
    return DataMatrix(num_rows, num_cols, row_names, column_names,
                      values=values)
Esempio n. 4
0
def rank_fun(mat_mean):
    """ranking function that is run within Pool.map()"""
    values, row_names, column_names, tmp_mean = mat_mean
    num_rows, num_cols = values.shape
    rankvals = util.rrank_matrix(values)
    values = np.reshape(tmp_mean[rankvals], (num_rows, num_cols))
    return DataMatrix(num_rows,
                      num_cols,
                      row_names,
                      column_names,
                      values=values)