summaryrefslogtreecommitdiff
path: root/src/python/test/test_simplex_tree.py
diff options
context:
space:
mode:
authorROUVREAU Vincent <vincent.rouvreau@inria.fr>2020-01-28 11:05:39 +0100
committerROUVREAU Vincent <vincent.rouvreau@inria.fr>2020-01-28 11:05:39 +0100
commitef2c5b53e88321f07ad93496f00dde16dc20f018 (patch)
tree0a7c4d1d7f69a691259e98ceed1439421fb14f3e /src/python/test/test_simplex_tree.py
parent0b77fdd5d9bd057103cb23020089a6628c1f14e6 (diff)
Code review: rename get_simplex_filtration with get_simplex_and_filtration. Remove exception raise. Fix failed tests. Reword documentation
Diffstat (limited to 'src/python/test/test_simplex_tree.py')
-rwxr-xr-xsrc/python/test/test_simplex_tree.py90
1 files changed, 47 insertions, 43 deletions
diff --git a/src/python/test/test_simplex_tree.py b/src/python/test/test_simplex_tree.py
index 1822c43b..0f3db7ac 100755
--- a/src/python/test/test_simplex_tree.py
+++ b/src/python/test/test_simplex_tree.py
@@ -9,6 +9,7 @@
"""
from gudhi import SimplexTree
+import pytest
__author__ = "Vincent Rouvreau"
__copyright__ = "Copyright (C) 2016 Inria"
@@ -126,55 +127,58 @@ def test_expansion():
assert st.num_vertices() == 7
assert st.num_simplices() == 17
- assert st.get_filtration() == [
- ([2], 0.1),
- ([3], 0.1),
- ([2, 3], 0.1),
- ([0], 0.2),
- ([0, 2], 0.2),
- ([1], 0.3),
- ([0, 1], 0.3),
- ([1, 3], 0.4),
- ([1, 2], 0.5),
- ([5], 0.6),
- ([6], 0.6),
- ([5, 6], 0.6),
- ([4], 0.7),
- ([2, 4], 0.7),
- ([0, 3], 0.8),
- ([4, 6], 0.9),
- ([3, 6], 1.0),
- ]
+
+ filtration_generator = st.get_filtration()
+ assert(next(filtration_generator) == ([2], 0.1))
+ assert(next(filtration_generator) == ([3], 0.1))
+ assert(next(filtration_generator) == ([2, 3], 0.1))
+ assert(next(filtration_generator) == ([0], 0.2))
+ assert(next(filtration_generator) == ([0, 2], 0.2))
+ assert(next(filtration_generator) == ([1], 0.3))
+ assert(next(filtration_generator) == ([0, 1], 0.3))
+ assert(next(filtration_generator) == ([1, 3], 0.4))
+ assert(next(filtration_generator) == ([1, 2], 0.5))
+ assert(next(filtration_generator) == ([5], 0.6))
+ assert(next(filtration_generator) == ([6], 0.6))
+ assert(next(filtration_generator) == ([5, 6], 0.6))
+ assert(next(filtration_generator) == ([4], 0.7))
+ assert(next(filtration_generator) == ([2, 4], 0.7))
+ assert(next(filtration_generator) == ([0, 3], 0.8))
+ assert(next(filtration_generator) == ([4, 6], 0.9))
+ assert(next(filtration_generator) == ([3, 6], 1.0))
+ with pytest.raises(StopIteration):
+ next(filtration_generator)
st.expansion(3)
assert st.num_vertices() == 7
assert st.num_simplices() == 22
st.initialize_filtration()
- assert st.get_filtration() == [
- ([2], 0.1),
- ([3], 0.1),
- ([2, 3], 0.1),
- ([0], 0.2),
- ([0, 2], 0.2),
- ([1], 0.3),
- ([0, 1], 0.3),
- ([1, 3], 0.4),
- ([1, 2], 0.5),
- ([0, 1, 2], 0.5),
- ([1, 2, 3], 0.5),
- ([5], 0.6),
- ([6], 0.6),
- ([5, 6], 0.6),
- ([4], 0.7),
- ([2, 4], 0.7),
- ([0, 3], 0.8),
- ([0, 1, 3], 0.8),
- ([0, 2, 3], 0.8),
- ([0, 1, 2, 3], 0.8),
- ([4, 6], 0.9),
- ([3, 6], 1.0),
- ]
+ filtration_generator = st.get_filtration()
+ assert(next(filtration_generator) == ([2], 0.1))
+ assert(next(filtration_generator) == ([3], 0.1))
+ assert(next(filtration_generator) == ([2, 3], 0.1))
+ assert(next(filtration_generator) == ([0], 0.2))
+ assert(next(filtration_generator) == ([0, 2], 0.2))
+ assert(next(filtration_generator) == ([1], 0.3))
+ assert(next(filtration_generator) == ([0, 1], 0.3))
+ assert(next(filtration_generator) == ([1, 3], 0.4))
+ assert(next(filtration_generator) == ([1, 2], 0.5))
+ assert(next(filtration_generator) == ([0, 1, 2], 0.5))
+ assert(next(filtration_generator) == ([1, 2, 3], 0.5))
+ assert(next(filtration_generator) == ([5], 0.6))
+ assert(next(filtration_generator) == ([6], 0.6))
+ assert(next(filtration_generator) == ([5, 6], 0.6))
+ assert(next(filtration_generator) == ([4], 0.7))
+ assert(next(filtration_generator) == ([2, 4], 0.7))
+ assert(next(filtration_generator) == ([0, 3], 0.8))
+ assert(next(filtration_generator) == ([0, 1, 3], 0.8))
+ assert(next(filtration_generator) == ([0, 2, 3], 0.8))
+ assert(next(filtration_generator) == ([0, 1, 2, 3], 0.8))
+ assert(next(filtration_generator) == ([4, 6], 0.9))
+ assert(next(filtration_generator) == ([3, 6], 1.0))
+ with pytest.raises(StopIteration):
+ next(filtration_generator)
def test_automatic_dimension():