Exemple #1
0
def test_collapse_edges():
    st = SimplexTree()

    assert st.insert([0, 1], filtration=1.0) == True
    assert st.insert([1, 2], filtration=1.0) == True
    assert st.insert([2, 3], filtration=1.0) == True
    assert st.insert([0, 3], filtration=1.0) == True
    assert st.insert([0, 2], filtration=2.0) == True
    assert st.insert([1, 3], filtration=2.0) == True

    assert st.num_simplices() == 10

    st.collapse_edges()
    assert st.num_simplices() == 9
    assert st.find([1, 3]) == False
    for simplex in st.get_skeleton(0):
        assert simplex[1] == 1.
Exemple #2
0
def test_collapse_edges():
    st = SimplexTree()

    assert st.insert([0, 1], filtration=1.0) == True
    assert st.insert([1, 2], filtration=1.0) == True
    assert st.insert([2, 3], filtration=1.0) == True
    assert st.insert([0, 3], filtration=1.0) == True
    assert st.insert([0, 2], filtration=2.0) == True
    assert st.insert([1, 3], filtration=2.0) == True

    assert st.num_simplices() == 10

    if __GUDHI_USE_EIGEN3:
        st.collapse_edges()
        assert st.num_simplices() == 9
        assert st.find([1, 3]) == False
        for simplex in st.get_skeleton(0):
            assert simplex[1] == 1.
    else:
        # If no Eigen3, collapse_edges throws an exception
        with pytest.raises(RuntimeError):
            st.collapse_edges()