From d7d59f1e4245af3595c8eafd0abc0abdc4b5805d Mon Sep 17 00:00:00 2001 From: vrouvrea Date: Wed, 30 Nov 2016 10:33:56 +0000 Subject: Doc, examples and tests updates for tangential git-svn-id: svn+ssh://scm.gforge.inria.fr/svnroot/gudhi/branches/ST_cythonize@1805 636b058d-ea47-450e-bf9e-a15bfbe3eedb Former-commit-id: 56d080f79a7a0c3b6eb3ed38b376e899cb17c8f9 --- src/cython/test/test_tangential_complex.py | 56 ++++++++++++++++++++++++++++++ 1 file changed, 56 insertions(+) create mode 100755 src/cython/test/test_tangential_complex.py (limited to 'src/cython/test/test_tangential_complex.py') 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 . +""" + +__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) == [] -- cgit v1.2.3 From 4d96411e43ddcf6c1bd47f6cc0df7c542b127e2e Mon Sep 17 00:00:00 2001 From: vrouvrea Date: Mon, 20 Mar 2017 16:42:26 +0000 Subject: rename get_coface_tree with get_cofaces git-svn-id: svn+ssh://scm.gforge.inria.fr/svnroot/gudhi/branches/ST_cythonize@2210 636b058d-ea47-450e-bf9e-a15bfbe3eedb Former-commit-id: c88576269982d87dd2dfd4003811628fee58dc2e --- src/cython/cython/simplex_tree.pyx | 6 +++--- src/cython/example/alpha_complex_from_points_example.py | 2 +- src/cython/example/rips_complex_from_points_example.py | 2 +- src/cython/include/Simplex_tree_interface.h | 2 +- src/cython/test/test_alpha_complex.py | 4 ++-- src/cython/test/test_rips_complex.py | 4 ++-- src/cython/test/test_simplex_tree.py | 2 +- src/cython/test/test_tangential_complex.py | 2 +- 8 files changed, 12 insertions(+), 12 deletions(-) (limited to 'src/cython/test/test_tangential_complex.py') diff --git a/src/cython/cython/simplex_tree.pyx b/src/cython/cython/simplex_tree.pyx index c0016461..05410a08 100644 --- a/src/cython/cython/simplex_tree.pyx +++ b/src/cython/cython/simplex_tree.pyx @@ -49,7 +49,7 @@ cdef extern from "Simplex_tree_interface.h" namespace "Gudhi": vector[pair[vector[int], double]] get_filtered_tree() vector[pair[vector[int], double]] get_skeleton_tree(int dimension) vector[pair[vector[int], double]] get_star_tree(vector[int] simplex) - vector[pair[vector[int], double]] get_coface_tree(vector[int] simplex, + vector[pair[vector[int], double]] get_cofaces(vector[int] simplex, int dimension) void remove_maximal_simplex(vector[int] simplex) @@ -263,7 +263,7 @@ cdef class SimplexTree: ct.append((v, filtered_complex.second)) return ct - def get_coface_tree(self, simplex, codimension): + def get_cofaces(self, simplex, codimension): """This function returns the coface tree of a given N-simplex with a given codimension. @@ -279,7 +279,7 @@ cdef class SimplexTree: for i in simplex: complex.push_back(i) cdef vector[pair[vector[int], double]] coface_tree \ - = self.thisptr.get_coface_tree(complex, codimension) + = self.thisptr.get_cofaces(complex, codimension) ct = [] for filtered_complex in coface_tree: v = [] diff --git a/src/cython/example/alpha_complex_from_points_example.py b/src/cython/example/alpha_complex_from_points_example.py index ae21c711..d14ff360 100755 --- a/src/cython/example/alpha_complex_from_points_example.py +++ b/src/cython/example/alpha_complex_from_points_example.py @@ -61,7 +61,7 @@ else: print("dimension=", simplex_tree.dimension()) print("filtered_tree=", simplex_tree.get_filtered_tree()) print("star([0])=", simplex_tree.get_star_tree([0])) -print("coface([0], 1)=", simplex_tree.get_coface_tree([0], 1)) +print("coface([0], 1)=", simplex_tree.get_cofaces([0], 1)) print("point[0]=", alpha_complex.get_point(0)) print("point[5]=", alpha_complex.get_point(5)) diff --git a/src/cython/example/rips_complex_from_points_example.py b/src/cython/example/rips_complex_from_points_example.py index df6252cd..97cd572e 100755 --- a/src/cython/example/rips_complex_from_points_example.py +++ b/src/cython/example/rips_complex_from_points_example.py @@ -37,4 +37,4 @@ simplex_tree = rips.create_simplex_tree(max_dimension=1) print("filtered_tree=", simplex_tree.get_filtered_tree()) print("star([0])=", simplex_tree.get_star_tree([0])) -print("coface([0], 1)=", simplex_tree.get_coface_tree([0], 1)) +print("coface([0], 1)=", simplex_tree.get_cofaces([0], 1)) diff --git a/src/cython/include/Simplex_tree_interface.h b/src/cython/include/Simplex_tree_interface.h index 65a9e6fc..b88aa539 100644 --- a/src/cython/include/Simplex_tree_interface.h +++ b/src/cython/include/Simplex_tree_interface.h @@ -113,7 +113,7 @@ class Simplex_tree_interface : public Simplex_tree { return star_tree; } - Complex_tree get_coface_tree(const Simplex& complex, int dimension) { + Complex_tree get_cofaces(const Simplex& complex, int dimension) { Complex_tree coface_tree; for (auto f_simplex : Base::cofaces_simplex_range(Base::find(complex), dimension)) { Simplex simplex; diff --git a/src/cython/test/test_alpha_complex.py b/src/cython/test/test_alpha_complex.py index b08ac0d7..486efaf9 100755 --- a/src/cython/test/test_alpha_complex.py +++ b/src/cython/test/test_alpha_complex.py @@ -50,7 +50,7 @@ def test_infinite_alpha(): 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) == \ + assert simplex_tree.get_cofaces([0], 1) == \ [([0, 1], 0.25), ([0, 2], 0.25)] assert point_list[0] == alpha_complex.get_point(0) @@ -82,5 +82,5 @@ def test_filtered_alpha(): ([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) == \ + assert simplex_tree.get_cofaces([0], 1) == \ [([0, 1], 0.25), ([0, 2], 0.25)] diff --git a/src/cython/test/test_rips_complex.py b/src/cython/test/test_rips_complex.py index 464c69e5..78de7f72 100755 --- a/src/cython/test/test_rips_complex.py +++ b/src/cython/test/test_rips_complex.py @@ -52,7 +52,7 @@ def test_rips_from_points(): assert simplex_tree.get_star_tree([0]) == \ [([0], 0.0), ([0, 1], 1.0), ([0, 2], 1.0), ([0, 3], 1.4142135623730951)] - assert simplex_tree.get_coface_tree([0], 1) == \ + assert simplex_tree.get_cofaces([0], 1) == \ [([0, 1], 1.0), ([0, 2], 1.0), ([0, 3], 1.4142135623730951)] @@ -91,7 +91,7 @@ def test_rips_from_distance_matrix(): assert simplex_tree.get_star_tree([0]) == \ [([0], 0.0), ([0, 1], 1.0), ([0, 2], 1.0), ([0, 3], 1.4142135623730951)] - assert simplex_tree.get_coface_tree([0], 1) == \ + assert simplex_tree.get_cofaces([0], 1) == \ [([0, 1], 1.0), ([0, 2], 1.0), ([0, 3], 1.4142135623730951)] diff --git a/src/cython/test/test_simplex_tree.py b/src/cython/test/test_simplex_tree.py index 0b9899f8..7466bf1d 100755 --- a/src/cython/test/test_simplex_tree.py +++ b/src/cython/test/test_simplex_tree.py @@ -75,7 +75,7 @@ def test_insertion(): [([0], 0.0), ([1], 0.0), ([2], 4.0)] # remove_maximal_simplex test - assert st.get_coface_tree([0, 1, 2], 1) == [] + assert st.get_cofaces([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), diff --git a/src/cython/test/test_tangential_complex.py b/src/cython/test/test_tangential_complex.py index 429fc0d0..c191baa4 100755 --- a/src/cython/test/test_tangential_complex.py +++ b/src/cython/test/test_tangential_complex.py @@ -42,7 +42,7 @@ def test_tangential(): assert st.get_filtered_tree() == \ [([0], 0.0), ([1], 0.0), ([2], 0.0), ([0, 2], 0.0), ([3], 0.0), ([1, 3], 0.0)] - assert st.get_coface_tree([0], 1) == [([0, 2], 0.0)] + assert st.get_cofaces([0], 1) == [([0, 2], 0.0)] assert point_list[0] == tc.get_point(0) assert point_list[1] == tc.get_point(1) -- cgit v1.2.3