summaryrefslogtreecommitdiff
path: root/src/cython/test
diff options
context:
space:
mode:
Diffstat (limited to 'src/cython/test')
-rwxr-xr-xsrc/cython/test/test_alpha_complex.py4
-rwxr-xr-xsrc/cython/test/test_bottleneck_distance.py4
-rwxr-xr-xsrc/cython/test/test_cover_complex.py92
-rwxr-xr-xsrc/cython/test/test_cubical_complex.py25
-rwxr-xr-xsrc/cython/test/test_euclidean_witness_complex.py4
-rwxr-xr-xsrc/cython/test/test_reader_utils.py4
-rwxr-xr-xsrc/cython/test/test_rips_complex.py4
-rwxr-xr-xsrc/cython/test/test_simplex_tree.py86
-rwxr-xr-xsrc/cython/test/test_subsampling.py4
-rwxr-xr-xsrc/cython/test/test_tangential_complex.py6
-rwxr-xr-xsrc/cython/test/test_witness_complex.py4
11 files changed, 208 insertions, 29 deletions
diff --git a/src/cython/test/test_alpha_complex.py b/src/cython/test/test_alpha_complex.py
index 2c76d9d7..e97f2530 100755
--- a/src/cython/test/test_alpha_complex.py
+++ b/src/cython/test/test_alpha_complex.py
@@ -6,7 +6,7 @@ from gudhi import AlphaComplex, SimplexTree
Author(s): Vincent Rouvreau
- Copyright (C) 2016 INRIA
+ 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
@@ -23,7 +23,7 @@ from gudhi import AlphaComplex, SimplexTree
"""
__author__ = "Vincent Rouvreau"
-__copyright__ = "Copyright (C) 2016 INRIA"
+__copyright__ = "Copyright (C) 2016 Inria"
__license__ = "GPL v3"
diff --git a/src/cython/test/test_bottleneck_distance.py b/src/cython/test/test_bottleneck_distance.py
index 3d982d34..4eb5848f 100755
--- a/src/cython/test/test_bottleneck_distance.py
+++ b/src/cython/test/test_bottleneck_distance.py
@@ -6,7 +6,7 @@ import gudhi
Author(s): Vincent Rouvreau
- Copyright (C) 2016 INRIA
+ 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
@@ -23,7 +23,7 @@ import gudhi
"""
__author__ = "Vincent Rouvreau"
-__copyright__ = "Copyright (C) 2016 INRIA"
+__copyright__ = "Copyright (C) 2016 Inria"
__license__ = "GPL v3"
diff --git a/src/cython/test/test_cover_complex.py b/src/cython/test/test_cover_complex.py
new file mode 100755
index 00000000..58935264
--- /dev/null
+++ b/src/cython/test/test_cover_complex.py
@@ -0,0 +1,92 @@
+from gudhi import CoverComplex
+
+"""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) 2018 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) 2018 Inria"
+__license__ = "GPL v3"
+
+
+def test_empty_constructor():
+ # Try to create an empty CoverComplex
+ cover = CoverComplex()
+ assert cover.__is_defined() == True
+
+def test_non_existing_file_read():
+ # Try to open a non existing file
+ cover = CoverComplex()
+ assert (cover.read_point_cloud('pouetpouettralala.toubiloubabdou') == False)
+
+def test_files_creation():
+ # Create test file
+ cloud_file = open('cloud', 'w')
+ cloud_file.write('nOFF\n3\n3 0 0\n0 0 0\n2 1 0\n4 0 0')
+ cloud_file.close()
+ cover_file = open('cover', 'w')
+ cover_file.write('1\n2\n3')
+ cover_file.close()
+ graph_file = open('graph', 'w')
+ graph_file.write('0 1\n0 2\n1 2')
+ graph_file.close()
+
+def test_nerve():
+ nerve = CoverComplex()
+ nerve.set_type('Nerve')
+ assert (nerve.read_point_cloud('cloud') == True)
+ nerve.set_color_from_coordinate()
+ nerve.set_graph_from_file('graph')
+ nerve.set_cover_from_file('cover')
+ nerve.find_simplices()
+ stree = nerve.create_simplex_tree()
+
+ assert (stree.num_vertices() == 3)
+ assert ((stree.num_simplices() - stree.num_vertices()) == 0)
+ assert (stree.dimension() == 0)
+
+def test_graph_induced_complex():
+ gic = CoverComplex()
+ gic.set_type('GIC')
+ assert (gic.read_point_cloud('cloud') == True)
+ gic.set_color_from_coordinate()
+ gic.set_graph_from_file('graph')
+ gic.set_cover_from_file('cover')
+ gic.find_simplices()
+ stree = gic.create_simplex_tree()
+
+ assert (stree.num_vertices() == 3)
+ assert ((stree.num_simplices() - stree.num_vertices()) == 4)
+ assert (stree.dimension() == 2)
+
+def test_voronoi_graph_induced_complex():
+ gic = CoverComplex()
+ gic.set_type('GIC')
+ assert (gic.read_point_cloud('cloud') == True)
+ gic.set_color_from_coordinate()
+ gic.set_graph_from_file('graph')
+ gic.set_cover_from_Voronoi(2)
+ gic.find_simplices()
+ stree = gic.create_simplex_tree()
+
+ assert (stree.num_vertices() == 2)
+ assert ((stree.num_simplices() - stree.num_vertices()) == 1)
+ assert (stree.dimension() == 1)
diff --git a/src/cython/test/test_cubical_complex.py b/src/cython/test/test_cubical_complex.py
index 9a365823..92e591e9 100755
--- a/src/cython/test/test_cubical_complex.py
+++ b/src/cython/test/test_cubical_complex.py
@@ -6,7 +6,7 @@ from gudhi import CubicalComplex
Author(s): Vincent Rouvreau
- Copyright (C) 2016 INRIA
+ 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
@@ -23,7 +23,7 @@ from gudhi import CubicalComplex
"""
__author__ = "Vincent Rouvreau"
-__copyright__ = "Copyright (C) 2016 INRIA"
+__copyright__ = "Copyright (C) 2016 Inria"
__license__ = "GPL v3"
@@ -62,17 +62,28 @@ def test_dimension_or_perseus_file_constructor():
assert cub.__is_defined() == False
assert cub.__is_persistence_defined() == False
-def test_dimension_constructor():
+def test_dimension_simple_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, float('inf')))]
+ assert cub.persistence() == [(0, (1.0, float('inf')))]
+ assert cub.__is_persistence_defined() == True
+ assert cub.betti_numbers() == [1, 0, 0]
+ assert cub.persistent_betti_numbers(0, 1000) == [0, 0, 0]
+
+def test_user_case_simple_constructor():
+ cub = CubicalComplex(dimensions=[3, 3],
+ top_dimensional_cells = [float('inf'), 0.,0.,0.,1.,0.,0.,0.,0.])
+ assert cub.__is_defined() == True
+ assert cub.__is_persistence_defined() == False
+ assert cub.persistence() == [(1, (0.0, 1.0)), (0, (0.0, float('inf')))]
assert cub.__is_persistence_defined() == True
- assert cub.betti_numbers() == [1, 0]
- assert cub.persistent_betti_numbers(0, 1000) == [0, 0]
+ other_cub = CubicalComplex(dimensions=[3, 3],
+ top_dimensional_cells = [1000., 0.,0.,0.,1.,0.,0.,0.,0.])
+ assert other_cub.persistence() == [(1, (0.0, 1.0)), (0, (0.0, float('inf')))]
-def test_dimension_constructor():
+def test_dimension_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')
diff --git a/src/cython/test/test_euclidean_witness_complex.py b/src/cython/test/test_euclidean_witness_complex.py
index 737f1ef4..2f77210a 100755
--- a/src/cython/test/test_euclidean_witness_complex.py
+++ b/src/cython/test/test_euclidean_witness_complex.py
@@ -6,7 +6,7 @@ import gudhi
Author(s): Vincent Rouvreau
- Copyright (C) 2016 INRIA
+ 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
@@ -23,7 +23,7 @@ import gudhi
"""
__author__ = "Vincent Rouvreau"
-__copyright__ = "Copyright (C) 2016 INRIA"
+__copyright__ = "Copyright (C) 2016 Inria"
__license__ = "GPL v3"
diff --git a/src/cython/test/test_reader_utils.py b/src/cython/test/test_reader_utils.py
index 25591fb3..b240c84f 100755
--- a/src/cython/test/test_reader_utils.py
+++ b/src/cython/test/test_reader_utils.py
@@ -6,7 +6,7 @@ import gudhi
Author(s): Vincent Rouvreau
- Copyright (C) 2017 INRIA
+ Copyright (C) 2017 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
@@ -23,7 +23,7 @@ import gudhi
"""
__author__ = "Vincent Rouvreau"
-__copyright__ = "Copyright (C) 2017 INRIA"
+__copyright__ = "Copyright (C) 2017 Inria"
__license__ = "GPL v3"
diff --git a/src/cython/test/test_rips_complex.py b/src/cython/test/test_rips_complex.py
index c7d2ead4..c37b5400 100755
--- a/src/cython/test/test_rips_complex.py
+++ b/src/cython/test/test_rips_complex.py
@@ -7,7 +7,7 @@ from math import sqrt
Author(s): Vincent Rouvreau
- Copyright (C) 2016 INRIA
+ 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
@@ -24,7 +24,7 @@ from math import sqrt
"""
__author__ = "Vincent Rouvreau"
-__copyright__ = "Copyright (C) 2016 INRIA"
+__copyright__ = "Copyright (C) 2016 Inria"
__license__ = "GPL v3"
diff --git a/src/cython/test/test_simplex_tree.py b/src/cython/test/test_simplex_tree.py
index 4d452d7d..cb701c9a 100755
--- a/src/cython/test/test_simplex_tree.py
+++ b/src/cython/test/test_simplex_tree.py
@@ -6,7 +6,7 @@ from gudhi import SimplexTree
Author(s): Vincent Rouvreau
- Copyright (C) 2016 INRIA
+ 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
@@ -23,7 +23,7 @@ from gudhi import SimplexTree
"""
__author__ = "Vincent Rouvreau"
-__copyright__ = "Copyright (C) 2016 INRIA"
+__copyright__ = "Copyright (C) 2016 Inria"
__license__ = "GPL v3"
@@ -34,9 +34,13 @@ def test_insertion():
# insert test
assert st.insert([0, 1]) == True
+
+ assert st.dimension() == 1
+
assert st.insert([0, 1, 2], filtration=4.0) == True
- # FIXME: Remove this line
- st.set_dimension(2)
+
+ assert st.dimension() == 2
+
assert st.num_simplices() == 7
assert st.num_vertices() == 3
@@ -86,8 +90,9 @@ def test_insertion():
assert st.find([2]) == True
st.initialize_filtration()
- assert st.persistence() == [(1, (4.0, float('inf'))), (0, (0.0, float('inf')))]
+ assert st.persistence(persistence_dim_max = True) == [(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]
@@ -129,3 +134,74 @@ def test_expansion():
([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)]
+
+def test_automatic_dimension():
+ st = SimplexTree()
+ assert st.__is_defined() == True
+ assert st.__is_persistence_defined() == False
+
+ # insert test
+ assert st.insert([0,1,3], filtration=0.5) == True
+ assert st.insert([0,1,2], filtration=1.) == True
+
+ assert st.num_vertices() == 4
+ assert st.num_simplices() == 11
+
+ assert st.dimension() == 2
+ assert st.upper_bound_dimension() == 2
+
+ assert st.prune_above_filtration(0.6) == True
+ assert st.dimension() == 2
+ assert st.upper_bound_dimension() == 2
+
+ st.assign_filtration([0, 1, 3], 0.7)
+ assert st.filtration([0, 1, 3]) == 0.7
+
+ st.remove_maximal_simplex([0, 1, 3])
+ assert st.upper_bound_dimension() == 2
+ assert st.dimension() == 1
+ assert st.upper_bound_dimension() == 1
+
+def test_make_filtration_non_decreasing():
+ st = SimplexTree()
+ assert st.__is_defined() == True
+ assert st.__is_persistence_defined() == False
+
+ # Inserted simplex:
+ # 1
+ # o
+ # /X\
+ # o---o---o---o
+ # 2 0 3\X/4
+ # o
+ # 5
+ assert st.insert([2, 1, 0], filtration=2.0) == True
+ assert st.insert([3, 0], filtration=2.0) == True
+ assert st.insert([3, 4, 5], filtration=2.0) == True
+
+ assert st.make_filtration_non_decreasing() == False
+
+ # Because of non decreasing property of simplex tree, { 0 } , { 1 } and
+ # { 0, 1 } are going to be set from value 2.0 to 1.0
+ st.insert([0, 1, 6, 7], filtration=1.0);
+
+ assert st.make_filtration_non_decreasing() == False
+
+ # Modify specific values to test make_filtration_non_decreasing
+ st.assign_filtration([0,1,6,7], 0.8);
+ st.assign_filtration([0,1,6], 0.9);
+ st.assign_filtration([0,6], 0.6);
+ st.assign_filtration([3,4,5], 1.2);
+ st.assign_filtration([3,4], 1.1);
+ st.assign_filtration([4,5], 1.99);
+
+ assert st.make_filtration_non_decreasing() == True
+
+ assert st.filtration([0,1,6,7]) == 1.
+ assert st.filtration([0,1,6]) == 1.
+ assert st.filtration([0,1]) == 1.
+ assert st.filtration([0]) == 1.
+ assert st.filtration([1]) == 1.
+ assert st.filtration([3,4,5]) == 2.
+ assert st.filtration([3,4]) == 2.
+ assert st.filtration([4,5]) == 2.
diff --git a/src/cython/test/test_subsampling.py b/src/cython/test/test_subsampling.py
index 2caf4ddb..96906a6f 100755
--- a/src/cython/test/test_subsampling.py
+++ b/src/cython/test/test_subsampling.py
@@ -6,7 +6,7 @@ import gudhi
Author(s): Vincent Rouvreau
- Copyright (C) 2016 INRIA
+ 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
@@ -23,7 +23,7 @@ import gudhi
"""
__author__ = "Vincent Rouvreau"
-__copyright__ = "Copyright (C) 2016 INRIA"
+__copyright__ = "Copyright (C) 2016 Inria"
__license__ = "GPL v3"
diff --git a/src/cython/test/test_tangential_complex.py b/src/cython/test/test_tangential_complex.py
index 8aa4023c..5385a0d3 100755
--- a/src/cython/test/test_tangential_complex.py
+++ b/src/cython/test/test_tangential_complex.py
@@ -6,7 +6,7 @@ from gudhi import TangentialComplex, SimplexTree
Author(s): Vincent Rouvreau
- Copyright (C) 2016 INRIA
+ 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
@@ -23,13 +23,13 @@ from gudhi import TangentialComplex, SimplexTree
"""
__author__ = "Vincent Rouvreau"
-__copyright__ = "Copyright (C) 2016 INRIA"
+__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)
+ tc = TangentialComplex(intrisic_dim = 1, points=point_list)
assert tc.__is_defined() == True
assert tc.num_vertices() == 4
diff --git a/src/cython/test/test_witness_complex.py b/src/cython/test/test_witness_complex.py
index 7d1fb6be..bcbc521b 100755
--- a/src/cython/test/test_witness_complex.py
+++ b/src/cython/test/test_witness_complex.py
@@ -6,7 +6,7 @@ from gudhi import WitnessComplex, StrongWitnessComplex, SimplexTree
Author(s): Vincent Rouvreau
- Copyright (C) 2016 INRIA
+ 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
@@ -23,7 +23,7 @@ from gudhi import WitnessComplex, StrongWitnessComplex, SimplexTree
"""
__author__ = "Vincent Rouvreau"
-__copyright__ = "Copyright (C) 2016 INRIA"
+__copyright__ = "Copyright (C) 2016 Inria"
__license__ = "GPL v3"