summaryrefslogtreecommitdiff
path: root/src/cython
diff options
context:
space:
mode:
authorvrouvrea <vrouvrea@636b058d-ea47-450e-bf9e-a15bfbe3eedb>2017-03-21 09:33:19 +0000
committervrouvrea <vrouvrea@636b058d-ea47-450e-bf9e-a15bfbe3eedb>2017-03-21 09:33:19 +0000
commita26b039683e35a64f7a3feb544a195b4a4510ec1 (patch)
treeae4b370da0599ed25b998d993c0d4a46073d6176 /src/cython
parent4d96411e43ddcf6c1bd47f6cc0df7c542b127e2e (diff)
Rename get_star_tree with get_stars
Rename Complex_tree typedef with Complex Typo in Rips doc for csv files for distance matrices git-svn-id: svn+ssh://scm.gforge.inria.fr/svnroot/gudhi/branches/ST_cythonize@2211 636b058d-ea47-450e-bf9e-a15bfbe3eedb Former-commit-id: a6be0ce66ef3c2c71ad43b328cebd673862a76d2
Diffstat (limited to 'src/cython')
-rw-r--r--src/cython/cython/simplex_tree.pyx28
-rw-r--r--src/cython/doc/rips_complex_user.rst2
-rwxr-xr-xsrc/cython/example/alpha_complex_from_points_example.py2
-rwxr-xr-xsrc/cython/example/rips_complex_from_points_example.py2
-rw-r--r--src/cython/include/Simplex_tree_interface.h55
-rwxr-xr-xsrc/cython/test/test_alpha_complex.py4
-rwxr-xr-xsrc/cython/test/test_rips_complex.py4
7 files changed, 50 insertions, 47 deletions
diff --git a/src/cython/cython/simplex_tree.pyx b/src/cython/cython/simplex_tree.pyx
index 05410a08..4bcda1cb 100644
--- a/src/cython/cython/simplex_tree.pyx
+++ b/src/cython/cython/simplex_tree.pyx
@@ -48,7 +48,7 @@ cdef extern from "Simplex_tree_interface.h" namespace "Gudhi":
double filtration)
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_stars(vector[int] simplex)
vector[pair[vector[int], double]] get_cofaces(vector[int] simplex,
int dimension)
void remove_maximal_simplex(vector[int] simplex)
@@ -213,10 +213,10 @@ cdef class SimplexTree:
:returns: The tree sorted by increasing filtration values.
:rtype: list of tuples(simplex, filtration)
"""
- cdef vector[pair[vector[int], double]] coface_tree \
+ cdef vector[pair[vector[int], double]] filtered_tree \
= self.thisptr.get_filtered_tree()
ct = []
- for filtered_complex in coface_tree:
+ for filtered_complex in filtered_tree:
v = []
for vertex in filtered_complex.first:
v.append(vertex)
@@ -232,18 +232,18 @@ cdef class SimplexTree:
:returns: The skeleton tree of a maximum dimension.
:rtype: list of tuples(simplex, filtration)
"""
- cdef vector[pair[vector[int], double]] coface_tree \
+ cdef vector[pair[vector[int], double]] sk_tree \
= self.thisptr.get_skeleton_tree(<int>dimension)
ct = []
- for filtered_complex in coface_tree:
+ for filtered_complex in sk_tree:
v = []
for vertex in filtered_complex.first:
v.append(vertex)
ct.append((v, filtered_complex.second))
return ct
- def get_star_tree(self, simplex):
- """This function returns the star tree of a given N-simplex.
+ def get_stars(self, simplex):
+ """This function returns the stars of a given N-simplex.
:param simplex: The N-simplex, represented by a list of vertex.
:type simplex: list of int.
@@ -253,10 +253,10 @@ cdef class SimplexTree:
cdef vector[int] complex
for i in simplex:
complex.push_back(i)
- cdef vector[pair[vector[int], double]] coface_tree \
- = self.thisptr.get_star_tree(complex)
+ cdef vector[pair[vector[int], double]] stars \
+ = self.thisptr.get_stars(complex)
ct = []
- for filtered_complex in coface_tree:
+ for filtered_complex in stars:
v = []
for vertex in filtered_complex.first:
v.append(vertex)
@@ -264,13 +264,13 @@ cdef class SimplexTree:
return ct
def get_cofaces(self, simplex, codimension):
- """This function returns the coface tree of a given N-simplex with a
+ """This function returns the cofaces of a given N-simplex with a
given codimension.
:param simplex: The N-simplex, represented by a list of vertex.
:type simplex: list of int.
:param codimension: The codimension. If codimension = 0, all cofaces
- are returned (equivalent of get_star_tree function)
+ are returned (equivalent of get_stars function)
:type codimension: int.
:returns: The coface tree of a simplex.
:rtype: list of tuples(simplex, filtration)
@@ -278,10 +278,10 @@ cdef class SimplexTree:
cdef vector[int] complex
for i in simplex:
complex.push_back(i)
- cdef vector[pair[vector[int], double]] coface_tree \
+ cdef vector[pair[vector[int], double]] cofaces \
= self.thisptr.get_cofaces(complex, <int>codimension)
ct = []
- for filtered_complex in coface_tree:
+ for filtered_complex in cofaces:
v = []
for vertex in filtered_complex.first:
v.append(vertex)
diff --git a/src/cython/doc/rips_complex_user.rst b/src/cython/doc/rips_complex_user.rst
index a5d17e19..027c3bf7 100644
--- a/src/cython/doc/rips_complex_user.rst
+++ b/src/cython/doc/rips_complex_user.rst
@@ -190,7 +190,7 @@ until dimension 1 - one skeleton graph in other words), the output is:
([4, 6], 9.4868329805)
([3, 6], 11.0)
-Example from OFF file
+Example from csv file
^^^^^^^^^^^^^^^^^^^^^
This example builds the :doc:`Rips_complex <rips_complex_ref>` from the given
diff --git a/src/cython/example/alpha_complex_from_points_example.py b/src/cython/example/alpha_complex_from_points_example.py
index d14ff360..c50c45f6 100755
--- a/src/cython/example/alpha_complex_from_points_example.py
+++ b/src/cython/example/alpha_complex_from_points_example.py
@@ -60,7 +60,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("star([0])=", simplex_tree.get_stars([0]))
print("coface([0], 1)=", simplex_tree.get_cofaces([0], 1))
print("point[0]=", alpha_complex.get_point(0))
diff --git a/src/cython/example/rips_complex_from_points_example.py b/src/cython/example/rips_complex_from_points_example.py
index 97cd572e..6ed54229 100755
--- a/src/cython/example/rips_complex_from_points_example.py
+++ b/src/cython/example/rips_complex_from_points_example.py
@@ -36,5 +36,5 @@ rips = gudhi.RipsComplex(points=[[0, 0], [1, 0], [0, 1], [1, 1]],
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("star([0])=", simplex_tree.get_stars([0]))
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 b88aa539..8e156be3 100644
--- a/src/cython/include/Simplex_tree_interface.h
+++ b/src/cython/include/Simplex_tree_interface.h
@@ -45,8 +45,7 @@ class Simplex_tree_interface : public Simplex_tree<SimplexTreeOptions> {
using Simplex_handle = typename Base::Simplex_handle;
using Insertion_result = typename std::pair<Simplex_handle, bool>;
using Simplex = std::vector<Vertex_handle>;
- using Filtered_complex = std::pair<Simplex, Filtration_value>;
- using Complex_tree = std::vector<Filtered_complex>;
+ using Complex = std::vector<std::pair<Simplex, Filtration_value>>;
public:
@@ -54,8 +53,8 @@ class Simplex_tree_interface : public Simplex_tree<SimplexTreeOptions> {
return (Base::find(vh) != Base::null_simplex());
}
- bool insert_simplex_and_subfaces(const Simplex& complex, Filtration_value filtration = 0) {
- Insertion_result result = Base::insert_simplex_and_subfaces(complex, filtration);
+ bool insert_simplex_and_subfaces(const Simplex& simplex, Filtration_value filtration = 0) {
+ Insertion_result result = Base::insert_simplex_and_subfaces(simplex, filtration);
Base::initialize_filtration();
return (result.second);
}
@@ -67,17 +66,17 @@ class Simplex_tree_interface : public Simplex_tree<SimplexTreeOptions> {
return (result.second);
}
- Filtration_value simplex_filtration(const Simplex& complex) {
- return Base::filtration(Base::find(complex));
+ Filtration_value simplex_filtration(const Simplex& simplex) {
+ return Base::filtration(Base::find(simplex));
}
- void remove_maximal_simplex(const Simplex& complex) {
- Base::remove_maximal_simplex(Base::find(complex));
+ void remove_maximal_simplex(const Simplex& simplex) {
+ Base::remove_maximal_simplex(Base::find(simplex));
Base::initialize_filtration();
}
- Complex_tree get_filtered_tree() {
- Complex_tree filtered_tree;
+ Complex get_filtered_tree() {
+ Complex filtered_tree;
for (auto f_simplex : Base::filtration_simplex_range()) {
Simplex simplex;
for (auto vertex : Base::simplex_vertex_range(f_simplex)) {
@@ -89,8 +88,8 @@ class Simplex_tree_interface : public Simplex_tree<SimplexTreeOptions> {
}
- Complex_tree get_skeleton_tree(int dimension) {
- Complex_tree skeleton_tree;
+ Complex get_skeleton_tree(int dimension) {
+ Complex skeleton_tree;
for (auto f_simplex : Base::skeleton_simplex_range(dimension)) {
Simplex simplex;
for (auto vertex : Base::simplex_vertex_range(f_simplex)) {
@@ -101,28 +100,32 @@ class Simplex_tree_interface : public Simplex_tree<SimplexTreeOptions> {
return skeleton_tree;
}
- Complex_tree get_star_tree(const Simplex& complex) {
- Complex_tree star_tree;
- for (auto f_simplex : Base::star_simplex_range(Base::find(complex))) {
- Simplex simplex;
+ Complex get_stars(const Simplex& simplex) {
+ Complex stars;
+ for (auto f_simplex : Base::star_simplex_range(Base::find(simplex))) {
+ Simplex simplex_star;
for (auto vertex : Base::simplex_vertex_range(f_simplex)) {
- simplex.insert(simplex.begin(), vertex);
+ std::cout << vertex << " ";
+ simplex_star.insert(simplex_star.begin(), vertex);
}
- star_tree.push_back(std::make_pair(simplex, Base::filtration(f_simplex)));
+ std::cout << std::endl;
+ stars.push_back(std::make_pair(simplex_star, Base::filtration(f_simplex)));
}
- return star_tree;
+ return stars;
}
- 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;
+ Complex get_cofaces(const Simplex& simplex, int dimension) {
+ Complex cofaces;
+ for (auto f_simplex : Base::cofaces_simplex_range(Base::find(simplex), dimension)) {
+ Simplex simplex_coface;
for (auto vertex : Base::simplex_vertex_range(f_simplex)) {
- simplex.insert(simplex.begin(), vertex);
+ std::cout << vertex << " ";
+ simplex_coface.insert(simplex_coface.begin(), vertex);
}
- coface_tree.push_back(std::make_pair(simplex, Base::filtration(f_simplex)));
+ std::cout << std::endl;
+ cofaces.push_back(std::make_pair(simplex_coface, Base::filtration(f_simplex)));
}
- return coface_tree;
+ return cofaces;
}
void create_persistence(Gudhi::Persistent_cohomology_interface<Base>* pcoh) {
diff --git a/src/cython/test/test_alpha_complex.py b/src/cython/test/test_alpha_complex.py
index 486efaf9..f5601ab7 100755
--- a/src/cython/test/test_alpha_complex.py
+++ b/src/cython/test/test_alpha_complex.py
@@ -47,7 +47,7 @@ def test_infinite_alpha():
([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]) == \
+ assert simplex_tree.get_stars([0]) == \
[([0], 0.0), ([0, 1], 0.25), ([0, 1, 2], 0.5),
([0, 2], 0.25)]
assert simplex_tree.get_cofaces([0], 1) == \
@@ -80,7 +80,7 @@ def test_filtered_alpha():
[([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]) == \
+ assert simplex_tree.get_stars([0]) == \
[([0], 0.0), ([0, 1], 0.25), ([0, 2], 0.25)]
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 78de7f72..4acf0a30 100755
--- a/src/cython/test/test_rips_complex.py
+++ b/src/cython/test/test_rips_complex.py
@@ -49,7 +49,7 @@ def test_rips_from_points():
([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_tree([0]) == \
+ assert simplex_tree.get_stars([0]) == \
[([0], 0.0), ([0, 1], 1.0), ([0, 2], 1.0),
([0, 3], 1.4142135623730951)]
assert simplex_tree.get_cofaces([0], 1) == \
@@ -88,7 +88,7 @@ def test_rips_from_distance_matrix():
([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_tree([0]) == \
+ assert simplex_tree.get_stars([0]) == \
[([0], 0.0), ([0, 1], 1.0), ([0, 2], 1.0),
([0, 3], 1.4142135623730951)]
assert simplex_tree.get_cofaces([0], 1) == \