From a71694354af45e8edc2e2d2b4e14795bf9b5e5f1 Mon Sep 17 00:00:00 2001 From: ROUVREAU Vincent Date: Fri, 12 Mar 2021 15:46:36 +0100 Subject: review constructor and test with one point and without points --- src/python/gudhi/alpha_complex.pyx | 8 +++----- src/python/test/test_alpha_complex.py | 5 +++++ 2 files changed, 8 insertions(+), 5 deletions(-) (limited to 'src') diff --git a/src/python/gudhi/alpha_complex.pyx b/src/python/gudhi/alpha_complex.pyx index ea128743..f5f0ca5b 100644 --- a/src/python/gudhi/alpha_complex.pyx +++ b/src/python/gudhi/alpha_complex.pyx @@ -71,20 +71,18 @@ cdef class AlphaComplex: """ # The real cython constructor - def __cinit__(self, points = None, off_file = '', precision = 'safe'): + def __cinit__(self, points = [], off_file = '', precision = 'safe'): assert precision in ['fast', 'safe', 'exact'], "Alpha complex precision can only be 'fast', 'safe' or 'exact'" cdef bool fast = precision == 'fast' cdef bool exact = precision == 'exact' - cdef vector[vector[double]] pts if off_file: if os.path.isfile(off_file): points = read_points_from_off_file(off_file = off_file) else: print("file " + off_file + " not found.") - if points is None: - # Empty Alpha construction - points=[] + # need to copy the points to use them without the gil + cdef vector[vector[double]] pts pts = points with nogil: self.this_ptr = new Alpha_complex_interface(pts, fast, exact) diff --git a/src/python/test/test_alpha_complex.py b/src/python/test/test_alpha_complex.py index 814f8289..8f1424ec 100755 --- a/src/python/test/test_alpha_complex.py +++ b/src/python/test/test_alpha_complex.py @@ -25,12 +25,17 @@ __license__ = "MIT" def _empty_alpha(precision): + alpha_complex = gd.AlphaComplex(precision = precision) + assert alpha_complex.__is_defined() == True + +def _one_2d_point_alpha(precision): alpha_complex = gd.AlphaComplex(points=[[0, 0]], precision = precision) assert alpha_complex.__is_defined() == True def test_empty_alpha(): for precision in ['fast', 'safe', 'exact']: _empty_alpha(precision) + _one_2d_point_alpha(precision) def _infinite_alpha(precision): point_list = [[0, 0], [1, 0], [0, 1], [1, 1]] -- cgit v1.2.3