summaryrefslogtreecommitdiff
path: root/src/python/test/test_simplex_tree.py
diff options
context:
space:
mode:
authormathieu <mathieu.carriere3@gmail.com>2020-02-04 19:44:52 -0500
committermathieu <mathieu.carriere3@gmail.com>2020-02-04 19:44:52 -0500
commit360cc2cc31e9e81b99f5c21aa2b4e79b066baabf (patch)
tree7632ef2dc88fef03116e326a497e61f4e811299a /src/python/test/test_simplex_tree.py
parentf2020f6bb3a4d2bbd774aa630151ef1db53ac4f8 (diff)
fixed Vincent's comments
Diffstat (limited to 'src/python/test/test_simplex_tree.py')
-rwxr-xr-xsrc/python/test/test_simplex_tree.py86
1 files changed, 82 insertions, 4 deletions
diff --git a/src/python/test/test_simplex_tree.py b/src/python/test/test_simplex_tree.py
index 1822c43b..7e3d843e 100755
--- a/src/python/test/test_simplex_tree.py
+++ b/src/python/test/test_simplex_tree.py
@@ -244,7 +244,85 @@ def test_make_filtration_non_decreasing():
assert st.filtration([0, 1, 6]) == 1.0
assert st.filtration([0, 1]) == 1.0
assert st.filtration([0]) == 1.0
- assert st.filtration([1]) == 1.0
- assert st.filtration([3, 4, 5]) == 2.0
- assert st.filtration([3, 4]) == 2.0
- assert st.filtration([4, 5]) == 2.0
+
+def test_extend_filtration():
+
+ # Inserted simplex:
+ # 5 4
+ # o o
+ # / \ /
+ # o o
+ # /2\ /3
+ # o o
+ # 1 0
+
+ st = SimplexTree()
+ st.insert([0,2])
+ st.insert([1,2])
+ st.insert([0,3])
+ st.insert([2,5])
+ st.insert([3,4])
+ st.insert([3,5])
+ st.assign_filtration([0], 1.)
+ st.assign_filtration([1], 2.)
+ st.assign_filtration([2], 3.)
+ st.assign_filtration([3], 4.)
+ st.assign_filtration([4], 5.)
+ st.assign_filtration([5], 6.)
+
+ assert st.get_filtration() == [
+ ([0, 2], 0.0),
+ ([1, 2], 0.0),
+ ([0, 3], 0.0),
+ ([3, 4], 0.0),
+ ([2, 5], 0.0),
+ ([3, 5], 0.0),
+ ([0], 1.0),
+ ([1], 2.0),
+ ([2], 3.0),
+ ([3], 4.0),
+ ([4], 5.0),
+ ([5], 6.0)
+ ]
+
+
+ st.extend_filtration()
+
+ assert st.get_filtration() == [
+ ([6], -3.0),
+ ([0], -2.0),
+ ([1], -1.8),
+ ([2], -1.6),
+ ([0, 2], -1.6),
+ ([1, 2], -1.6),
+ ([3], -1.4),
+ ([0, 3], -1.4),
+ ([4], -1.2),
+ ([3, 4], -1.2),
+ ([5], -1.0),
+ ([2, 5], -1.0),
+ ([3, 5], -1.0),
+ ([5, 6], 1.0),
+ ([4, 6], 1.2),
+ ([3, 6], 1.4),
+ ([3, 4, 6], 1.4),
+ ([3, 5, 6], 1.4),
+ ([2, 6], 1.6),
+ ([2, 5, 6], 1.6),
+ ([1, 6], 1.8),
+ ([1, 2, 6], 1.8),
+ ([0, 6], 2.0),
+ ([0, 2, 6], 2.0),
+ ([0, 3, 6], 2.0)
+ ]
+
+
+ dgm = st.persistence()
+ L = st.compute_extended_persistence_subdiagrams(dgm)
+ assert L == [
+ [(0, (1.9999999999999998, 2.9999999999999996))],
+ [(1, (5.0, 4.0))],
+ [(0, (1.0, 6.0))],
+ [(1, (6.0, 1.0))]
+ ]
+