summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorROUVREAU Vincent <vincent.rouvreau@inria.fr>2021-03-12 15:46:36 +0100
committerROUVREAU Vincent <vincent.rouvreau@inria.fr>2021-03-12 15:46:36 +0100
commita71694354af45e8edc2e2d2b4e14795bf9b5e5f1 (patch)
tree828037055878f60b5aa37468933bdd082af2dffa
parentc838e3ec441109cc02ea4612dd2189860662298f (diff)
review constructor and test with one point and without points
-rw-r--r--src/python/gudhi/alpha_complex.pyx8
-rwxr-xr-xsrc/python/test/test_alpha_complex.py5
2 files changed, 8 insertions, 5 deletions
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]]