Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

An assertion in the method compute_perm is not doing what it should do #42

Open
nbro opened this issue Apr 21, 2019 · 3 comments
Open

Comments

@nbro
Copy link

nbro commented Apr 21, 2019

At the following line, https://github.com/mdeff/cnn_graph/blob/master/lib/coarsening.py#L210, you have the assertion assert len(indices[0] == M), but this is always true, because indices[0] is not empty and indices[0] == M produces another list of the same size as indices[0], so len(indices[0] == M) is always greater than zero.

@mdeff
Copy link
Owner

mdeff commented Jul 20, 2020

Thanks. It should be assert len(indices[0]) == M right?

@nbro
Copy link
Author

nbro commented Jul 20, 2020

@mdeff To be honest, I don't know. It's been a long time since I tried it.

@mdeff
Copy link
Owner

mdeff commented Jul 20, 2020

Me too 🙈

For reference, here's what I have from a later iteration of this code:

def test_permutations():
    parents = [np.array([4, 1, 1, 2, 2, 3, 0, 0, 3]),
               np.array([2, 1, 0, 1, 0])]
    permutations = compute_permutations(parents)
    assert permutations[0] == [3, 4, 0, 9, 1, 2, 5, 8, 6, 7, 10, 11]
    assert permutations[1] == [2, 4, 1, 3, 0, 5]
    assert permutations[2] == [0, 1, 2]
test_permutations()

adjacency = sparse.random(100, 100, density=0.01, format='csr')
adjacency = adjacency + adjacency.T

def test_permutations(adjacency, levels):
    _, parents = coarsen(adjacency, levels)
    permutations = compute_permutations(parents)
    n_nodes = len(permutations[0])
    for level in range(levels):
        n_nodes_level = n_nodes // 2**level
        assert sorted(permutations[level]) == list(range(n_nodes_level))
test_permutations(adjacency, levels=5)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants