Ejemplo n.º 1
0
def test_output(flag_file):
    adjacency_matrix = load_unweighted_flag(flag_file, fmt='coo')
    res = flagser_unweighted(adjacency_matrix)
    betti_exp = betti[os.path.split(flag_file)[1]]
    betti_res = res["betti"]
    assert_almost_equal(betti_res, betti_exp)

    cell_count_exp = cell_count[os.path.split(flag_file)[1]]
    cell_count_res = res["cell_count"]
    assert_almost_equal(cell_count_res, cell_count_exp)
Ejemplo n.º 2
0
def compute(tribes, adj_matrix, conv, precision):

    # Normalized Betti coefficients
    nbcs = []
    pbar = progressbar.ProgressBar()

    for tribe in pbar(tribes):

        # Convert from GIDs to local indexing
        tribe_local_indices = conv.indices(tribe)

        adj_submat = adj_matrix[np.ix_(tribe_local_indices, tribe_local_indices)]
        bettinumbers = pyflagser.flagser_unweighted(adj_submat, directed=True)['betti']
        cellcounts = pyflagser.flagser_unweighted(adj_submat, directed=True)['cell_count']

        parameter = sum(list(map(lambda x: (x+1)*bettinumbers[x]/cellcounts[x]
                                 if cellcounts[x] != 0 else 0,
                                 range(min(len(bettinumbers), len(cellcounts))))))
        nbcs.append(np.round(parameter,precision))

    return nbcs
Ejemplo n.º 3
0
def compute(tribes, adj_matrix, conv, precision):

    ec = []
    pbar = progressbar.ProgressBar()

    for tribe in pbar(tribes):
        # Convert from GIDs to local indexing
        tribe_local_indices = conv.indices(tribe)

        adj_submat = adj_matrix[np.ix_(tribe_local_indices,
                                       tribe_local_indices)]
        ec.append(
            pyflagser.flagser_unweighted(adj_submat, directed=True)['euler'])

    return ec
def compute(adj_sumatrix, parameter="euler", index=None):
    res = pyflagser.flagser_unweighted(adj_sumatrix, directed=True)[parameter]
    if index is not None:
        res = res[index]
    return res
Ejemplo n.º 5
0
def test_huge_graphs():
    """Regression test for issue #65"""
    from scipy.sparse import coo_matrix
    x = coo_matrix(([1], ([0], [1])), shape=(2**16, 2**16))
    flagser_unweighted(x)