summaryrefslogtreecommitdiff
path: root/src/python
diff options
context:
space:
mode:
Diffstat (limited to 'src/python')
-rw-r--r--src/python/gudhi/simplex_tree.pxd1
-rw-r--r--src/python/gudhi/simplex_tree.pyx10
-rwxr-xr-xsrc/python/test/test_simplex_tree.py25
3 files changed, 34 insertions, 2 deletions
diff --git a/src/python/gudhi/simplex_tree.pxd b/src/python/gudhi/simplex_tree.pxd
index 75e94e0b..3b494ba3 100644
--- a/src/python/gudhi/simplex_tree.pxd
+++ b/src/python/gudhi/simplex_tree.pxd
@@ -58,6 +58,7 @@ cdef extern from "Simplex_tree_interface.h" namespace "Gudhi":
void compute_extended_filtration() nogil
vector[vector[pair[int, pair[double, double]]]] compute_extended_persistence_subdiagrams(vector[pair[int, pair[double, double]]] dgm, double min_persistence) nogil
Simplex_tree_interface_full_featured* collapse_edges(int nb_collapse_iteration) nogil
+ void reset_filtration(double filtration, int dimension) nogil
# Iterators over Simplex tree
pair[vector[int], double] get_simplex_and_filtration(Simplex_tree_simplex_handle f_simplex) nogil
Simplex_tree_simplices_iterator get_simplices_iterator_begin() nogil
diff --git a/src/python/gudhi/simplex_tree.pyx b/src/python/gudhi/simplex_tree.pyx
index dfb1d985..b7682693 100644
--- a/src/python/gudhi/simplex_tree.pyx
+++ b/src/python/gudhi/simplex_tree.pyx
@@ -358,6 +358,16 @@ cdef class SimplexTree:
"""
return self.get_ptr().make_filtration_non_decreasing()
+ def reset_filtration(self, filtration, max_dim):
+ """This function resets filtration value until a given dimension.
+
+ :param filtration: New threshold value.
+ :type filtration: float.
+ :param max_dim: The maximal dimension.
+ :type max_dim: int.
+ """
+ self.get_ptr().reset_filtration(filtration, max_dim)
+
def extend_filtration(self):
""" Extend filtration for computing extended persistence. This function only uses the
filtration values at the 0-dimensional simplices, and computes the extended persistence
diff --git a/src/python/test/test_simplex_tree.py b/src/python/test/test_simplex_tree.py
index 83be0602..6f1d01cc 100755
--- a/src/python/test/test_simplex_tree.py
+++ b/src/python/test/test_simplex_tree.py
@@ -356,5 +356,26 @@ def test_collapse_edges():
st.collapse_edges()
assert st.num_simplices() == 9
assert st.find([1, 3]) == False
- for simplex in st.get_skeleton(0):
- assert simplex[1] == 1.
+ for simplex in st.get_skeleton(0):
+ assert simplex[1] == 1.
+
+def test_reset_filtration():
+ st = SimplexTree()
+
+ assert st.insert([0, 1, 2], 3.) == True
+ assert st.insert([0, 3], 2.) == True
+ assert st.insert([3, 4, 5], 3.) == True
+ assert st.insert([0, 1, 6, 7], 4.) == True
+
+ for simplex in st.get_simplices():
+ assert st.filtration(simplex[0]) >= 0.
+
+ # dimension until 5 even if simplex tree is of dimension 3 to test the limits
+ for dimension in range(0, 6):
+ st.reset_filtration(0., dimension)
+ for simplex in st.get_skeleton(3):
+ print(simplex)
+ if len(simplex[0]) > (dimension + 1):
+ assert st.filtration(simplex[0]) >= 1.
+ else:
+ assert st.filtration(simplex[0]) == 0.