summaryrefslogtreecommitdiff
path: root/src/python/gudhi/alpha_complex.pyx
diff options
context:
space:
mode:
authorROUVREAU Vincent <vincent.rouvreau@inria.fr>2021-06-09 10:43:02 +0200
committerROUVREAU Vincent <vincent.rouvreau@inria.fr>2021-06-09 10:43:02 +0200
commitafd0a890b39e40cd3ce358c647ae5e77eb288e07 (patch)
tree864dd9bb738ec58becfcfb676976e246c7993002 /src/python/gudhi/alpha_complex.pyx
parent2f507728035c76f16c732b911c52a9118a9b52dd (diff)
code review: weights should be None by default and not an empty list, clearer
Diffstat (limited to 'src/python/gudhi/alpha_complex.pyx')
-rw-r--r--src/python/gudhi/alpha_complex.pyx7
1 files changed, 4 insertions, 3 deletions
diff --git a/src/python/gudhi/alpha_complex.pyx b/src/python/gudhi/alpha_complex.pyx
index 5d181391..caebfab0 100644
--- a/src/python/gudhi/alpha_complex.pyx
+++ b/src/python/gudhi/alpha_complex.pyx
@@ -82,7 +82,7 @@ cdef class AlphaComplex:
"""
# The real cython constructor
- def __cinit__(self, points = [], off_file = '', weights=[], precision = 'safe'):
+ def __cinit__(self, points = [], off_file = '', weights=None, precision = 'safe'):
assert precision in ['fast', 'safe', 'exact'], \
"Alpha complex precision can only be 'fast', 'safe' or 'exact'"
cdef bool fast = precision == 'fast'
@@ -97,14 +97,15 @@ cdef class AlphaComplex:
raise FileNotFoundError(errno.ENOENT, os.strerror(errno.ENOENT), off_file)
# weights are set but is inconsistent with the number of points
- if len(weights) != 0 and len(weights) != len(points):
+ if weights != None and len(weights) != len(points):
raise ValueError("Inconsistency between the number of points and weights")
# need to copy the points to use them without the gil
cdef vector[vector[double]] pts
cdef vector[double] wgts
pts = points
- wgts = weights
+ if weights != None:
+ wgts = weights
with nogil:
self.this_ptr = new Alpha_complex_interface(pts, wgts, fast, exact)