summaryrefslogtreecommitdiff
path: root/src/python/gudhi/bottleneck.pyx
diff options
context:
space:
mode:
authorMarc Glisse <marc.glisse@inria.fr>2020-05-04 20:13:05 +0200
committerMarc Glisse <marc.glisse@inria.fr>2020-05-04 20:13:05 +0200
commit5ad8f41550d94988214fbf128a179d918635c3cf (patch)
tree5d3acb989e3f7ec27e53e66ca5ab4fb95cbc1430 /src/python/gudhi/bottleneck.pyx
parent07a017ca26238847e9d9ab75dcb17e52c81e6865 (diff)
Add some nogil for cython
Diffstat (limited to 'src/python/gudhi/bottleneck.pyx')
-rw-r--r--src/python/gudhi/bottleneck.pyx20
1 files changed, 14 insertions, 6 deletions
diff --git a/src/python/gudhi/bottleneck.pyx b/src/python/gudhi/bottleneck.pyx
index af011e88..6a88895e 100644
--- a/src/python/gudhi/bottleneck.pyx
+++ b/src/python/gudhi/bottleneck.pyx
@@ -17,8 +17,8 @@ __copyright__ = "Copyright (C) 2016 Inria"
__license__ = "GPL v3"
cdef extern from "Bottleneck_distance_interface.h" namespace "Gudhi::persistence_diagram":
- double bottleneck(vector[pair[double, double]], vector[pair[double, double]], double)
- double bottleneck(vector[pair[double, double]], vector[pair[double, double]])
+ double bottleneck(vector[pair[double, double]], vector[pair[double, double]], double) nogil
+ double bottleneck(vector[pair[double, double]], vector[pair[double, double]]) nogil
def bottleneck_distance(diagram_1, diagram_2, e=None):
"""This function returns the point corresponding to a given vertex.
@@ -40,9 +40,17 @@ def bottleneck_distance(diagram_1, diagram_2, e=None):
:rtype: float
:returns: the bottleneck distance.
"""
+ cdef vector[pair[double, double]] dgm1 = diagram_1
+ cdef vector[pair[double, double]] dgm2 = diagram_2
+ cdef double eps
+ cdef double ret
if e is None:
- # Default value is the smallest double value (not 0, 0 is for exact version)
- return bottleneck(diagram_1, diagram_2)
+ with nogil:
+ # Default value is the smallest double value (not 0, 0 is for exact version)
+ ret = bottleneck(dgm1, dgm2)
else:
- # Can be 0 for exact version
- return bottleneck(diagram_1, diagram_2, e)
+ eps = e
+ with nogil:
+ # Can be 0 for exact version
+ ret = bottleneck(dgm1, dgm2, eps)
+ return ret