summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorvrouvrea <vrouvrea@636b058d-ea47-450e-bf9e-a15bfbe3eedb>2017-02-16 16:06:16 +0000
committervrouvrea <vrouvrea@636b058d-ea47-450e-bf9e-a15bfbe3eedb>2017-02-16 16:06:16 +0000
commit1cea4c9f6af3fff2b907c7e5e0d9417bc4afaff4 (patch)
tree151bba4f51be469e19b287fa0fb659ebecba9fff /src
parent518acce63202c7b89fa3f76467e50eee7630cf62 (diff)
Do not use args default value set to []
git-svn-id: svn+ssh://scm.gforge.inria.fr/svnroot/gudhi/branches/ST_cythonize@2082 636b058d-ea47-450e-bf9e-a15bfbe3eedb Former-commit-id: 107892dbf3afcf8d46c80f49470e350f57d0090e
Diffstat (limited to 'src')
-rw-r--r--src/cython/cython/alpha_complex.pyx7
-rw-r--r--src/cython/cython/subsampling.pyx28
-rw-r--r--src/cython/cython/tangential_complex.pyx5
-rw-r--r--src/cython/cython/witness_complex.pyx2
4 files changed, 31 insertions, 11 deletions
diff --git a/src/cython/cython/alpha_complex.pyx b/src/cython/cython/alpha_complex.pyx
index 6b27594a..da537c2e 100644
--- a/src/cython/cython/alpha_complex.pyx
+++ b/src/cython/cython/alpha_complex.pyx
@@ -62,7 +62,7 @@ cdef class AlphaComplex:
cdef Alpha_complex_interface * thisptr
# Fake constructor that does nothing but documenting the constructor
- def __init__(self, points=[], off_file=''):
+ def __init__(self, points=None, off_file=''):
"""AlphaComplex constructor.
:param points: A list of points in d-Dimension.
@@ -75,13 +75,16 @@ cdef class AlphaComplex:
"""
# The real cython constructor
- def __cinit__(self, points=[], off_file=''):
+ def __cinit__(self, points=None, off_file=''):
if off_file is not '':
if os.path.isfile(off_file):
self.thisptr = new Alpha_complex_interface(off_file, True)
else:
print("file " + off_file + " not found.")
else:
+ if points is None:
+ # Empty Alpha construction
+ points=[]
self.thisptr = new Alpha_complex_interface(points)
diff --git a/src/cython/cython/subsampling.pyx b/src/cython/cython/subsampling.pyx
index 05c0232f..a25d196d 100644
--- a/src/cython/cython/subsampling.pyx
+++ b/src/cython/cython/subsampling.pyx
@@ -40,7 +40,7 @@ cdef extern from "Subsampling_interface.h" namespace "Gudhi::subsampling":
vector[vector[double]] subsampling_sparsify_points(vector[vector[double]] points, double min_squared_dist)
vector[vector[double]] subsampling_sparsify_points_from_file(string off_file, double min_squared_dist)
-def choose_n_farthest_points(points=[], off_file='', nb_points=0, starting_point = ''):
+def choose_n_farthest_points(points=None, off_file='', nb_points=0, starting_point = ''):
"""Subsample by a greedy strategy of iteratively adding the farthest point
from the current chosen point set to the subsampling.
The iteration starts with the landmark `starting point`.
@@ -65,18 +65,25 @@ def choose_n_farthest_points(points=[], off_file='', nb_points=0, starting_point
if off_file is not '':
if os.path.isfile(off_file):
if starting_point is '':
- return subsampling_n_farthest_points_from_file(off_file, nb_points)
+ return subsampling_n_farthest_points_from_file(off_file,
+ nb_points)
else:
- return subsampling_n_farthest_points_from_file(off_file, nb_points, starting_point)
+ return subsampling_n_farthest_points_from_file(off_file,
+ nb_points,
+ starting_point)
else:
print("file " + off_file + " not found.")
else:
+ if points is None:
+ # Empty points
+ points=[]
if starting_point is '':
return subsampling_n_farthest_points(points, nb_points)
else:
- return subsampling_n_farthest_points(points, nb_points, starting_point)
+ return subsampling_n_farthest_points(points, nb_points,
+ starting_point)
-def pick_n_random_points(points=[], off_file='', nb_points=0):
+def pick_n_random_points(points=None, off_file='', nb_points=0):
"""Subsample a point set by picking random vertices.
:param points: The input point set.
@@ -98,9 +105,12 @@ def pick_n_random_points(points=[], off_file='', nb_points=0):
else:
print("file " + off_file + " not found.")
else:
+ if points is None:
+ # Empty points
+ points=[]
return subsampling_n_random_points(points, nb_points)
-def sparsify_point_set(points=[], off_file='', min_squared_dist=0.0):
+def sparsify_point_set(points=None, off_file='', min_squared_dist=0.0):
"""Subsample a point set by picking random vertices.
:param points: The input point set.
@@ -118,8 +128,12 @@ def sparsify_point_set(points=[], off_file='', min_squared_dist=0.0):
"""
if off_file is not '':
if os.path.isfile(off_file):
- return subsampling_sparsify_points_from_file(off_file, min_squared_dist)
+ return subsampling_sparsify_points_from_file(off_file,
+ min_squared_dist)
else:
print("file " + off_file + " not found.")
else:
+ if points is None:
+ # Empty points
+ points=[]
return subsampling_sparsify_points(points, min_squared_dist)
diff --git a/src/cython/cython/tangential_complex.pyx b/src/cython/cython/tangential_complex.pyx
index c0260577..1b213c3a 100644
--- a/src/cython/cython/tangential_complex.pyx
+++ b/src/cython/cython/tangential_complex.pyx
@@ -80,13 +80,16 @@ cdef class TangentialComplex:
"""
# The real cython constructor
- def __cinit__(self, points=[], off_file=''):
+ def __cinit__(self, points=None, off_file=''):
if off_file is not '':
if os.path.isfile(off_file):
self.thisptr = new Tangential_complex_interface(off_file, True)
else:
print("file " + off_file + " not found.")
else:
+ if points is None:
+ # Empty tangential construction
+ points=[]
self.thisptr = new Tangential_complex_interface(points)
diff --git a/src/cython/cython/witness_complex.pyx b/src/cython/cython/witness_complex.pyx
index 835244cf..b2ad4e68 100644
--- a/src/cython/cython/witness_complex.pyx
+++ b/src/cython/cython/witness_complex.pyx
@@ -62,7 +62,7 @@ cdef class WitnessComplex:
cdef Witness_complex_interface * thisptr
# Fake constructor that does nothing but documenting the constructor
- def __init__(self, points=[], number_of_landmarks=5):
+ def __init__(self, points=None, number_of_landmarks=5):
"""WitnessComplex constructor.
:param points: A list of points in d-Dimension.