diff options
author | ROUVREAU Vincent <vincent.rouvreau@inria.fr> | 2020-01-27 10:40:34 +0100 |
---|---|---|
committer | ROUVREAU Vincent <vincent.rouvreau@inria.fr> | 2020-01-27 10:40:34 +0100 |
commit | c7b70317b643b2eb9c603602da9c979388829821 (patch) | |
tree | b6902eb51b29d0033f086f80ba3cb5d82c11c9d8 /src/python/test | |
parent | 6e9211cccad31145a5675a33689b167008ac1ffa (diff) | |
parent | 5d5f40493ce60f2a606793645bf713c60fb5284d (diff) |
Merge branch 'master' into print_warnings_to_stderr
Diffstat (limited to 'src/python/test')
-rwxr-xr-x | src/python/test/test_alpha_complex.py | 37 |
1 files changed, 31 insertions, 6 deletions
diff --git a/src/python/test/test_alpha_complex.py b/src/python/test/test_alpha_complex.py index 712a50b6..3761fe16 100755 --- a/src/python/test/test_alpha_complex.py +++ b/src/python/test/test_alpha_complex.py @@ -11,8 +11,13 @@ from gudhi import AlphaComplex, SimplexTree import math import numpy as np -import itertools import pytest +try: + # python3 + from itertools import zip_longest +except ImportError: + # python2 + from itertools import izip_longest as zip_longest __author__ = "Vincent Rouvreau" __copyright__ = "Copyright (C) 2016 Inria" @@ -60,8 +65,18 @@ def test_infinite_alpha(): assert point_list[1] == alpha_complex.get_point(1) assert point_list[2] == alpha_complex.get_point(2) assert point_list[3] == alpha_complex.get_point(3) - assert alpha_complex.get_point(4) == [] - assert alpha_complex.get_point(125) == [] + try: + alpha_complex.get_point(4) == [] + except IndexError: + pass + else: + assert False + try: + alpha_complex.get_point(125) == [] + except IndexError: + pass + else: + assert False def test_filtered_alpha(): @@ -77,8 +92,18 @@ def test_filtered_alpha(): assert point_list[1] == filtered_alpha.get_point(1) assert point_list[2] == filtered_alpha.get_point(2) assert point_list[3] == filtered_alpha.get_point(3) - assert filtered_alpha.get_point(4) == [] - assert filtered_alpha.get_point(125) == [] + try: + filtered_alpha.get_point(4) == [] + except IndexError: + pass + else: + assert False + try: + filtered_alpha.get_point(125) == [] + except IndexError: + pass + else: + assert False assert simplex_tree.get_filtration() == [ ([0], 0.0), @@ -114,6 +139,6 @@ def test_safe_alpha_persistence_comparison(): diag1 = simplex_tree1.persistence() diag2 = simplex_tree2.persistence() - for (first_p, second_p) in itertools.zip_longest(diag1, diag2): + for (first_p, second_p) in zip_longest(diag1, diag2): assert first_p[0] == pytest.approx(second_p[0]) assert first_p[1] == pytest.approx(second_p[1]) |