diff options
author | Marc Glisse <marc.glisse@inria.fr> | 2022-04-01 23:52:15 +0200 |
---|---|---|
committer | Marc Glisse <marc.glisse@inria.fr> | 2022-04-01 23:52:15 +0200 |
commit | b28c83f63ca5d6437fa0a234ad3a1be692f07999 (patch) | |
tree | ccc98325230cd4212ca50aaebf3953dfe630a682 /src/python/test/test_simplex_tree.py | |
parent | 67b1e0ae09d8a975fb72faad1ee9b2f15f22e635 (diff) | |
parent | b066b4376abf66ddc76e61a6a815a409b05fe59b (diff) |
Merge remote-tracking branch 'origin/master' into insert
Diffstat (limited to 'src/python/test/test_simplex_tree.py')
-rwxr-xr-x | src/python/test/test_simplex_tree.py | 46 |
1 files changed, 46 insertions, 0 deletions
diff --git a/src/python/test/test_simplex_tree.py b/src/python/test/test_simplex_tree.py index a5b8ffe0..15279c28 100755 --- a/src/python/test/test_simplex_tree.py +++ b/src/python/test/test_simplex_tree.py @@ -600,3 +600,49 @@ def test_insert_batch(): ([5, 6], 4.0), ([2, 5, 6], 4.0), ] + + +def test_expansion_with_blocker(): + st = SimplexTree() + st.insert([0, 1], 0) + st.insert([0, 2], 1) + st.insert([0, 3], 2) + st.insert([1, 2], 3) + st.insert([1, 3], 4) + st.insert([2, 3], 5) + st.insert([2, 4], 6) + st.insert([3, 6], 7) + st.insert([4, 5], 8) + st.insert([4, 6], 9) + st.insert([5, 6], 10) + st.insert([6], 10) + + def blocker(simplex): + try: + # Block all simplices that countains vertex 6 + simplex.index(6) + print(simplex, " is blocked") + return True + except ValueError: + print(simplex, " is accepted") + st.assign_filtration(simplex, st.filtration(simplex) + 1.0) + return False + + st.expansion_with_blocker(2, blocker) + assert st.num_simplices() == 22 + assert st.dimension() == 2 + assert st.find([4, 5, 6]) == False + assert st.filtration([0, 1, 2]) == 4.0 + assert st.filtration([0, 1, 3]) == 5.0 + assert st.filtration([0, 2, 3]) == 6.0 + assert st.filtration([1, 2, 3]) == 6.0 + + st.expansion_with_blocker(3, blocker) + assert st.num_simplices() == 23 + assert st.dimension() == 3 + assert st.find([4, 5, 6]) == False + assert st.filtration([0, 1, 2]) == 4.0 + assert st.filtration([0, 1, 3]) == 5.0 + assert st.filtration([0, 2, 3]) == 6.0 + assert st.filtration([1, 2, 3]) == 6.0 + assert st.filtration([0, 1, 2, 3]) == 7.0 |