From 8b658271dd38f1aaffbe94be8978cf5cea8ec7de Mon Sep 17 00:00:00 2001 From: Marc Glisse Date: Wed, 16 Nov 2022 00:20:04 +0100 Subject: Output matching from hera.wasserstein_distance --- src/python/gudhi/hera/bottleneck.cc | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) (limited to 'src/python/gudhi/hera/bottleneck.cc') diff --git a/src/python/gudhi/hera/bottleneck.cc b/src/python/gudhi/hera/bottleneck.cc index ec461f7c..6b919b02 100644 --- a/src/python/gudhi/hera/bottleneck.cc +++ b/src/python/gudhi/hera/bottleneck.cc @@ -16,13 +16,16 @@ using py::ssize_t; #endif -#include // Hera +#include + +// Indices are added internally in bottleneck_distance, they are not needed in the input. +static auto make_point(double x, double y, py::ssize_t) { return std::pair(x, y); }; double bottleneck_distance(Dgm d1, Dgm d2, double delta) { // I *think* the call to request() has to be before releasing the GIL. - auto diag1 = numpy_to_range_of_pairs(d1); - auto diag2 = numpy_to_range_of_pairs(d2); + auto diag1 = numpy_to_range_of_pairs(d1, make_point); + auto diag2 = numpy_to_range_of_pairs(d2, make_point); py::gil_scoped_release release; -- cgit v1.2.3 From 33b63b9d364bdb2d470a3eac878fe48e3a4e7da6 Mon Sep 17 00:00:00 2001 From: Marc Glisse Date: Sat, 10 Dec 2022 21:05:25 +0100 Subject: Clarify comment --- src/python/gudhi/bottleneck.cc | 2 +- src/python/gudhi/hera/bottleneck.cc | 2 +- src/python/gudhi/hera/wasserstein.cc | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) (limited to 'src/python/gudhi/hera/bottleneck.cc') diff --git a/src/python/gudhi/bottleneck.cc b/src/python/gudhi/bottleneck.cc index 1cf3283c..040e6d37 100644 --- a/src/python/gudhi/bottleneck.cc +++ b/src/python/gudhi/bottleneck.cc @@ -20,7 +20,7 @@ static auto make_point(double x, double y, py::ssize_t) { return std::pair(x, y) double bottleneck(Dgm d1, Dgm d2, std::optional epsilon) { double e = epsilon.value_or((std::numeric_limits::min)()); - // I *think* the call to request() has to be before releasing the GIL. + // I *think* the call to request() in numpy_to_range_of_pairs has to be before releasing the GIL. auto diag1 = numpy_to_range_of_pairs(d1, make_point); auto diag2 = numpy_to_range_of_pairs(d2, make_point); diff --git a/src/python/gudhi/hera/bottleneck.cc b/src/python/gudhi/hera/bottleneck.cc index 6b919b02..9826252c 100644 --- a/src/python/gudhi/hera/bottleneck.cc +++ b/src/python/gudhi/hera/bottleneck.cc @@ -23,7 +23,7 @@ static auto make_point(double x, double y, py::ssize_t) { return std::pair(x, y) double bottleneck_distance(Dgm d1, Dgm d2, double delta) { - // I *think* the call to request() has to be before releasing the GIL. + // I *think* the call to request() in numpy_to_range_of_pairs has to be before releasing the GIL. auto diag1 = numpy_to_range_of_pairs(d1, make_point); auto diag2 = numpy_to_range_of_pairs(d2, make_point); diff --git a/src/python/gudhi/hera/wasserstein.cc b/src/python/gudhi/hera/wasserstein.cc index 8c731530..77c1413a 100644 --- a/src/python/gudhi/hera/wasserstein.cc +++ b/src/python/gudhi/hera/wasserstein.cc @@ -27,7 +27,7 @@ py::object wasserstein_distance( double wasserstein_power, double internal_p, double delta, bool return_matching) { - // I *think* the call to request() has to be before releasing the GIL. + // I *think* the call to request() in numpy_to_range_of_pairs has to be before releasing the GIL. auto diag1 = numpy_to_range_of_pairs(d1, make_hera_point); auto diag2 = numpy_to_range_of_pairs(d2, make_hera_point); int n1 = boost::size(diag1); -- cgit v1.2.3