summaryrefslogtreecommitdiff
path: root/src/python/test/test_rips_complex.py
diff options
context:
space:
mode:
authorROUVREAU Vincent <vincent.rouvreau@inria.fr>2020-02-11 17:20:24 +0100
committerROUVREAU Vincent <vincent.rouvreau@inria.fr>2020-02-11 17:20:24 +0100
commit3ea44646f04648d1a456a0fb9526035101fc17ea (patch)
treeae517187fd90c6f878538748b4b1f550bf1e5790 /src/python/test/test_rips_complex.py
parent3253abd27129595f7fcd2be4c2285a93aea98690 (diff)
Code review: non-optimal way to test filtration generator
Diffstat (limited to 'src/python/test/test_rips_complex.py')
-rwxr-xr-xsrc/python/test/test_rips_complex.py50
1 files changed, 24 insertions, 26 deletions
diff --git a/src/python/test/test_rips_complex.py b/src/python/test/test_rips_complex.py
index bd31c47c..f5c086cb 100755
--- a/src/python/test/test_rips_complex.py
+++ b/src/python/test/test_rips_complex.py
@@ -33,19 +33,18 @@ def test_rips_from_points():
assert simplex_tree.num_simplices() == 10
assert simplex_tree.num_vertices() == 4
- 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 list(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),
+ ]
assert simplex_tree.get_star([0]) == [
([0], 0.0),
@@ -98,19 +97,18 @@ def test_rips_from_distance_matrix():
assert simplex_tree.num_simplices() == 10
assert simplex_tree.num_vertices() == 4
- 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 list(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),
+ ]
assert simplex_tree.get_star([0]) == [
([0], 0.0),