diff options
Diffstat (limited to 'src/cython/test')
-rwxr-xr-x | src/cython/test/test_alpha_complex.py | 86 | ||||
-rwxr-xr-x | src/cython/test/test_cubical_complex.py | 86 | ||||
-rwxr-xr-x | src/cython/test/test_mini_simplex_tree.py | 50 | ||||
-rwxr-xr-x | src/cython/test/test_rips_complex.py | 65 | ||||
-rwxr-xr-x | src/cython/test/test_simplex_tree.py | 98 | ||||
-rwxr-xr-x | src/cython/test/test_subsampling.py | 94 | ||||
-rwxr-xr-x | src/cython/test/test_tangential_complex.py | 56 | ||||
-rwxr-xr-x | src/cython/test/test_witness_complex.py | 55 |
8 files changed, 590 insertions, 0 deletions
diff --git a/src/cython/test/test_alpha_complex.py b/src/cython/test/test_alpha_complex.py new file mode 100755 index 00000000..b08ac0d7 --- /dev/null +++ b/src/cython/test/test_alpha_complex.py @@ -0,0 +1,86 @@ +from gudhi import AlphaComplex, SimplexTree + +"""This file is part of the Gudhi Library. The Gudhi library + (Geometric Understanding in Higher Dimensions) is a generic C++ + library for computational topology. + + Author(s): Vincent Rouvreau + + Copyright (C) 2016 INRIA + + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see <http://www.gnu.org/licenses/>. +""" + +__author__ = "Vincent Rouvreau" +__copyright__ = "Copyright (C) 2016 INRIA" +__license__ = "GPL v3" + + +def test_empty_alpha(): + alpha_complex = AlphaComplex(points=[[0,0]]) + assert alpha_complex.__is_defined() == True + +def test_infinite_alpha(): + point_list = [[0, 0], [1, 0], [0, 1], [1, 1]] + alpha_complex = AlphaComplex(points=point_list) + assert alpha_complex.__is_defined() == True + + simplex_tree = alpha_complex.create_simplex_tree() + assert simplex_tree.__is_persistence_defined() == False + + assert simplex_tree.num_simplices() == 11 + assert simplex_tree.num_vertices() == 4 + + assert simplex_tree.get_filtered_tree() == \ + [([0], 0.0), ([1], 0.0), ([2], 0.0), ([3], 0.0), + ([0, 1], 0.25), ([0, 2], 0.25), ([1, 3], 0.25), + ([2, 3], 0.25), ([1, 2], 0.5), ([0, 1, 2], 0.5), + ([1, 2, 3], 0.5)] + assert simplex_tree.get_star_tree([0]) == \ + [([0], 0.0), ([0, 1], 0.25), ([0, 1, 2], 0.5), + ([0, 2], 0.25)] + assert simplex_tree.get_coface_tree([0], 1) == \ + [([0, 1], 0.25), ([0, 2], 0.25)] + + assert point_list[0] == alpha_complex.get_point(0) + 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) == [] + +def test_filtered_alpha(): + point_list = [[0, 0], [1, 0], [0, 1], [1, 1]] + filtered_alpha = AlphaComplex(points=point_list) + + simplex_tree = filtered_alpha.create_simplex_tree(max_alpha_square=0.25) + + assert simplex_tree.num_simplices() == 8 + assert simplex_tree.num_vertices() == 4 + + assert point_list[0] == filtered_alpha.get_point(0) + 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) == [] + + assert simplex_tree.get_filtered_tree() == \ + [([0], 0.0), ([1], 0.0), ([2], 0.0), ([3], 0.0), + ([0, 1], 0.25), ([0, 2], 0.25), ([1, 3], 0.25), + ([2, 3], 0.25)] + assert simplex_tree.get_star_tree([0]) == \ + [([0], 0.0), ([0, 1], 0.25), ([0, 2], 0.25)] + assert simplex_tree.get_coface_tree([0], 1) == \ + [([0, 1], 0.25), ([0, 2], 0.25)] diff --git a/src/cython/test/test_cubical_complex.py b/src/cython/test/test_cubical_complex.py new file mode 100755 index 00000000..c8df8089 --- /dev/null +++ b/src/cython/test/test_cubical_complex.py @@ -0,0 +1,86 @@ +from gudhi import CubicalComplex + +"""This file is part of the Gudhi Library. The Gudhi library + (Geometric Understanding in Higher Dimensions) is a generic C++ + library for computational topology. + + Author(s): Vincent Rouvreau + + Copyright (C) 2016 INRIA + + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see <http://www.gnu.org/licenses/>. +""" + +__author__ = "Vincent Rouvreau" +__copyright__ = "Copyright (C) 2016 INRIA" +__license__ = "GPL v3" + + +def test_empty_constructor(): + # Try to create an empty CubicalComplex + cub = CubicalComplex() + assert cub.__is_defined() == False + assert cub.__is_persistence_defined() == False + +def test_non_existing_perseus_file_constructor(): + # Try to open a non existing file + cub = CubicalComplex(perseus_file='pouetpouettralala.toubiloubabdou') + assert cub.__is_defined() == False + assert cub.__is_persistence_defined() == False + +def test_dimension_or_perseus_file_constructor(): + # Create test file + test_file = open('CubicalOneSphere.txt', 'w') + test_file.write('2\n3\n3\n0\n0\n0\n0\n100\n0\n0\n0\n0\n') + test_file.close() + # CubicalComplex can be constructed from dimensions and + # top_dimensional_cells OR from a perseus file style name. + cub = CubicalComplex(dimensions=[3, 3], + top_dimensional_cells = [1,2,3,4,5,6,7,8,9], + perseus_file='CubicalOneSphere.txt') + assert cub.__is_defined() == False + assert cub.__is_persistence_defined() == False + + cub = CubicalComplex(top_dimensional_cells = [1,2,3,4,5,6,7,8,9], + perseus_file='CubicalOneSphere.txt') + assert cub.__is_defined() == False + assert cub.__is_persistence_defined() == False + + cub = CubicalComplex(dimensions=[3, 3], + perseus_file='CubicalOneSphere.txt') + assert cub.__is_defined() == False + assert cub.__is_persistence_defined() == False + +def test_dimension_constructor(): + cub = CubicalComplex(dimensions=[3, 3], + top_dimensional_cells = [1,2,3,4,5,6,7,8,9]) + assert cub.__is_defined() == True + assert cub.__is_persistence_defined() == False + assert cub.persistence() == [(1, (0.0, 100.0)), (0, (0.0, 1.8446744073709552e+19))] + assert cub.__is_persistence_defined() == True + assert cub.betti_numbers() == [1, 0] + assert cub.persistent_betti_numbers(0, 1000) == [0, 0] + +def test_dimension_constructor(): + # Create test file + test_file = open('CubicalOneSphere.txt', 'w') + test_file.write('2\n3\n3\n0\n0\n0\n0\n100\n0\n0\n0\n0\n') + test_file.close() + cub = CubicalComplex(perseus_file='CubicalOneSphere.txt') + assert cub.__is_defined() == True + assert cub.__is_persistence_defined() == False + assert cub.persistence() == [(1, (0.0, 100.0)), (0, (0.0, 1.8446744073709552e+19))] + assert cub.__is_persistence_defined() == True + assert cub.betti_numbers() == [1, 0, 0] + assert cub.persistent_betti_numbers(0, 1000) == [1, 0, 0] diff --git a/src/cython/test/test_mini_simplex_tree.py b/src/cython/test/test_mini_simplex_tree.py new file mode 100755 index 00000000..e44bfdbc --- /dev/null +++ b/src/cython/test/test_mini_simplex_tree.py @@ -0,0 +1,50 @@ +from gudhi import MiniSimplexTree + +"""This file is part of the Gudhi Library. The Gudhi library + (Geometric Understanding in Higher Dimensions) is a generic C++ + library for computational topology. + + Author(s): Vincent Rouvreau + + Copyright (C) 2016 INRIA + + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see <http://www.gnu.org/licenses/>. +""" + +__author__ = "Vincent Rouvreau" +__copyright__ = "Copyright (C) 2016 INRIA" +__license__ = "GPL v3" + + +def test_mini(): + triangle012 = [0, 1, 2] + edge03 = [0, 3] + mini_st = MiniSimplexTree() + assert mini_st.__is_defined() == True + assert mini_st.__is_persistence_defined() == False + assert mini_st.insert(triangle012) == True + assert mini_st.insert(edge03) == True + # FIXME: Remove this line + mini_st.set_dimension(2) + + edge02 = [0, 2] + assert mini_st.find(edge02) == True + assert mini_st.get_coface_tree(edge02, 1) == \ + [([0, 1, 2], 0.0)] + + # remove_maximal_simplex test + assert mini_st.get_coface_tree(triangle012, 1) == [] + mini_st.remove_maximal_simplex(triangle012) + assert mini_st.find(edge02) == True + assert mini_st.find(triangle012) == False diff --git a/src/cython/test/test_rips_complex.py b/src/cython/test/test_rips_complex.py new file mode 100755 index 00000000..877289cf --- /dev/null +++ b/src/cython/test/test_rips_complex.py @@ -0,0 +1,65 @@ +from gudhi import RipsComplex + +"""This file is part of the Gudhi Library. The Gudhi library + (Geometric Understanding in Higher Dimensions) is a generic C++ + library for computational topology. + + Author(s): Vincent Rouvreau + + Copyright (C) 2016 INRIA + + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see <http://www.gnu.org/licenses/>. +""" + +__author__ = "Vincent Rouvreau" +__copyright__ = "Copyright (C) 2016 INRIA" +__license__ = "GPL v3" + + +def test_empty_rips(): + rips_complex = RipsComplex() + assert rips_complex.__is_defined() == True + assert rips_complex.__is_persistence_defined() == False + +def test_rips(): + point_list = [[0, 0], [1, 0], [0, 1], [1, 1]] + rips_complex = RipsComplex(points=point_list, max_dimension=1, + max_edge_length=42) + assert rips_complex.__is_defined() == True + assert rips_complex.__is_persistence_defined() == False + + assert rips_complex.num_simplices() == 10 + assert rips_complex.num_vertices() == 4 + + assert rips_complex.get_filtered_tree() == \ + [([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 rips_complex.get_star_tree([0]) == \ + [([0], 0.0), ([0, 1], 1.0), ([0, 2], 1.0), + ([0, 3], 1.4142135623730951)] + assert rips_complex.get_coface_tree([0], 1) == \ + [([0, 1], 1.0), ([0, 2], 1.0), + ([0, 3], 1.4142135623730951)] + +def test_filtered_rips(): + point_list = [[0, 0], [1, 0], [0, 1], [1, 1]] + filtered_rips = RipsComplex(points=point_list, max_dimension=1, + max_edge_length=1.0) + assert filtered_rips.__is_defined() == True + assert filtered_rips.__is_persistence_defined() == False + + assert filtered_rips.num_simplices() == 8 + assert filtered_rips.num_vertices() == 4 diff --git a/src/cython/test/test_simplex_tree.py b/src/cython/test/test_simplex_tree.py new file mode 100755 index 00000000..0b9899f8 --- /dev/null +++ b/src/cython/test/test_simplex_tree.py @@ -0,0 +1,98 @@ +from gudhi import SimplexTree + +"""This file is part of the Gudhi Library. The Gudhi library + (Geometric Understanding in Higher Dimensions) is a generic C++ + library for computational topology. + + Author(s): Vincent Rouvreau + + Copyright (C) 2016 INRIA + + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see <http://www.gnu.org/licenses/>. +""" + +__author__ = "Vincent Rouvreau" +__copyright__ = "Copyright (C) 2016 INRIA" +__license__ = "GPL v3" + + +def test_insertion(): + st = SimplexTree() + assert st.__is_defined() == True + assert st.__is_persistence_defined() == False + + # insert test + assert st.insert([0, 1]) == True + assert st.insert([0, 1, 2], filtration=4.0) == True + # FIXME: Remove this line + st.set_dimension(2) + assert st.num_simplices() == 7 + assert st.num_vertices() == 3 + + # find test + assert st.find([0, 1, 2]) == True + assert st.find([0, 1]) == True + assert st.find([0, 2]) == True + assert st.find([0]) == True + assert st.find([1]) == True + assert st.find([2]) == True + assert st.find([3]) == False + assert st.find([0, 3]) == False + assert st.find([1, 3]) == False + assert st.find([2, 3]) == False + + # filtration test + st.set_filtration(5.0) + st.initialize_filtration() + assert st.get_filtration() == 5.0 + assert st.filtration([0, 1, 2]) == 4.0 + assert st.filtration([0, 2]) == 4.0 + assert st.filtration([1, 2]) == 4.0 + assert st.filtration([2]) == 4.0 + assert st.filtration([0, 1]) == 0.0 + assert st.filtration([0]) == 0.0 + assert st.filtration([1]) == 0.0 + + # skeleton_tree test + assert st.get_skeleton_tree(2) == \ + [([0, 1, 2], 4.0), ([0, 1], 0.0), ([0, 2], 4.0), + ([0], 0.0), ([1, 2], 4.0), ([1], 0.0), ([2], 4.0)] + assert st.get_skeleton_tree(1) == \ + [([0, 1], 0.0), ([0, 2], 4.0), ([0], 0.0), + ([1, 2], 4.0), ([1], 0.0), ([2], 4.0)] + assert st.get_skeleton_tree(0) == \ + [([0], 0.0), ([1], 0.0), ([2], 4.0)] + + # remove_maximal_simplex test + assert st.get_coface_tree([0, 1, 2], 1) == [] + st.remove_maximal_simplex([0, 1, 2]) + assert st.get_skeleton_tree(2) == \ + [([0, 1], 0.0), ([0, 2], 4.0), ([0], 0.0), + ([1, 2], 4.0), ([1], 0.0), ([2], 4.0)] + assert st.find([0, 1, 2]) == False + assert st.find([0, 1]) == True + assert st.find([0, 2]) == True + assert st.find([0]) == True + assert st.find([1]) == True + assert st.find([2]) == True + + st.initialize_filtration() + assert st.persistence() == [(1, (4.0, float('inf'))), (0, (0.0, float('inf')))] + assert st.__is_persistence_defined() == True + assert st.betti_numbers() == [1, 1] + assert st.persistent_betti_numbers(-0.1, 10000.0) == [0, 0] + assert st.persistent_betti_numbers(0.0, 10000.0) == [1, 0] + assert st.persistent_betti_numbers(3.9, 10000.0) == [1, 0] + assert st.persistent_betti_numbers(4.0, 10000.0) == [1, 1] + assert st.persistent_betti_numbers(9999.0, 10000.0) == [1, 1] diff --git a/src/cython/test/test_subsampling.py b/src/cython/test/test_subsampling.py new file mode 100755 index 00000000..e5f2d70a --- /dev/null +++ b/src/cython/test/test_subsampling.py @@ -0,0 +1,94 @@ +import gudhi +import os + +"""This file is part of the Gudhi Library. The Gudhi library + (Geometric Understanding in Higher Dimensions) is a generic C++ + library for computational topology. + + Author(s): Vincent Rouvreau + + Copyright (C) 2016 INRIA + + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see <http://www.gnu.org/licenses/>. +""" + +__author__ = "Vincent Rouvreau" +__copyright__ = "Copyright (C) 2016 INRIA" +__license__ = "GPL v3" + + +def test_write_off_file_for_tests(): + file = open("n_farthest.off", "w") + file.write("nOFF\n") + file.write("2 7 0 0\n") + file.write("1.0 1.0\n") + file.write("7.0 0.0\n") + file.write("4.0 6.0\n") + file.write("9.0 6.0\n") + file.write("0.0 14.0\n") + file.write("2.0 19.0\n") + file.write("9.0 17.0\n") + file.close() + +def test_simple_choose_n_farthest_points_with_a_starting_point(): + point_set = [[0,1], [0,0], [1,0], [1,1]] + i = 0 + for point in point_set: + # The iteration starts with the given starting point + sub_set = gudhi.choose_n_farthest_points(points = point_set, nb_points = 1, starting_point = i) + assert sub_set[0] == point_set[i] + i = i + 1 + + # The iteration finds then the farthest + sub_set = gudhi.choose_n_farthest_points(points = point_set, nb_points = 2, starting_point = 1) + assert sub_set[1] == point_set[3] + sub_set = gudhi.choose_n_farthest_points(points = point_set, nb_points = 2, starting_point = 3) + assert sub_set[1] == point_set[1] + sub_set = gudhi.choose_n_farthest_points(points = point_set, nb_points = 2, starting_point = 0) + assert sub_set[1] == point_set[2] + sub_set = gudhi.choose_n_farthest_points(points = point_set, nb_points = 2, starting_point = 2) + assert sub_set[1] == point_set[0] + + # Test the limits + assert gudhi.choose_n_farthest_points(points = [], nb_points = 0, starting_point = 0) == [] + assert gudhi.choose_n_farthest_points(points = [], nb_points = 1, starting_point = 0) == [] + assert gudhi.choose_n_farthest_points(points = [], nb_points = 0, starting_point = 1) == [] + assert gudhi.choose_n_farthest_points(points = [], nb_points = 1, starting_point = 1) == [] + + print(os.getcwd()) + # From off file test + for i in range (0, 7): + assert len(gudhi.choose_n_farthest_points(off_file = 'n_farthest.off', nb_points = i, starting_point = i)) == i + +def test_simple_choose_n_farthest_points_randomed(): + point_set = [[0,1], [0,0], [1,0], [1,1]] + + # Test the limits + assert gudhi.choose_n_farthest_points(points = [], nb_points = 0) == [] + assert gudhi.choose_n_farthest_points(points = [], nb_points = 1) == [] + assert gudhi.choose_n_farthest_points(points = point_set, nb_points = 0) == [] + # Go furter than point set on purpose + for iter in range(1,10): + sub_set = gudhi.choose_n_farthest_points(points = point_set, nb_points = iter) + for sub in sub_set: + found = False + for point in point_set: + if point == sub: + found = True + assert found == True + + print(os.getcwd()) + # From off file test + for i in range (0, 7): + assert len(gudhi.choose_n_farthest_points(off_file = 'n_farthest.off', nb_points = i)) == i diff --git a/src/cython/test/test_tangential_complex.py b/src/cython/test/test_tangential_complex.py new file mode 100755 index 00000000..8e1b5c51 --- /dev/null +++ b/src/cython/test/test_tangential_complex.py @@ -0,0 +1,56 @@ +from gudhi import TangentialComplex, SimplexTree + +"""This file is part of the Gudhi Library. The Gudhi library + (Geometric Understanding in Higher Dimensions) is a generic C++ + library for computational topology. + + Author(s): Vincent Rouvreau + + Copyright (C) 2016 INRIA + + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see <http://www.gnu.org/licenses/>. +""" + +__author__ = "Vincent Rouvreau" +__copyright__ = "Copyright (C) 2016 INRIA" +__license__ = "GPL v3" + + +def test_tangential(): + point_list = [[0.0, 0.0], [1.0, 0.0], [0.0, 1.0], [1.0, 1.0]] + tc = TangentialComplex(points=point_list) + assert tc.__is_defined() == True + assert tc.num_vertices() == 4 + + st = tc.create_simplex_tree() + assert st.__is_defined() == True + assert st.__is_persistence_defined() == False + + assert st.num_simplices() == 13 + assert st.num_vertices() == 4 + + assert st.get_filtered_tree() == \ + [([0], 0.0), ([1], 0.0), ([0, 1], 0.0), ([2], 0.0), ([0, 2], 0.0), + ([1, 2], 0.0), ([3], 0.0), ([0, 3], 0.0), ([1, 3], 0.0), + ([0, 1, 3], 0.0), ([2, 3], 0.0), ([0, 2, 3], 0.0), + ([1, 2, 3], 0.0)] + assert st.get_coface_tree([0], 1) == \ + [([0, 1], 0.0), ([0, 2], 0.0), ([0, 3], 0.0)] + + assert point_list[0] == tc.get_point(0) + assert point_list[1] == tc.get_point(1) + assert point_list[2] == tc.get_point(2) + assert point_list[3] == tc.get_point(3) + assert tc.get_point(4) == [] + assert tc.get_point(125) == [] diff --git a/src/cython/test/test_witness_complex.py b/src/cython/test/test_witness_complex.py new file mode 100755 index 00000000..9f4a3523 --- /dev/null +++ b/src/cython/test/test_witness_complex.py @@ -0,0 +1,55 @@ +from gudhi import WitnessComplex + +"""This file is part of the Gudhi Library. The Gudhi library + (Geometric Understanding in Higher Dimensions) is a generic C++ + library for computational topology. + + Author(s): Vincent Rouvreau + + Copyright (C) 2016 INRIA + + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see <http://www.gnu.org/licenses/>. +""" + +__author__ = "Vincent Rouvreau" +__copyright__ = "Copyright (C) 2016 INRIA" +__license__ = "GPL v3" + + +def test_empty_witness_complex(): + witness = WitnessComplex() + assert witness.__is_defined() == False + +def test_witness_complex(): + point_list = [[0, 0], [1, 0], [0, 1], [1, 1]] + witness = WitnessComplex(points=point_list, number_of_landmarks=10) + assert witness.__is_defined() == True + + # FIXME: Remove this line + witness.set_dimension(2) + + assert witness.num_simplices() == 13 + assert witness.num_vertices() == 10 + witness.initialize_filtration() + + assert witness.get_filtered_tree() == \ + [([0], 0.0), ([1], 0.0), ([2], 0.0), ([0, 2], 0.0), + ([1, 2], 0.0), ([3], 0.0), ([4], 0.0), ([3, 4], 0.0), + ([5], 0.0), ([6], 0.0), ([7], 0.0), ([8], 0.0), + ([9], 0.0)] + + assert witness.get_coface_tree([2], 1) == \ + [([0, 2], 0.0), ([1, 2], 0.0)] + assert witness.get_star_tree([2]) == \ + [([0, 2], 0.0), ([1, 2], 0.0), ([2], 0.0)] |