From 495f3d9b51f5ed48151118fedcc61f5067f04d51 Mon Sep 17 00:00:00 2001 From: Vincent Rouvreau Date: Wed, 30 Mar 2022 12:22:56 +0200 Subject: get/set float_relative_precision and its documentation --- src/python/gudhi/alpha_complex.pyx | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) (limited to 'src/python/gudhi') diff --git a/src/python/gudhi/alpha_complex.pyx b/src/python/gudhi/alpha_complex.pyx index a4888914..9af62b43 100644 --- a/src/python/gudhi/alpha_complex.pyx +++ b/src/python/gudhi/alpha_complex.pyx @@ -31,6 +31,10 @@ cdef extern from "Alpha_complex_interface.h" namespace "Gudhi": Alpha_complex_interface(vector[vector[double]] points, vector[double] weights, bool fast_version, bool exact_version) nogil except + vector[double] get_point(int vertex) nogil except + void create_simplex_tree(Simplex_tree_interface_full_featured* simplex_tree, double max_alpha_square, bool default_filtration_value) nogil except + + @staticmethod + void set_float_relative_precision(double precision) nogil + @staticmethod + double get_float_relative_precision() nogil # AlphaComplex python interface cdef class AlphaComplex: @@ -133,3 +137,27 @@ cdef class AlphaComplex: self.this_ptr.create_simplex_tree(stree_int_ptr, mas, compute_filtration) return stree + + @staticmethod + def set_float_relative_precision(precision): + """ + :param precision: When the AlphaComplex is constructed with :code:`precision = 'safe'` (the default), + one can set the float relative precision of filtration values computed in + :func:`~gudhi.AlphaComplex.create_simplex_tree`. + Default is :code:`1e-5` (cf. :func:`~gudhi.AlphaComplex.get_float_relative_precision`). + For more details, please refer to + `CGAL::Lazy_exact_nt::set_relative_precision_of_to_double `_ + :type precision: float + """ + if precision <=0. or precision >= 1.: + raise ValueError("Relative precision value must be strictly greater than 0 and strictly lower than 1") + Alpha_complex_interface.set_float_relative_precision(precision) + + @staticmethod + def get_float_relative_precision(): + """ + :returns: The float relative precision of filtration values computation in + :func:`~gudhi.AlphaComplex.create_simplex_tree`. + :rtype: float + """ + return Alpha_complex_interface.get_float_relative_precision() -- cgit v1.2.3 From f4b543bb4891b1c2aa104e45cc5a0d07b56e6977 Mon Sep 17 00:00:00 2001 From: Vincent Rouvreau Date: Thu, 31 Mar 2022 21:15:18 +0200 Subject: code review: no need to nogil for cheap functions. Repeat get_float_relative_precision is only for safe mode --- src/python/gudhi/alpha_complex.pyx | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) (limited to 'src/python/gudhi') diff --git a/src/python/gudhi/alpha_complex.pyx b/src/python/gudhi/alpha_complex.pyx index 9af62b43..e63796db 100644 --- a/src/python/gudhi/alpha_complex.pyx +++ b/src/python/gudhi/alpha_complex.pyx @@ -32,9 +32,9 @@ cdef extern from "Alpha_complex_interface.h" namespace "Gudhi": vector[double] get_point(int vertex) nogil except + void create_simplex_tree(Simplex_tree_interface_full_featured* simplex_tree, double max_alpha_square, bool default_filtration_value) nogil except + @staticmethod - void set_float_relative_precision(double precision) nogil + void set_float_relative_precision(double precision) @staticmethod - double get_float_relative_precision() nogil + double get_float_relative_precision() # AlphaComplex python interface cdef class AlphaComplex: @@ -157,7 +157,8 @@ cdef class AlphaComplex: def get_float_relative_precision(): """ :returns: The float relative precision of filtration values computation in - :func:`~gudhi.AlphaComplex.create_simplex_tree`. + :func:`~gudhi.AlphaComplex.create_simplex_tree` when the AlphaComplex is constructed with + :code:`precision = 'safe'` (the default). :rtype: float """ return Alpha_complex_interface.get_float_relative_precision() -- cgit v1.2.3 From 25172af7cbe5a3ea3017bed6fde53be471a7e4bf Mon Sep 17 00:00:00 2001 From: Vincent Rouvreau Date: Tue, 5 Apr 2022 13:35:11 +0200 Subject: nogil for float_relative_precision methods --- src/python/gudhi/alpha_complex.pyx | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src/python/gudhi') diff --git a/src/python/gudhi/alpha_complex.pyx b/src/python/gudhi/alpha_complex.pyx index e63796db..375e1561 100644 --- a/src/python/gudhi/alpha_complex.pyx +++ b/src/python/gudhi/alpha_complex.pyx @@ -32,9 +32,9 @@ cdef extern from "Alpha_complex_interface.h" namespace "Gudhi": vector[double] get_point(int vertex) nogil except + void create_simplex_tree(Simplex_tree_interface_full_featured* simplex_tree, double max_alpha_square, bool default_filtration_value) nogil except + @staticmethod - void set_float_relative_precision(double precision) + void set_float_relative_precision(double precision) nogil @staticmethod - double get_float_relative_precision() + double get_float_relative_precision() nogil # AlphaComplex python interface cdef class AlphaComplex: -- cgit v1.2.3