summaryrefslogtreecommitdiff
path: root/src/python/test/test_rips_complex.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_rips_complex.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_rips_complex.py')
-rwxr-xr-xsrc/python/test/test_rips_complex.py53
1 files changed, 29 insertions, 24 deletions
diff --git a/src/python/test/test_rips_complex.py b/src/python/test/test_rips_complex.py
index b02a68e1..bd31c47c 100755
--- a/src/python/test/test_rips_complex.py
+++ b/src/python/test/test_rips_complex.py
@@ -10,6 +10,7 @@
from gudhi import RipsComplex
from math import sqrt
+import pytest
__author__ = "Vincent Rouvreau"
__copyright__ = "Copyright (C) 2016 Inria"
@@ -32,18 +33,20 @@ def test_rips_from_points():
assert simplex_tree.num_simplices() == 10
assert simplex_tree.num_vertices() == 4
- assert simplex_tree.get_filtration() == [
- ([0], 0.0),
- ([1], 0.0),
- ([2], 0.0),
- ([3], 0.0),
- ([0, 1], 1.0),
- ([0, 2], 1.0),
- ([1, 3], 1.0),
- ([2, 3], 1.0),
- ([1, 2], 1.4142135623730951),
- ([0, 3], 1.4142135623730951),
- ]
+ filtration_generator = simplex_tree.get_filtration()
+ assert(next(filtration_generator) == ([0], 0.0))
+ assert(next(filtration_generator) == ([1], 0.0))
+ assert(next(filtration_generator) == ([2], 0.0))
+ assert(next(filtration_generator) == ([3], 0.0))
+ assert(next(filtration_generator) == ([0, 1], 1.0))
+ assert(next(filtration_generator) == ([0, 2], 1.0))
+ assert(next(filtration_generator) == ([1, 3], 1.0))
+ assert(next(filtration_generator) == ([2, 3], 1.0))
+ assert(next(filtration_generator) == ([1, 2], 1.4142135623730951))
+ assert(next(filtration_generator) == ([0, 3], 1.4142135623730951))
+ with pytest.raises(StopIteration):
+ next(filtration_generator)
+
assert simplex_tree.get_star([0]) == [
([0], 0.0),
([0, 1], 1.0),
@@ -95,18 +98,20 @@ def test_rips_from_distance_matrix():
assert simplex_tree.num_simplices() == 10
assert simplex_tree.num_vertices() == 4
- assert simplex_tree.get_filtration() == [
- ([0], 0.0),
- ([1], 0.0),
- ([2], 0.0),
- ([3], 0.0),
- ([0, 1], 1.0),
- ([0, 2], 1.0),
- ([1, 3], 1.0),
- ([2, 3], 1.0),
- ([1, 2], 1.4142135623730951),
- ([0, 3], 1.4142135623730951),
- ]
+ filtration_generator = simplex_tree.get_filtration()
+ assert(next(filtration_generator) == ([0], 0.0))
+ assert(next(filtration_generator) == ([1], 0.0))
+ assert(next(filtration_generator) == ([2], 0.0))
+ assert(next(filtration_generator) == ([3], 0.0))
+ assert(next(filtration_generator) == ([0, 1], 1.0))
+ assert(next(filtration_generator) == ([0, 2], 1.0))
+ assert(next(filtration_generator) == ([1, 3], 1.0))
+ assert(next(filtration_generator) == ([2, 3], 1.0))
+ assert(next(filtration_generator) == ([1, 2], 1.4142135623730951))
+ assert(next(filtration_generator) == ([0, 3], 1.4142135623730951))
+ with pytest.raises(StopIteration):
+ next(filtration_generator)
+
assert simplex_tree.get_star([0]) == [
([0], 0.0),
([0, 1], 1.0),