From f87a1026d5d1accbb6a558ef5d50f5c4c035e0d8 Mon Sep 17 00:00:00 2001 From: ROUVREAU Vincent Date: Tue, 3 Dec 2019 16:51:09 +0100 Subject: Fix #134 --- src/Alpha_complex/include/gudhi/Alpha_complex.h | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) (limited to 'src') diff --git a/src/Alpha_complex/include/gudhi/Alpha_complex.h b/src/Alpha_complex/include/gudhi/Alpha_complex.h index 6b4d8463..6f19cb6c 100644 --- a/src/Alpha_complex/include/gudhi/Alpha_complex.h +++ b/src/Alpha_complex/include/gudhi/Alpha_complex.h @@ -121,8 +121,8 @@ class Alpha_complex { // size_type type from CGAL. typedef typename Delaunay_triangulation::size_type size_type; - // Map type to switch from simplex tree vertex handle to CGAL vertex iterator. - typedef typename std::map< std::size_t, CGAL_vertex_iterator > Vector_vertex_iterator; + // Structure to switch from simplex tree vertex handle to CGAL vertex iterator. + typedef typename std::vector< CGAL_vertex_iterator > Vector_vertex_iterator; private: /** \brief Vertex iterator vector to switch from simplex tree vertex handle to CGAL vertex iterator. @@ -238,14 +238,16 @@ class Alpha_complex { hint = pos->full_cell(); } // -------------------------------------------------------------------------------------------- - // double map to retrieve simplex tree vertex handles from CGAL vertex iterator and vice versa + // structure to retrieve CGAL points from vertex handle - one vertex handle per point. + // Needs to be constructed before as vertex handles arrives in no particular order. + vertex_handle_to_iterator_.resize(point_cloud.size()); // Loop on triangulation vertices list for (CGAL_vertex_iterator vit = triangulation_->vertices_begin(); vit != triangulation_->vertices_end(); ++vit) { if (!triangulation_->is_infinite(*vit)) { #ifdef DEBUG_TRACES std::cout << "Vertex insertion - " << vit->data() << " -> " << vit->point() << std::endl; #endif // DEBUG_TRACES - vertex_handle_to_iterator_.emplace(vit->data(), vit); + vertex_handle_to_iterator_[vit->data()] = vit; } } // -------------------------------------------------------------------------------------------- -- cgit v1.2.3 From 10e7b9ff243260887c54c5ca49d92a27c281c68f Mon Sep 17 00:00:00 2001 From: ROUVREAU Vincent Date: Tue, 3 Dec 2019 17:45:14 +0100 Subject: Fix #118 - protect some bottleneck tests --- .../test/bottleneck_unit_test.cpp | 37 +++++++++++----------- src/common/include/gudhi/Unitary_tests_utils.h | 11 +++++++ 2 files changed, 30 insertions(+), 18 deletions(-) (limited to 'src') diff --git a/src/Bottleneck_distance/test/bottleneck_unit_test.cpp b/src/Bottleneck_distance/test/bottleneck_unit_test.cpp index 3fc6fc7b..2c520045 100644 --- a/src/Bottleneck_distance/test/bottleneck_unit_test.cpp +++ b/src/Bottleneck_distance/test/bottleneck_unit_test.cpp @@ -15,6 +15,7 @@ #include #include +#include using namespace Gudhi::persistence_diagram; @@ -59,24 +60,24 @@ BOOST_AUTO_TEST_CASE(persistence_graph) { BOOST_CHECK(g.size() == (n1 + n2)); // BOOST_CHECK((int) d.size() == (n1 + n2)*(n1 + n2) + n1 + n2 + 1); - BOOST_CHECK(std::count(d.begin(), d.end(), g.distance(0, 0)) > 0); - BOOST_CHECK(std::count(d.begin(), d.end(), g.distance(0, n1 - 1)) > 0); - BOOST_CHECK(std::count(d.begin(), d.end(), g.distance(0, n1)) > 0); - BOOST_CHECK(std::count(d.begin(), d.end(), g.distance(0, n2 - 1)) > 0); - BOOST_CHECK(std::count(d.begin(), d.end(), g.distance(0, n2)) > 0); - BOOST_CHECK(std::count(d.begin(), d.end(), g.distance(0, (n1 + n2) - 1)) > 0); - BOOST_CHECK(std::count(d.begin(), d.end(), g.distance(n1, 0)) > 0); - BOOST_CHECK(std::count(d.begin(), d.end(), g.distance(n1, n1 - 1)) > 0); - BOOST_CHECK(std::count(d.begin(), d.end(), g.distance(n1, n1)) > 0); - BOOST_CHECK(std::count(d.begin(), d.end(), g.distance(n1, n2 - 1)) > 0); - BOOST_CHECK(std::count(d.begin(), d.end(), g.distance(n1, n2)) > 0); - BOOST_CHECK(std::count(d.begin(), d.end(), g.distance(n1, (n1 + n2) - 1)) > 0); - BOOST_CHECK(std::count(d.begin(), d.end(), g.distance((n1 + n2) - 1, 0)) > 0); - BOOST_CHECK(std::count(d.begin(), d.end(), g.distance((n1 + n2) - 1, n1 - 1)) > 0); - BOOST_CHECK(std::count(d.begin(), d.end(), g.distance((n1 + n2) - 1, n1)) > 0); - BOOST_CHECK(std::count(d.begin(), d.end(), g.distance((n1 + n2) - 1, n2 - 1)) > 0); - BOOST_CHECK(std::count(d.begin(), d.end(), g.distance((n1 + n2) - 1, n2)) > 0); - BOOST_CHECK(std::count(d.begin(), d.end(), g.distance((n1 + n2) - 1, (n1 + n2) - 1)) > 0); + BOOST_CHECK(std::count(d.begin(), d.end(), GUDHI_PROTECT_FLOAT(g.distance(0, 0))) > 0); + BOOST_CHECK(std::count(d.begin(), d.end(), GUDHI_PROTECT_FLOAT(g.distance(0, n1 - 1))) > 0); + BOOST_CHECK(std::count(d.begin(), d.end(), GUDHI_PROTECT_FLOAT(g.distance(0, n1))) > 0); + BOOST_CHECK(std::count(d.begin(), d.end(), GUDHI_PROTECT_FLOAT(g.distance(0, n2 - 1))) > 0); + BOOST_CHECK(std::count(d.begin(), d.end(), GUDHI_PROTECT_FLOAT(g.distance(0, n2))) > 0); + BOOST_CHECK(std::count(d.begin(), d.end(), GUDHI_PROTECT_FLOAT(g.distance(0, (n1 + n2) - 1))) > 0); + BOOST_CHECK(std::count(d.begin(), d.end(), GUDHI_PROTECT_FLOAT(g.distance(n1, 0))) > 0); + BOOST_CHECK(std::count(d.begin(), d.end(), GUDHI_PROTECT_FLOAT(g.distance(n1, n1 - 1))) > 0); + BOOST_CHECK(std::count(d.begin(), d.end(), GUDHI_PROTECT_FLOAT(g.distance(n1, n1))) > 0); + BOOST_CHECK(std::count(d.begin(), d.end(), GUDHI_PROTECT_FLOAT(g.distance(n1, n2 - 1))) > 0); + BOOST_CHECK(std::count(d.begin(), d.end(), GUDHI_PROTECT_FLOAT(g.distance(n1, n2))) > 0); + BOOST_CHECK(std::count(d.begin(), d.end(), GUDHI_PROTECT_FLOAT(g.distance(n1, (n1 + n2) - 1))) > 0); + BOOST_CHECK(std::count(d.begin(), d.end(), GUDHI_PROTECT_FLOAT(g.distance((n1 + n2) - 1, 0))) > 0); + BOOST_CHECK(std::count(d.begin(), d.end(), GUDHI_PROTECT_FLOAT(g.distance((n1 + n2) - 1, n1 - 1))) > 0); + BOOST_CHECK(std::count(d.begin(), d.end(), GUDHI_PROTECT_FLOAT(g.distance((n1 + n2) - 1, n1))) > 0); + BOOST_CHECK(std::count(d.begin(), d.end(), GUDHI_PROTECT_FLOAT(g.distance((n1 + n2) - 1, n2 - 1))) > 0); + BOOST_CHECK(std::count(d.begin(), d.end(), GUDHI_PROTECT_FLOAT(g.distance((n1 + n2) - 1, n2))) > 0); + BOOST_CHECK(std::count(d.begin(), d.end(), GUDHI_PROTECT_FLOAT(g.distance((n1 + n2) - 1, (n1 + n2) - 1))) > 0); } BOOST_AUTO_TEST_CASE(neighbors_finder) { diff --git a/src/common/include/gudhi/Unitary_tests_utils.h b/src/common/include/gudhi/Unitary_tests_utils.h index 7d039304..9b86460a 100644 --- a/src/common/include/gudhi/Unitary_tests_utils.h +++ b/src/common/include/gudhi/Unitary_tests_utils.h @@ -26,4 +26,15 @@ void GUDHI_TEST_FLOAT_EQUALITY_CHECK(FloatingType a, FloatingType b, BOOST_CHECK(std::fabs(a - b) <= epsilon); } +// That's the usual x86 issue where a+b==a+b can return false (without any NaN) because one of them was stored in +// memory (and thus rounded to 64 bits) while the other is still in a register (80 bits). +template +FloatingType GUDHI_PROTECT_FLOAT(FloatingType value) { + volatile FloatingType protected_value = value; +#ifdef DEBUG_TRACES + std::cout << "GUDHI_PROTECT_FLOAT - " << protected_value << std::endl; +#endif + return protected_value; +} + #endif // UNITARY_TESTS_UTILS_H_ -- cgit v1.2.3 From 9fc45aafa4588b86ccd903b9173a8cdf48db68a1 Mon Sep 17 00:00:00 2001 From: ROUVREAU Vincent Date: Thu, 5 Dec 2019 16:01:45 +0100 Subject: Add MPFR dependency for python module. Use Epeck_d by default for Alpha complex. Add boolean exact version mechanism --- src/cmake/modules/FindMPFR.cmake | 51 ++++++++++++++++++ .../modules/GUDHI_third_party_libraries.cmake | 2 + src/python/CMakeLists.txt | 61 +++++++++++++--------- src/python/gudhi/alpha_complex.pyx | 13 +++-- src/python/include/Alpha_complex_interface.h | 9 ++-- 5 files changed, 102 insertions(+), 34 deletions(-) create mode 100644 src/cmake/modules/FindMPFR.cmake (limited to 'src') diff --git a/src/cmake/modules/FindMPFR.cmake b/src/cmake/modules/FindMPFR.cmake new file mode 100644 index 00000000..6c963272 --- /dev/null +++ b/src/cmake/modules/FindMPFR.cmake @@ -0,0 +1,51 @@ +# Try to find the MPFR libraries +# MPFR_FOUND - system has MPFR lib +# MPFR_INCLUDE_DIR - the MPFR include directory +# MPFR_LIBRARIES_DIR - Directory where the MPFR libraries are located +# MPFR_LIBRARIES - the MPFR libraries + +# TODO: support MacOSX + +include(FindPackageHandleStandardArgs) + +if(MPFR_INCLUDE_DIR) + set(MPFR_in_cache TRUE) +else() + set(MPFR_in_cache FALSE) +endif() +if(NOT MPFR_LIBRARIES) + set(MPFR_in_cache FALSE) +endif() + +# Is it already configured? +if (MPFR_in_cache) + set(MPFR_FOUND TRUE) +else() + find_path(MPFR_INCLUDE_DIR + NAMES mpfr.h + HINTS ENV MPFR_INC_DIR + ENV MPFR_DIR + ${CGAL_INSTALLATION_PACKAGE_DIR}/auxiliary/gmp/include + PATH_SUFFIXES include + DOC "The directory containing the MPFR header files" + ) + + find_library(MPFR_LIBRARIES NAMES mpfr libmpfr-4 libmpfr-1 + HINTS ENV MPFR_LIB_DIR + ENV MPFR_DIR + ${CGAL_INSTALLATION_PACKAGE_DIR}/auxiliary/gmp/lib + PATH_SUFFIXES lib + DOC "Path to the MPFR library" + ) + + if ( MPFR_LIBRARIES ) + get_filename_component(MPFR_LIBRARIES_DIR ${MPFR_LIBRARIES} PATH CACHE ) + endif() + + # Attempt to load a user-defined configuration for MPFR if couldn't be found + if ( NOT MPFR_INCLUDE_DIR OR NOT MPFR_LIBRARIES_DIR ) + include( MPFRConfig OPTIONAL ) + endif() + + find_package_handle_standard_args(MPFR "DEFAULT_MSG" MPFR_LIBRARIES MPFR_INCLUDE_DIR) +endif() diff --git a/src/cmake/modules/GUDHI_third_party_libraries.cmake b/src/cmake/modules/GUDHI_third_party_libraries.cmake index 24a34150..d8c7a428 100644 --- a/src/cmake/modules/GUDHI_third_party_libraries.cmake +++ b/src/cmake/modules/GUDHI_third_party_libraries.cmake @@ -6,6 +6,8 @@ if(NOT Boost_FOUND) message(FATAL_ERROR "NOTICE: This program requires Boost and will not be compiled.") endif(NOT Boost_FOUND) +find_package(MPFR) + find_package(GMP) if(GMP_FOUND) INCLUDE_DIRECTORIES(${GMP_INCLUDE_DIR}) diff --git a/src/python/CMakeLists.txt b/src/python/CMakeLists.txt index 9af85eac..13a8a909 100644 --- a/src/python/CMakeLists.txt +++ b/src/python/CMakeLists.txt @@ -114,9 +114,9 @@ if(PYTHONINTERP_FOUND) set(GUDHI_PYTHON_MODULES_TO_COMPILE "${GUDHI_PYTHON_MODULES_TO_COMPILE}'nerve_gic', ") endif () if (NOT CGAL_WITH_EIGEN3_VERSION VERSION_LESS 4.11.0) + set(GUDHI_PYTHON_MODULES_TO_COMPILE "${GUDHI_PYTHON_MODULES_TO_COMPILE}'alpha_complex', ") set(GUDHI_PYTHON_MODULES_TO_COMPILE "${GUDHI_PYTHON_MODULES_TO_COMPILE}'subsampling', ") set(GUDHI_PYTHON_MODULES_TO_COMPILE "${GUDHI_PYTHON_MODULES_TO_COMPILE}'tangential_complex', ") - set(GUDHI_PYTHON_MODULES_TO_COMPILE "${GUDHI_PYTHON_MODULES_TO_COMPILE}'alpha_complex', ") set(GUDHI_PYTHON_MODULES_TO_COMPILE "${GUDHI_PYTHON_MODULES_TO_COMPILE}'euclidean_witness_complex', ") set(GUDHI_PYTHON_MODULES_TO_COMPILE "${GUDHI_PYTHON_MODULES_TO_COMPILE}'euclidean_strong_witness_complex', ") endif () @@ -162,10 +162,17 @@ if(PYTHONINTERP_FOUND) set(GUDHI_PYTHON_EXTRA_COMPILE_ARGS "${GUDHI_PYTHON_EXTRA_COMPILE_ARGS}'-DCGAL_USE_GMPXX', ") add_GUDHI_PYTHON_lib("${GMPXX_LIBRARIES}") set(GUDHI_PYTHON_LIBRARY_DIRS "${GUDHI_PYTHON_LIBRARY_DIRS}'${GMPXX_LIBRARIES_DIR}', ") - message("** Add gmpxx ${GMPXX_LIBRARIES_DIR}") + message("** Add gmpxx ${GMPXX_LIBRARIES_DIR}") endif(GMPXX_FOUND) endif(GMP_FOUND) - endif(CGAL_FOUND) + if(MPFR_FOUND) + add_gudhi_debug_info("MPFR_LIBRARIES = ${MPFR_LIBRARIES}") + set(GUDHI_PYTHON_EXTRA_COMPILE_ARGS "${GUDHI_PYTHON_EXTRA_COMPILE_ARGS}'-DCGAL_USE_MPFR', ") + add_GUDHI_PYTHON_lib("${MPFR_LIBRARIES}") + set(GUDHI_PYTHON_LIBRARY_DIRS "${GUDHI_PYTHON_LIBRARY_DIRS}'${MPFR_LIBRARIES_DIR}', ") + message("** Add mpfr ${MPFR_LIBRARIES}") + endif(MPFR_FOUND) +endif(CGAL_FOUND) # Specific for Mac if (${CMAKE_SYSTEM_NAME} MATCHES "Darwin") @@ -223,13 +230,14 @@ if(PYTHONINTERP_FOUND) # Test examples if (NOT CGAL_WITH_EIGEN3_VERSION VERSION_LESS 4.11.0) - # Bottleneck and Alpha - add_test(NAME alpha_rips_persistence_bottleneck_distance_py_test - WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR} - COMMAND ${CMAKE_COMMAND} -E env "PYTHONPATH=${CMAKE_CURRENT_BINARY_DIR}" - ${PYTHON_EXECUTABLE} "${CMAKE_CURRENT_SOURCE_DIR}/example/alpha_rips_persistence_bottleneck_distance.py" - -f ${CMAKE_SOURCE_DIR}/data/points/tore3D_300.off -t 0.15 -d 3) - + if (MPFR_FOUND) + # Bottleneck and Alpha + add_test(NAME alpha_rips_persistence_bottleneck_distance_py_test + WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR} + COMMAND ${CMAKE_COMMAND} -E env "PYTHONPATH=${CMAKE_CURRENT_BINARY_DIR}" + ${PYTHON_EXECUTABLE} "${CMAKE_CURRENT_SOURCE_DIR}/example/alpha_rips_persistence_bottleneck_distance.py" + -f ${CMAKE_SOURCE_DIR}/data/points/tore3D_300.off -t 0.15 -d 3) + endif(MPFR_FOUND) if(MATPLOTLIB_FOUND AND NUMPY_FOUND) # Tangential add_test(NAME tangential_complex_plain_homology_from_off_file_example_py_test @@ -300,22 +308,23 @@ if(PYTHONINTERP_FOUND) endif (NOT CGAL_VERSION VERSION_LESS 4.11.0) if (NOT CGAL_WITH_EIGEN3_VERSION VERSION_LESS 4.11.0) - # Alpha - add_test(NAME alpha_complex_from_points_example_py_test - WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR} - COMMAND ${CMAKE_COMMAND} -E env "PYTHONPATH=${CMAKE_CURRENT_BINARY_DIR}" - ${PYTHON_EXECUTABLE} "${CMAKE_CURRENT_SOURCE_DIR}/example/alpha_complex_from_points_example.py") - - if(MATPLOTLIB_FOUND AND NUMPY_FOUND) - add_test(NAME alpha_complex_diagram_persistence_from_off_file_example_py_test - WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR} - COMMAND ${CMAKE_COMMAND} -E env "PYTHONPATH=${CMAKE_CURRENT_BINARY_DIR}" - ${PYTHON_EXECUTABLE} "${CMAKE_CURRENT_SOURCE_DIR}/example/alpha_complex_diagram_persistence_from_off_file_example.py" - --no-diagram -f ${CMAKE_SOURCE_DIR}/data/points/tore3D_300.off -a 0.6) - endif() - - add_gudhi_py_test(test_alpha_complex) - + if (MPFR_FOUND) + # Alpha + add_test(NAME alpha_complex_from_points_example_py_test + WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR} + COMMAND ${CMAKE_COMMAND} -E env "PYTHONPATH=${CMAKE_CURRENT_BINARY_DIR}" + ${PYTHON_EXECUTABLE} "${CMAKE_CURRENT_SOURCE_DIR}/example/alpha_complex_from_points_example.py") + + if(MATPLOTLIB_FOUND AND NUMPY_FOUND) + add_test(NAME alpha_complex_diagram_persistence_from_off_file_example_py_test + WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR} + COMMAND ${CMAKE_COMMAND} -E env "PYTHONPATH=${CMAKE_CURRENT_BINARY_DIR}" + ${PYTHON_EXECUTABLE} "${CMAKE_CURRENT_SOURCE_DIR}/example/alpha_complex_diagram_persistence_from_off_file_example.py" + --no-diagram -f ${CMAKE_SOURCE_DIR}/data/points/tore3D_300.off -a 0.6) + endif() + + add_gudhi_py_test(test_alpha_complex) + endif(MPFR_FOUND) endif (NOT CGAL_WITH_EIGEN3_VERSION VERSION_LESS 4.11.0) if (NOT CGAL_WITH_EIGEN3_VERSION VERSION_LESS 4.11.0) diff --git a/src/python/gudhi/alpha_complex.pyx b/src/python/gudhi/alpha_complex.pyx index 8f2c98d5..abac6e7b 100644 --- a/src/python/gudhi/alpha_complex.pyx +++ b/src/python/gudhi/alpha_complex.pyx @@ -28,7 +28,7 @@ cdef extern from "Alpha_complex_interface.h" namespace "Gudhi": # bool from_file is a workaround for cython to find the correct signature Alpha_complex_interface(string off_file, bool from_file) vector[double] get_point(int vertex) - void create_simplex_tree(Simplex_tree_interface_full_featured* simplex_tree, double max_alpha_square) + void create_simplex_tree(Simplex_tree_interface_full_featured* simplex_tree, double max_alpha_square, bool exact_version) # AlphaComplex python interface cdef class AlphaComplex: @@ -66,7 +66,7 @@ cdef class AlphaComplex: """ # The real cython constructor - def __cinit__(self, points=None, off_file=''): + def __cinit__(self, points = None, off_file = ''): if off_file: if os.path.isfile(off_file): self.thisptr = new Alpha_complex_interface(str.encode(off_file), True) @@ -99,17 +99,22 @@ cdef class AlphaComplex: cdef vector[double] point = self.thisptr.get_point(vertex) return point - def create_simplex_tree(self, max_alpha_square=float('inf')): + def create_simplex_tree(self, max_alpha_square = float('inf'), + exact_version = False): """ :param max_alpha_square: The maximum alpha square threshold the simplices shall not exceed. Default is set to infinity, and there is very little point using anything else since it does not save time. :type max_alpha_square: float + :param exact_version: Exact computation version. Default is false + which means Safe version is used. + :type exact_version: bool :returns: A simplex tree created from the Delaunay Triangulation. :rtype: SimplexTree """ stree = SimplexTree() cdef intptr_t stree_int_ptr=stree.thisptr - self.thisptr.create_simplex_tree(stree_int_ptr, max_alpha_square) + self.thisptr.create_simplex_tree(stree_int_ptr, + max_alpha_square, exact_version) return stree diff --git a/src/python/include/Alpha_complex_interface.h b/src/python/include/Alpha_complex_interface.h index 96353cc4..a7621f2b 100644 --- a/src/python/include/Alpha_complex_interface.h +++ b/src/python/include/Alpha_complex_interface.h @@ -13,6 +13,7 @@ #include #include +#include #include #include @@ -28,7 +29,7 @@ namespace Gudhi { namespace alpha_complex { class Alpha_complex_interface { - using Dynamic_kernel = CGAL::Epick_d< CGAL::Dynamic_dimension_tag >; + using Dynamic_kernel = CGAL::Epeck_d< CGAL::Dynamic_dimension_tag >; using Point_d = Dynamic_kernel::Point_d; public: @@ -51,7 +52,7 @@ class Alpha_complex_interface { std::vector vd; try { Point_d const& ph = alpha_complex_->get_point(vh); - for (auto coord = ph.cartesian_begin(); coord < ph.cartesian_end(); coord++) + for (auto coord = ph.cartesian_begin(); coord != ph.cartesian_end(); coord++) vd.push_back(CGAL::to_double(*coord)); } catch (std::out_of_range const&) { // std::out_of_range is thrown in case not found. Other exceptions must be re-thrown @@ -59,8 +60,8 @@ class Alpha_complex_interface { return vd; } - void create_simplex_tree(Simplex_tree_interface<>* simplex_tree, double max_alpha_square) { - alpha_complex_->create_complex(*simplex_tree, max_alpha_square); + void create_simplex_tree(Simplex_tree_interface<>* simplex_tree, double max_alpha_square, bool exact_version) { + alpha_complex_->create_complex(*simplex_tree, max_alpha_square, exact_version); simplex_tree->initialize_filtration(); } -- cgit v1.2.3 From 3757fedbf7ad387cdc06870a1db9532bbee4bab9 Mon Sep 17 00:00:00 2001 From: ROUVREAU Vincent Date: Thu, 5 Dec 2019 17:05:19 +0100 Subject: Add a test that fixes #107 --- src/python/test/test_alpha_complex.py | 35 +++++++++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+) (limited to 'src') diff --git a/src/python/test/test_alpha_complex.py b/src/python/test/test_alpha_complex.py index 24f8bf53..ab84daaa 100755 --- a/src/python/test/test_alpha_complex.py +++ b/src/python/test/test_alpha_complex.py @@ -1,4 +1,8 @@ from gudhi import AlphaComplex, SimplexTree +import math +import numpy as np +import itertools +import pytest """ This file is part of the Gudhi Library - https://gudhi.inria.fr/ - which is released under MIT. See file LICENSE or go to https://gudhi.inria.fr/licensing/ for full license details. @@ -88,3 +92,34 @@ def test_filtered_alpha(): ] assert simplex_tree.get_star([0]) == [([0], 0.0), ([0, 1], 0.25), ([0, 2], 0.25)] assert simplex_tree.get_cofaces([0], 1) == [([0, 1], 0.25), ([0, 2], 0.25)] + +def alpha_persistence_comparison(exact_version): + #generate periodic signal + time = np.arange(0, 10, 1) + signal = [math.sin(x) for x in time] + delta = math.pi + delayed = [math.sin(x + delta) for x in time] + + #construct embedding + embedding1 = [[signal[i], -signal[i]] for i in range(len(time))] + embedding2 = [[signal[i], delayed[i]] for i in range(len(time))] + + #build alpha complex and simplex tree + alpha_complex1 = AlphaComplex(points=embedding1) + simplex_tree1 = alpha_complex1.create_simplex_tree(exact_version = exact_version) + + alpha_complex2 = AlphaComplex(points=embedding2) + simplex_tree2 = alpha_complex2.create_simplex_tree(exact_version = exact_version) + + diag1 = simplex_tree1.persistence() + diag2 = simplex_tree2.persistence() + + for (first_p, second_p) in itertools.zip_longest(diag1, diag2): + assert first_p[0] == pytest.approx(second_p[0]) + assert first_p[1] == pytest.approx(second_p[1]) + +def test_exact_alpha_version(): + alpha_persistence_comparison(exact_version = True) + +def test_safe_alpha_version(): + alpha_persistence_comparison(exact_version = False) -- cgit v1.2.3 From 6142e146e92801cafe1438bf487f3ecafa502177 Mon Sep 17 00:00:00 2001 From: ROUVREAU Vincent Date: Thu, 5 Dec 2019 17:57:19 +0100 Subject: nicer doc presentation --- src/python/gudhi/alpha_complex.pyx | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/python/gudhi/alpha_complex.pyx b/src/python/gudhi/alpha_complex.pyx index abac6e7b..bfb9783a 100644 --- a/src/python/gudhi/alpha_complex.pyx +++ b/src/python/gudhi/alpha_complex.pyx @@ -107,8 +107,8 @@ cdef class AlphaComplex: there is very little point using anything else since it does not save time. :type max_alpha_square: float - :param exact_version: Exact computation version. Default is false - which means Safe version is used. + :param exact_version: :code:`EXACT` computation version if set. + Default is false which means :code:`SAFE` version is used. :type exact_version: bool :returns: A simplex tree created from the Delaunay Triangulation. :rtype: SimplexTree -- cgit v1.2.3 From 17cf8da254d88fa42cbe9e7bb486147def47c26b Mon Sep 17 00:00:00 2001 From: ROUVREAU Vincent Date: Fri, 6 Dec 2019 15:27:15 +0100 Subject: Modify boost tests to be more verbose and errors in colour. I kept coverage tests (was only used by Jenkins) and they still can be activated through an option --- src/Alpha_complex/test/CMakeLists.txt | 22 +++++++-------- src/Bitmap_cubical_complex/test/CMakeLists.txt | 5 ++-- src/Bottleneck_distance/test/CMakeLists.txt | 5 ++-- src/Cech_complex/test/CMakeLists.txt | 5 ++-- src/Nerve_GIC/test/CMakeLists.txt | 5 ++-- .../test/CMakeLists.txt | 33 ++++++---------------- src/Persistent_cohomology/test/CMakeLists.txt | 13 ++++----- src/Rips_complex/test/CMakeLists.txt | 5 ++-- src/Simplex_tree/test/CMakeLists.txt | 18 ++++-------- src/Skeleton_blocker/test/CMakeLists.txt | 11 +++----- src/Spatial_searching/test/CMakeLists.txt | 9 ++---- src/Subsampling/test/CMakeLists.txt | 14 ++++----- src/Tangential_complex/test/CMakeLists.txt | 6 ++-- src/Toplex_map/test/CMakeLists.txt | 8 ++---- src/Witness_complex/test/CMakeLists.txt | 8 ++---- src/cmake/modules/GUDHI_boost_test.cmake | 26 +++++++++++++++++ src/cmake/modules/GUDHI_compilation_flags.cmake | 2 ++ src/cmake/modules/GUDHI_test_coverage.cmake | 26 ----------------- src/common/test/CMakeLists.txt | 13 +++------ 19 files changed, 95 insertions(+), 139 deletions(-) create mode 100644 src/cmake/modules/GUDHI_boost_test.cmake delete mode 100644 src/cmake/modules/GUDHI_test_coverage.cmake (limited to 'src') diff --git a/src/Alpha_complex/test/CMakeLists.txt b/src/Alpha_complex/test/CMakeLists.txt index ad5b6314..0476c6d4 100644 --- a/src/Alpha_complex/test/CMakeLists.txt +++ b/src/Alpha_complex/test/CMakeLists.txt @@ -1,27 +1,27 @@ project(Alpha_complex_tests) -include(GUDHI_test_coverage) +include(GUDHI_boost_test) if (NOT CGAL_WITH_EIGEN3_VERSION VERSION_LESS 4.11.0) # Do not forget to copy test files in current binary dir file(COPY "${CMAKE_SOURCE_DIR}/data/points/alphacomplexdoc.off" DESTINATION ${CMAKE_CURRENT_BINARY_DIR}/) add_executable ( Alpha_complex_test_unit Alpha_complex_unit_test.cpp ) - target_link_libraries(Alpha_complex_test_unit ${CGAL_LIBRARY} ${Boost_UNIT_TEST_FRAMEWORK_LIBRARY}) + target_link_libraries(Alpha_complex_test_unit ${CGAL_LIBRARY}) if (TBB_FOUND) target_link_libraries(Alpha_complex_test_unit ${TBB_LIBRARIES}) endif() - gudhi_add_coverage_test(Alpha_complex_test_unit) + gudhi_add_boost_test(Alpha_complex_test_unit) add_executable ( Alpha_complex_3d_test_unit Alpha_complex_3d_unit_test.cpp ) - target_link_libraries(Alpha_complex_3d_test_unit ${CGAL_LIBRARY} ${Boost_UNIT_TEST_FRAMEWORK_LIBRARY}) + target_link_libraries(Alpha_complex_3d_test_unit ${CGAL_LIBRARY}) add_executable ( Weighted_alpha_complex_3d_test_unit Weighted_alpha_complex_3d_unit_test.cpp ) - target_link_libraries(Weighted_alpha_complex_3d_test_unit ${CGAL_LIBRARY} ${Boost_UNIT_TEST_FRAMEWORK_LIBRARY}) + target_link_libraries(Weighted_alpha_complex_3d_test_unit ${CGAL_LIBRARY}) add_executable ( Periodic_alpha_complex_3d_test_unit Periodic_alpha_complex_3d_unit_test.cpp ) - target_link_libraries(Periodic_alpha_complex_3d_test_unit ${CGAL_LIBRARY} ${Boost_UNIT_TEST_FRAMEWORK_LIBRARY}) + target_link_libraries(Periodic_alpha_complex_3d_test_unit ${CGAL_LIBRARY}) add_executable ( Weighted_periodic_alpha_complex_3d_test_unit Weighted_periodic_alpha_complex_3d_unit_test.cpp ) - target_link_libraries(Weighted_periodic_alpha_complex_3d_test_unit ${CGAL_LIBRARY} ${Boost_UNIT_TEST_FRAMEWORK_LIBRARY}) + target_link_libraries(Weighted_periodic_alpha_complex_3d_test_unit ${CGAL_LIBRARY}) if (TBB_FOUND) target_link_libraries(Alpha_complex_3d_test_unit ${TBB_LIBRARIES}) target_link_libraries(Weighted_alpha_complex_3d_test_unit ${TBB_LIBRARIES}) @@ -29,9 +29,9 @@ if (NOT CGAL_WITH_EIGEN3_VERSION VERSION_LESS 4.11.0) target_link_libraries(Weighted_periodic_alpha_complex_3d_test_unit ${TBB_LIBRARIES}) endif() - gudhi_add_coverage_test(Alpha_complex_3d_test_unit) - gudhi_add_coverage_test(Weighted_alpha_complex_3d_test_unit) - gudhi_add_coverage_test(Periodic_alpha_complex_3d_test_unit) - gudhi_add_coverage_test(Weighted_periodic_alpha_complex_3d_test_unit) + gudhi_add_boost_test(Alpha_complex_3d_test_unit) + gudhi_add_boost_test(Weighted_alpha_complex_3d_test_unit) + gudhi_add_boost_test(Periodic_alpha_complex_3d_test_unit) + gudhi_add_boost_test(Weighted_periodic_alpha_complex_3d_test_unit) endif (NOT CGAL_WITH_EIGEN3_VERSION VERSION_LESS 4.11.0) diff --git a/src/Bitmap_cubical_complex/test/CMakeLists.txt b/src/Bitmap_cubical_complex/test/CMakeLists.txt index d2f002a6..eb7eb6b5 100644 --- a/src/Bitmap_cubical_complex/test/CMakeLists.txt +++ b/src/Bitmap_cubical_complex/test/CMakeLists.txt @@ -1,14 +1,13 @@ project(Bitmap_cubical_complex_tests) -include(GUDHI_test_coverage) +include(GUDHI_boost_test) # Do not forget to copy test files in current binary dir file(COPY "${CMAKE_SOURCE_DIR}/data/bitmap/sinusoid.txt" DESTINATION ${CMAKE_CURRENT_BINARY_DIR}/) add_executable ( Bitmap_cubical_complex_test_unit Bitmap_test.cpp ) -target_link_libraries(Bitmap_cubical_complex_test_unit ${Boost_UNIT_TEST_FRAMEWORK_LIBRARY}) if (TBB_FOUND) target_link_libraries(Bitmap_cubical_complex_test_unit ${TBB_LIBRARIES}) endif() -gudhi_add_coverage_test(Bitmap_cubical_complex_test_unit) +gudhi_add_boost_test(Bitmap_cubical_complex_test_unit) diff --git a/src/Bottleneck_distance/test/CMakeLists.txt b/src/Bottleneck_distance/test/CMakeLists.txt index ec2d045f..3acd3d86 100644 --- a/src/Bottleneck_distance/test/CMakeLists.txt +++ b/src/Bottleneck_distance/test/CMakeLists.txt @@ -1,14 +1,13 @@ project(Bottleneck_distance_tests) if (NOT CGAL_VERSION VERSION_LESS 4.11.0) - include(GUDHI_test_coverage) + include(GUDHI_boost_test) add_executable ( Bottleneck_distance_test_unit bottleneck_unit_test.cpp ) - target_link_libraries(Bottleneck_distance_test_unit ${Boost_UNIT_TEST_FRAMEWORK_LIBRARY}) if (TBB_FOUND) target_link_libraries(Bottleneck_distance_test_unit ${TBB_LIBRARIES}) endif(TBB_FOUND) - gudhi_add_coverage_test(Bottleneck_distance_test_unit) + gudhi_add_boost_test(Bottleneck_distance_test_unit) endif (NOT CGAL_VERSION VERSION_LESS 4.11.0) diff --git a/src/Cech_complex/test/CMakeLists.txt b/src/Cech_complex/test/CMakeLists.txt index 8db51173..db510af3 100644 --- a/src/Cech_complex/test/CMakeLists.txt +++ b/src/Cech_complex/test/CMakeLists.txt @@ -1,10 +1,9 @@ cmake_minimum_required(VERSION 2.6) project(Cech_complex_tests) -include(GUDHI_test_coverage) +include(GUDHI_boost_test) add_executable ( Cech_complex_test_unit test_cech_complex.cpp ) -target_link_libraries(Cech_complex_test_unit ${Boost_UNIT_TEST_FRAMEWORK_LIBRARY}) if (TBB_FOUND) target_link_libraries(Cech_complex_test_unit ${TBB_LIBRARIES}) endif() @@ -12,4 +11,4 @@ endif() # Do not forget to copy test files in current binary dir file(COPY "${CMAKE_SOURCE_DIR}/data/points/alphacomplexdoc.off" DESTINATION ${CMAKE_CURRENT_BINARY_DIR}/) -gudhi_add_coverage_test(Cech_complex_test_unit) +gudhi_add_boost_test(Cech_complex_test_unit) diff --git a/src/Nerve_GIC/test/CMakeLists.txt b/src/Nerve_GIC/test/CMakeLists.txt index b89c18a2..567bf43f 100644 --- a/src/Nerve_GIC/test/CMakeLists.txt +++ b/src/Nerve_GIC/test/CMakeLists.txt @@ -1,16 +1,15 @@ project(Graph_induced_complex_tests) if (NOT CGAL_VERSION VERSION_LESS 4.11.0) - include(GUDHI_test_coverage) + include(GUDHI_boost_test) add_executable ( Nerve_GIC_test_unit test_GIC.cpp ) - target_link_libraries(Nerve_GIC_test_unit ${Boost_UNIT_TEST_FRAMEWORK_LIBRARY}) if (TBB_FOUND) target_link_libraries(Nerve_GIC_test_unit ${TBB_LIBRARIES}) endif() file(COPY data DESTINATION ${CMAKE_CURRENT_BINARY_DIR}/) - gudhi_add_coverage_test(Nerve_GIC_test_unit) + gudhi_add_boost_test(Nerve_GIC_test_unit) endif (NOT CGAL_VERSION VERSION_LESS 4.11.0) diff --git a/src/Persistence_representations/test/CMakeLists.txt b/src/Persistence_representations/test/CMakeLists.txt index a95880c9..92d68a63 100644 --- a/src/Persistence_representations/test/CMakeLists.txt +++ b/src/Persistence_representations/test/CMakeLists.txt @@ -1,51 +1,36 @@ project(Persistence_representations_test) -include(GUDHI_test_coverage) +include(GUDHI_boost_test) # copy data directory for tests purpose. file(COPY data DESTINATION ${CMAKE_CURRENT_BINARY_DIR}/) add_executable ( Persistence_intervals_test_unit persistence_intervals_test.cpp ) -target_link_libraries(Persistence_intervals_test_unit ${Boost_UNIT_TEST_FRAMEWORK_LIBRARY}) - -gudhi_add_coverage_test(Persistence_intervals_test_unit) +gudhi_add_boost_test(Persistence_intervals_test_unit) add_executable (Vector_representation_test_unit vector_representation_test.cpp ) -target_link_libraries(Vector_representation_test_unit ${Boost_UNIT_TEST_FRAMEWORK_LIBRARY}) - -gudhi_add_coverage_test(Vector_representation_test_unit) +gudhi_add_boost_test(Vector_representation_test_unit) add_executable (Persistence_lanscapes_test_unit persistence_lanscapes_test.cpp ) -target_link_libraries(Persistence_lanscapes_test_unit ${Boost_UNIT_TEST_FRAMEWORK_LIBRARY}) - -gudhi_add_coverage_test(Persistence_lanscapes_test_unit) +gudhi_add_boost_test(Persistence_lanscapes_test_unit) add_executable ( Persistence_lanscapes_on_grid_test_unit persistence_lanscapes_on_grid_test.cpp ) -target_link_libraries(Persistence_lanscapes_on_grid_test_unit ${Boost_UNIT_TEST_FRAMEWORK_LIBRARY}) - -gudhi_add_coverage_test(Persistence_lanscapes_on_grid_test_unit) +gudhi_add_boost_test(Persistence_lanscapes_on_grid_test_unit) add_executable (Persistence_heat_maps_test_unit persistence_heat_maps_test.cpp ) -target_link_libraries(Persistence_heat_maps_test_unit ${Boost_UNIT_TEST_FRAMEWORK_LIBRARY}) - -gudhi_add_coverage_test(Persistence_heat_maps_test_unit) +gudhi_add_boost_test(Persistence_heat_maps_test_unit) add_executable ( Read_persistence_from_file_test_unit read_persistence_from_file_test.cpp ) -target_link_libraries(Read_persistence_from_file_test_unit ${Boost_UNIT_TEST_FRAMEWORK_LIBRARY}) - -gudhi_add_coverage_test(Read_persistence_from_file_test_unit) +gudhi_add_boost_test(Read_persistence_from_file_test_unit) add_executable ( kernels_unit kernels.cpp ) -target_link_libraries(kernels_unit ${Boost_UNIT_TEST_FRAMEWORK_LIBRARY}) - -gudhi_add_coverage_test(kernels_unit) +gudhi_add_boost_test(kernels_unit) if (NOT CGAL_WITH_EIGEN3_VERSION VERSION_LESS 4.11.0) add_executable (Persistence_intervals_with_distances_test_unit persistence_intervals_with_distances_test.cpp ) - target_link_libraries(Persistence_intervals_with_distances_test_unit ${Boost_UNIT_TEST_FRAMEWORK_LIBRARY}) if (TBB_FOUND) target_link_libraries(Persistence_intervals_with_distances_test_unit ${TBB_LIBRARIES}) endif(TBB_FOUND) - gudhi_add_coverage_test(Persistence_intervals_with_distances_test_unit) + gudhi_add_boost_test(Persistence_intervals_with_distances_test_unit) endif (NOT CGAL_WITH_EIGEN3_VERSION VERSION_LESS 4.11.0) diff --git a/src/Persistent_cohomology/test/CMakeLists.txt b/src/Persistent_cohomology/test/CMakeLists.txt index f8baf861..64669c4e 100644 --- a/src/Persistent_cohomology/test/CMakeLists.txt +++ b/src/Persistent_cohomology/test/CMakeLists.txt @@ -1,11 +1,9 @@ project(Persistent_cohomology_tests) -include(GUDHI_test_coverage) +include(GUDHI_boost_test) add_executable ( Persistent_cohomology_test_unit persistent_cohomology_unit_test.cpp ) -target_link_libraries(Persistent_cohomology_test_unit ${Boost_UNIT_TEST_FRAMEWORK_LIBRARY}) add_executable ( Persistent_cohomology_test_betti_numbers betti_numbers_unit_test.cpp ) -target_link_libraries(Persistent_cohomology_test_betti_numbers ${Boost_UNIT_TEST_FRAMEWORK_LIBRARY}) if (TBB_FOUND) target_link_libraries(Persistent_cohomology_test_unit ${TBB_LIBRARIES}) target_link_libraries(Persistent_cohomology_test_betti_numbers ${TBB_LIBRARIES}) @@ -16,13 +14,12 @@ file(COPY "${CMAKE_SOURCE_DIR}/src/Persistent_cohomology/test/simplex_tree_file_ DESTINATION ${CMAKE_CURRENT_BINARY_DIR}/) # Unitary tests -gudhi_add_coverage_test(Persistent_cohomology_test_unit) -gudhi_add_coverage_test(Persistent_cohomology_test_betti_numbers) +gudhi_add_boost_test(Persistent_cohomology_test_unit) +gudhi_add_boost_test(Persistent_cohomology_test_betti_numbers) if(GMPXX_FOUND AND GMP_FOUND) add_executable ( Persistent_cohomology_test_unit_multi_field persistent_cohomology_unit_test_multi_field.cpp ) - target_link_libraries(Persistent_cohomology_test_unit_multi_field - ${Boost_UNIT_TEST_FRAMEWORK_LIBRARY} ${GMPXX_LIBRARIES} ${GMP_LIBRARIES}) + target_link_libraries(Persistent_cohomology_test_unit_multi_field ${GMPXX_LIBRARIES} ${GMP_LIBRARIES}) if (TBB_FOUND) target_link_libraries(Persistent_cohomology_test_unit_multi_field ${TBB_LIBRARIES}) endif(TBB_FOUND) @@ -31,7 +28,7 @@ if(GMPXX_FOUND AND GMP_FOUND) file(COPY "${CMAKE_SOURCE_DIR}/src/Persistent_cohomology/test/simplex_tree_file_for_multi_field_unit_test.txt" DESTINATION ${CMAKE_CURRENT_BINARY_DIR}/) # Unitary tests - gudhi_add_coverage_test(Persistent_cohomology_test_unit_multi_field) + gudhi_add_boost_test(Persistent_cohomology_test_unit_multi_field) endif(GMPXX_FOUND AND GMP_FOUND) diff --git a/src/Rips_complex/test/CMakeLists.txt b/src/Rips_complex/test/CMakeLists.txt index 745d953c..b359584e 100644 --- a/src/Rips_complex/test/CMakeLists.txt +++ b/src/Rips_complex/test/CMakeLists.txt @@ -1,9 +1,8 @@ project(Rips_complex_tests) -include(GUDHI_test_coverage) +include(GUDHI_boost_test) add_executable ( Rips_complex_test_unit test_rips_complex.cpp ) -target_link_libraries(Rips_complex_test_unit ${Boost_UNIT_TEST_FRAMEWORK_LIBRARY}) if (TBB_FOUND) target_link_libraries(Rips_complex_test_unit ${TBB_LIBRARIES}) endif() @@ -12,4 +11,4 @@ endif() file(COPY "${CMAKE_SOURCE_DIR}/data/points/alphacomplexdoc.off" DESTINATION ${CMAKE_CURRENT_BINARY_DIR}/) file(COPY "${CMAKE_SOURCE_DIR}/data/distance_matrix/full_square_distance_matrix.csv" DESTINATION ${CMAKE_CURRENT_BINARY_DIR}/) -gudhi_add_coverage_test(Rips_complex_test_unit) +gudhi_add_boost_test(Rips_complex_test_unit) diff --git a/src/Simplex_tree/test/CMakeLists.txt b/src/Simplex_tree/test/CMakeLists.txt index 5bea3938..8b9163f5 100644 --- a/src/Simplex_tree/test/CMakeLists.txt +++ b/src/Simplex_tree/test/CMakeLists.txt @@ -1,38 +1,30 @@ project(Simplex_tree_tests) -include(GUDHI_test_coverage) +include(GUDHI_boost_test) # Do not forget to copy test files in current binary dir file(COPY "simplex_tree_for_unit_test.txt" DESTINATION ${CMAKE_CURRENT_BINARY_DIR}/) add_executable ( Simplex_tree_test_unit simplex_tree_unit_test.cpp ) -target_link_libraries(Simplex_tree_test_unit ${Boost_UNIT_TEST_FRAMEWORK_LIBRARY}) if (TBB_FOUND) target_link_libraries(Simplex_tree_test_unit ${TBB_LIBRARIES}) endif() - -gudhi_add_coverage_test(Simplex_tree_test_unit) +gudhi_add_boost_test(Simplex_tree_test_unit) add_executable ( Simplex_tree_remove_test_unit simplex_tree_remove_unit_test.cpp ) -target_link_libraries(Simplex_tree_remove_test_unit ${Boost_UNIT_TEST_FRAMEWORK_LIBRARY}) if (TBB_FOUND) target_link_libraries(Simplex_tree_remove_test_unit ${TBB_LIBRARIES}) endif() - -gudhi_add_coverage_test(Simplex_tree_remove_test_unit) +gudhi_add_boost_test(Simplex_tree_remove_test_unit) add_executable ( Simplex_tree_iostream_operator_test_unit simplex_tree_iostream_operator_unit_test.cpp ) -target_link_libraries(Simplex_tree_iostream_operator_test_unit ${Boost_UNIT_TEST_FRAMEWORK_LIBRARY}) if (TBB_FOUND) target_link_libraries(Simplex_tree_iostream_operator_test_unit ${TBB_LIBRARIES}) endif() - -gudhi_add_coverage_test(Simplex_tree_iostream_operator_test_unit) +gudhi_add_boost_test(Simplex_tree_iostream_operator_test_unit) add_executable ( Simplex_tree_ctor_and_move_test_unit simplex_tree_ctor_and_move_unit_test.cpp ) -target_link_libraries(Simplex_tree_ctor_and_move_test_unit ${Boost_UNIT_TEST_FRAMEWORK_LIBRARY}) if (TBB_FOUND) target_link_libraries(Simplex_tree_ctor_and_move_test_unit ${TBB_LIBRARIES}) endif() - -gudhi_add_coverage_test(Simplex_tree_ctor_and_move_test_unit) +gudhi_add_boost_test(Simplex_tree_ctor_and_move_test_unit) diff --git a/src/Skeleton_blocker/test/CMakeLists.txt b/src/Skeleton_blocker/test/CMakeLists.txt index 19c65871..24b6c11e 100644 --- a/src/Skeleton_blocker/test/CMakeLists.txt +++ b/src/Skeleton_blocker/test/CMakeLists.txt @@ -1,17 +1,14 @@ project(Skeleton_blocker_tests) -include(GUDHI_test_coverage) +include(GUDHI_boost_test) add_executable ( Skeleton_blocker_test_unit test_skeleton_blocker_complex.cpp ) -target_link_libraries(Skeleton_blocker_test_unit ${Boost_UNIT_TEST_FRAMEWORK_LIBRARY}) add_executable ( Skeleton_blocker_test_geometric_complex test_skeleton_blocker_geometric_complex.cpp ) -target_link_libraries(Skeleton_blocker_test_geometric_complex ${Boost_UNIT_TEST_FRAMEWORK_LIBRARY}) add_executable ( Skeleton_blocker_test_simplifiable test_skeleton_blocker_simplifiable.cpp ) -target_link_libraries(Skeleton_blocker_test_simplifiable ${Boost_UNIT_TEST_FRAMEWORK_LIBRARY}) # Do not forget to copy test files in current binary dir file(COPY "test2.off" DESTINATION ${CMAKE_CURRENT_BINARY_DIR}/) -gudhi_add_coverage_test(Skeleton_blocker_test_unit) -gudhi_add_coverage_test(Skeleton_blocker_test_geometric_complex) -gudhi_add_coverage_test(Skeleton_blocker_test_simplifiable) +gudhi_add_boost_test(Skeleton_blocker_test_unit) +gudhi_add_boost_test(Skeleton_blocker_test_geometric_complex) +gudhi_add_boost_test(Skeleton_blocker_test_simplifiable) diff --git a/src/Spatial_searching/test/CMakeLists.txt b/src/Spatial_searching/test/CMakeLists.txt index 18f7c6b8..a6c23951 100644 --- a/src/Spatial_searching/test/CMakeLists.txt +++ b/src/Spatial_searching/test/CMakeLists.txt @@ -1,11 +1,8 @@ project(Spatial_searching_tests) if(NOT CGAL_WITH_EIGEN3_VERSION VERSION_LESS 4.11.0) - include(GUDHI_test_coverage) - + include(GUDHI_boost_test) add_executable( Spatial_searching_test_Kd_tree_search test_Kd_tree_search.cpp ) - target_link_libraries(Spatial_searching_test_Kd_tree_search - ${CGAL_LIBRARY} ${Boost_UNIT_TEST_FRAMEWORK_LIBRARY}) - - gudhi_add_coverage_test(Spatial_searching_test_Kd_tree_search) + target_link_libraries(Spatial_searching_test_Kd_tree_search ${CGAL_LIBRARY}) + gudhi_add_boost_test(Spatial_searching_test_Kd_tree_search) endif () diff --git a/src/Subsampling/test/CMakeLists.txt b/src/Subsampling/test/CMakeLists.txt index cf54788e..354021c1 100644 --- a/src/Subsampling/test/CMakeLists.txt +++ b/src/Subsampling/test/CMakeLists.txt @@ -1,18 +1,18 @@ project(Subsampling_tests) if(NOT CGAL_WITH_EIGEN3_VERSION VERSION_LESS 4.11.0) - include(GUDHI_test_coverage) + include(GUDHI_boost_test) add_executable( Subsampling_test_pick_n_random_points test_pick_n_random_points.cpp ) - target_link_libraries(Subsampling_test_pick_n_random_points ${CGAL_LIBRARY} ${Boost_UNIT_TEST_FRAMEWORK_LIBRARY}) + target_link_libraries(Subsampling_test_pick_n_random_points ${CGAL_LIBRARY}) add_executable( Subsampling_test_choose_n_farthest_points test_choose_n_farthest_points.cpp ) - target_link_libraries(Subsampling_test_choose_n_farthest_points ${CGAL_LIBRARY} ${Boost_UNIT_TEST_FRAMEWORK_LIBRARY}) + target_link_libraries(Subsampling_test_choose_n_farthest_points ${CGAL_LIBRARY}) add_executable(Subsampling_test_sparsify_point_set test_sparsify_point_set.cpp) - target_link_libraries(Subsampling_test_sparsify_point_set ${CGAL_LIBRARY} ${Boost_UNIT_TEST_FRAMEWORK_LIBRARY}) + target_link_libraries(Subsampling_test_sparsify_point_set ${CGAL_LIBRARY}) - gudhi_add_coverage_test(Subsampling_test_pick_n_random_points) - gudhi_add_coverage_test(Subsampling_test_choose_n_farthest_points) - gudhi_add_coverage_test(Subsampling_test_sparsify_point_set) + gudhi_add_boost_test(Subsampling_test_pick_n_random_points) + gudhi_add_boost_test(Subsampling_test_choose_n_farthest_points) + gudhi_add_boost_test(Subsampling_test_sparsify_point_set) endif(NOT CGAL_WITH_EIGEN3_VERSION VERSION_LESS 4.11.0) diff --git a/src/Tangential_complex/test/CMakeLists.txt b/src/Tangential_complex/test/CMakeLists.txt index ae17a286..2207d67c 100644 --- a/src/Tangential_complex/test/CMakeLists.txt +++ b/src/Tangential_complex/test/CMakeLists.txt @@ -1,13 +1,13 @@ project(Tangential_complex_tests) if(NOT CGAL_WITH_EIGEN3_VERSION VERSION_LESS 4.11.0) - include(GUDHI_test_coverage) + include(GUDHI_boost_test) add_executable( Tangential_complex_test_TC test_tangential_complex.cpp ) - target_link_libraries(Tangential_complex_test_TC ${CGAL_LIBRARY} ${Boost_UNIT_TEST_FRAMEWORK_LIBRARY}) + target_link_libraries(Tangential_complex_test_TC ${CGAL_LIBRARY}) if (TBB_FOUND) target_link_libraries(Tangential_complex_test_TC ${TBB_LIBRARIES}) endif() - gudhi_add_coverage_test(Tangential_complex_test_TC) + gudhi_add_boost_test(Tangential_complex_test_TC) endif(NOT CGAL_WITH_EIGEN3_VERSION VERSION_LESS 4.11.0) diff --git a/src/Toplex_map/test/CMakeLists.txt b/src/Toplex_map/test/CMakeLists.txt index 59517db5..2997584d 100644 --- a/src/Toplex_map/test/CMakeLists.txt +++ b/src/Toplex_map/test/CMakeLists.txt @@ -1,11 +1,9 @@ project(Toplex_map_tests) -include(GUDHI_test_coverage) +include(GUDHI_boost_test) add_executable( Toplex_map_unit_test toplex_map_unit_test.cpp ) -target_link_libraries(Toplex_map_unit_test ${Boost_UNIT_TEST_FRAMEWORK_LIBRARY}) -gudhi_add_coverage_test(Toplex_map_unit_test) +gudhi_add_boost_test(Toplex_map_unit_test) add_executable( Lazy_toplex_map_unit_test lazy_toplex_map_unit_test.cpp ) -target_link_libraries(Lazy_toplex_map_unit_test ${Boost_UNIT_TEST_FRAMEWORK_LIBRARY}) -gudhi_add_coverage_test(Lazy_toplex_map_unit_test) +gudhi_add_boost_test(Lazy_toplex_map_unit_test) diff --git a/src/Witness_complex/test/CMakeLists.txt b/src/Witness_complex/test/CMakeLists.txt index 96188e46..690933aa 100644 --- a/src/Witness_complex/test/CMakeLists.txt +++ b/src/Witness_complex/test/CMakeLists.txt @@ -1,22 +1,20 @@ project(Witness_complex_tests) -include(GUDHI_test_coverage) +include(GUDHI_boost_test) add_executable ( Witness_complex_test_simple_witness_complex test_simple_witness_complex.cpp ) -target_link_libraries(Witness_complex_test_simple_witness_complex ${Boost_UNIT_TEST_FRAMEWORK_LIBRARY}) if (TBB_FOUND) target_link_libraries(Witness_complex_test_simple_witness_complex ${TBB_LIBRARIES}) endif(TBB_FOUND) -gudhi_add_coverage_test(Witness_complex_test_simple_witness_complex) +gudhi_add_boost_test(Witness_complex_test_simple_witness_complex) # CGAL and Eigen3 are required for Euclidean version of Witness if(NOT CGAL_WITH_EIGEN3_VERSION VERSION_LESS 4.11.0) add_executable ( Witness_complex_test_euclidean_simple_witness_complex test_euclidean_simple_witness_complex.cpp ) - target_link_libraries(Witness_complex_test_euclidean_simple_witness_complex ${Boost_UNIT_TEST_FRAMEWORK_LIBRARY}) if (TBB_FOUND) target_link_libraries(Witness_complex_test_euclidean_simple_witness_complex ${TBB_LIBRARIES}) endif(TBB_FOUND) - gudhi_add_coverage_test(Witness_complex_test_euclidean_simple_witness_complex) + gudhi_add_boost_test(Witness_complex_test_euclidean_simple_witness_complex) endif(NOT CGAL_WITH_EIGEN3_VERSION VERSION_LESS 4.11.0) diff --git a/src/cmake/modules/GUDHI_boost_test.cmake b/src/cmake/modules/GUDHI_boost_test.cmake new file mode 100644 index 00000000..c3b29883 --- /dev/null +++ b/src/cmake/modules/GUDHI_boost_test.cmake @@ -0,0 +1,26 @@ +if (WITH_GUDHI_BOOST_TEST_COVERAGE) + # Make CTest output XML coverage report - WITH_GUDHI_BOOST_TEST_COVERAGE must be set - default is OFF + if (GCOVR_PATH) + # for gcovr to make coverage reports - Corbera Jenkins plugin + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fprofile-arcs -ftest-coverage") + endif() + if (GPROF_PATH) + # for gprof to make coverage reports - Jenkins + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -pg") + endif() + set(GUDHI_UT_LOG_FORMAT "--log_format=XML") + set(GUDHI_UT_LOG_SINK "--log_sink=${CMAKE_BINARY_DIR}/${unitary_test}_UT.xml") + set(GUDHI_UT_LOG_LEVEL "--log_level=test_suite") + set(GUDHI_UT_REPORT_LEVEL "--report_level=no") +else (WITH_GUDHI_BOOST_TEST_COVERAGE) + # Make CTest more verbose and color output + set(GUDHI_UT_LOG_LEVEL "--color_output") + set(GUDHI_UT_REPORT_LEVEL "--report_level=detailed") +endif(WITH_GUDHI_BOOST_TEST_COVERAGE) + +function(gudhi_add_boost_test unitary_test) + target_link_libraries(${unitary_test} ${Boost_UNIT_TEST_FRAMEWORK_LIBRARY}) + add_test(NAME ${unitary_test} COMMAND $ + ${GUDHI_UT_LOG_FORMAT} ${GUDHI_UT_LOG_SINK} + ${GUDHI_UT_LOG_LEVEL} ${GUDHI_UT_REPORT_LEVEL}) +endfunction() diff --git a/src/cmake/modules/GUDHI_compilation_flags.cmake b/src/cmake/modules/GUDHI_compilation_flags.cmake index 6cd2614d..34c2e065 100644 --- a/src/cmake/modules/GUDHI_compilation_flags.cmake +++ b/src/cmake/modules/GUDHI_compilation_flags.cmake @@ -73,3 +73,5 @@ if(CMAKE_BUILD_TYPE MATCHES Debug) else() message("++ Release compilation flags are: ${CMAKE_CXX_FLAGS} ${CMAKE_CXX_FLAGS_RELEASE}") endif() + +option(WITH_GUDHI_BOOST_TEST_COVERAGE "Report xml coverage files on boost tests" OFF) diff --git a/src/cmake/modules/GUDHI_test_coverage.cmake b/src/cmake/modules/GUDHI_test_coverage.cmake deleted file mode 100644 index bea5b2d6..00000000 --- a/src/cmake/modules/GUDHI_test_coverage.cmake +++ /dev/null @@ -1,26 +0,0 @@ - -if (GCOVR_PATH) - # for gcovr to make coverage reports - Corbera Jenkins plugin - set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fprofile-arcs -ftest-coverage") -endif() -if (GPROF_PATH) - # for gprof to make coverage reports - Jenkins - set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -pg") -endif() - -if (DEBUG_TRACES) - # Make CTest more verbose with DEBUG_TRACES - no XML output - set(GUDHI_UT_LOG_LEVEL "--log_level=all") - set(GUDHI_UT_REPORT_LEVEL "--report_level=detailed") -else() - set(GUDHI_UT_LOG_FORMAT "--log_format=XML") - set(GUDHI_UT_LOG_SINK "--log_sink=${CMAKE_BINARY_DIR}/${unitary_test}_UT.xml") - set(GUDHI_UT_LOG_LEVEL "--log_level=test_suite") - set(GUDHI_UT_REPORT_LEVEL "--report_level=no") -endif() - -function(gudhi_add_coverage_test unitary_test) - add_test(NAME ${unitary_test} COMMAND $ - ${GUDHI_UT_LOG_FORMAT} ${GUDHI_UT_LOG_SINK} - ${GUDHI_UT_LOG_LEVEL} ${GUDHI_UT_REPORT_LEVEL}) -endfunction() diff --git a/src/common/test/CMakeLists.txt b/src/common/test/CMakeLists.txt index 0b49fa1e..34de7398 100644 --- a/src/common/test/CMakeLists.txt +++ b/src/common/test/CMakeLists.txt @@ -1,15 +1,10 @@ project(Common_tests) -include(GUDHI_test_coverage) +include(GUDHI_boost_test) add_executable ( Common_test_points_off_reader test_points_off_reader.cpp ) -target_link_libraries(Common_test_points_off_reader ${Boost_UNIT_TEST_FRAMEWORK_LIBRARY}) - add_executable ( Common_test_distance_matrix_reader test_distance_matrix_reader.cpp ) -target_link_libraries(Common_test_distance_matrix_reader ${Boost_UNIT_TEST_FRAMEWORK_LIBRARY}) - add_executable ( Common_test_persistence_intervals_reader test_persistence_intervals_reader.cpp ) -target_link_libraries(Common_test_persistence_intervals_reader ${Boost_UNIT_TEST_FRAMEWORK_LIBRARY}) # Do not forget to copy test files in current binary dir file(COPY "${CMAKE_SOURCE_DIR}/data/points/alphacomplexdoc.off" DESTINATION ${CMAKE_CURRENT_BINARY_DIR}/) @@ -19,6 +14,6 @@ file(COPY "${CMAKE_SOURCE_DIR}/src/common/test/persistence_intervals_with_dimens file(COPY "${CMAKE_SOURCE_DIR}/src/common/test/persistence_intervals_with_field.pers" DESTINATION ${CMAKE_CURRENT_BINARY_DIR}/) file(COPY "${CMAKE_SOURCE_DIR}/src/common/test/persistence_intervals_without_dimension.pers" DESTINATION ${CMAKE_CURRENT_BINARY_DIR}/) -gudhi_add_coverage_test(Common_test_points_off_reader) -gudhi_add_coverage_test(Common_test_distance_matrix_reader) -gudhi_add_coverage_test(Common_test_persistence_intervals_reader) +gudhi_add_boost_test(Common_test_points_off_reader) +gudhi_add_boost_test(Common_test_distance_matrix_reader) +gudhi_add_boost_test(Common_test_persistence_intervals_reader) -- cgit v1.2.3 From ce58cc97866605fe64df479e96d455e90f56f8e2 Mon Sep 17 00:00:00 2001 From: MathieuCarriere Date: Sun, 8 Dec 2019 21:22:09 -0500 Subject: fixed useless coordinates in Landscape if min and max are computed from data --- src/python/doc/representations.rst | 25 ++++++++++++++++++++-- .../diagram_vectorizations_distances_kernels.py | 6 +++--- src/python/gudhi/representations/vector_methods.py | 12 ++++++++--- 3 files changed, 35 insertions(+), 8 deletions(-) (limited to 'src') diff --git a/src/python/doc/representations.rst b/src/python/doc/representations.rst index b3131a25..b338f7f0 100644 --- a/src/python/doc/representations.rst +++ b/src/python/doc/representations.rst @@ -8,9 +8,9 @@ Representations manual .. include:: representations_sum.inc -This module, originally named sklearn_tda, aims at bridging the gap between persistence diagrams and machine learning tools, in particular scikit-learn. It provides tools, using the scikit-learn standard interface, to compute distances and kernels on diagrams, and to convert diagrams into vectors. +This module, originally available at https://github.com/MathieuCarriere/sklearn-tda and named sklearn_tda, aims at bridging the gap between persistence diagrams and machine learning, by providing implementations of most of the vector representations for persistence diagrams in the literature, in a scikit-learn format. More specifically, it provides tools, using the scikit-learn standard interface, to compute distances and kernels on persistence diagrams, and to convert these diagrams into vectors in Euclidean space. -A diagram is represented as a numpy array of shape (n,2), as can be obtained from :func:`~gudhi.SimplexTree.persistence_intervals_in_dimension` for instance. Points at infinity are represented as a numpy array of shape (n,1), storing only the birth time. +A diagram is represented as a numpy array of shape (n,2), as can be obtained from `SimplexTree.persistence_intervals_in_dimension` for instance. Points at infinity are represented as a numpy array of shape (n,1), storing only the birth time. A small example is provided @@ -46,3 +46,24 @@ Metrics :members: :special-members: :show-inheritance: + +Basic example +------------- + +This example computes the first two Landscapes associated to a persistence diagram with four points. The landscapes are evaluated on ten samples, leading to two vectors with ten coordinates each, that are eventually concatenated in order to produce a single vector representation. + +.. testcode:: + + import numpy as np + from gudhi.representations import Landscape + # A single diagram with 4 points + D = np.array([[0.,4.],[1.,2.],[3.,8.],[6.,8.]]) + diags = [D] + l=Landscape(num_landscapes=2,resolution=10).fit_transform(diags) + print(l) + +The output is: + +.. testoutput:: + + [[0. 1.25707872 2.51415744 1.88561808 0.7856742 2.04275292 3.29983165 2.51415744 1.25707872 0. 0. 0. 0.31426968 0. 0.62853936 0. 0. 0.31426968 1.25707872 0. ]] diff --git a/src/python/example/diagram_vectorizations_distances_kernels.py b/src/python/example/diagram_vectorizations_distances_kernels.py index 119072eb..f777984c 100755 --- a/src/python/example/diagram_vectorizations_distances_kernels.py +++ b/src/python/example/diagram_vectorizations_distances_kernels.py @@ -26,9 +26,9 @@ plt.show() LS = Landscape(resolution=1000) L = LS.fit_transform(diags) -plt.plot(L[0][:1000]) -plt.plot(L[0][1000:2000]) -plt.plot(L[0][2000:3000]) +plt.plot(L[0][:999]) +plt.plot(L[0][999:2*999]) +plt.plot(L[0][2*999:3*999]) plt.title("Landscape") plt.show() diff --git a/src/python/gudhi/representations/vector_methods.py b/src/python/gudhi/representations/vector_methods.py index 61c4fb84..083551a4 100644 --- a/src/python/gudhi/representations/vector_methods.py +++ b/src/python/gudhi/representations/vector_methods.py @@ -104,10 +104,11 @@ class Landscape(BaseEstimator, TransformerMixin): X (list of n x 2 numpy arrays): input persistence diagrams. y (n x 1 array): persistence diagram labels (unused). """ + self.nan_in_range = np.isnan(np.array(self.sample_range)) if np.isnan(np.array(self.sample_range)).any(): pre = DiagramScaler(use=True, scalers=[([0], MinMaxScaler()), ([1], MinMaxScaler())]).fit(X,y) [mx,my],[Mx,My] = [pre.scalers[0][1].data_min_[0], pre.scalers[1][1].data_min_[0]], [pre.scalers[0][1].data_max_[0], pre.scalers[1][1].data_max_[0]] - self.sample_range = np.where(np.isnan(np.array(self.sample_range)), np.array([mx, My]), np.array(self.sample_range)) + self.sample_range = np.where(self.nan_in_range, np.array([mx, My]), np.array(self.sample_range)) return self def transform(self, X): @@ -121,7 +122,7 @@ class Landscape(BaseEstimator, TransformerMixin): numpy array with shape (number of diagrams) x (number of samples = **num_landscapes** x **resolution**): output persistence landscapes. """ num_diag, Xfit = len(X), [] - x_values = np.linspace(self.sample_range[0], self.sample_range[1], self.resolution) + x_values = np.linspace(self.sample_range[0], self.sample_range[1], self.resolution + self.nan_in_range.sum()) step_x = x_values[1] - x_values[0] for i in range(num_diag): @@ -157,7 +158,12 @@ class Landscape(BaseEstimator, TransformerMixin): for k in range( min(self.num_landscapes, len(events[j])) ): ls[k,j] = events[j][k] - Xfit.append(np.sqrt(2)*np.reshape(ls,[1,-1])) + if self.nan_in_range[0]: + ls = ls[:,1:] + if self.nan_in_range[1]: + ls = ls[:,:-1] + ls = np.sqrt(2)*np.reshape(ls,[1,-1]) + Xfit.append(ls) Xfit = np.concatenate(Xfit,0) -- cgit v1.2.3 From 5385b57782d63cf86048762e9a1c9b0c1070930c Mon Sep 17 00:00:00 2001 From: ROUVREAU Vincent Date: Mon, 9 Dec 2019 10:29:02 +0100 Subject: Document 'ctest --output-on-failure' in installation tests section --- src/common/doc/installation.h | 5 ++++- src/python/doc/installation.rst | 12 ++++++++++++ 2 files changed, 16 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/common/doc/installation.h b/src/common/doc/installation.h index c320e7e0..c4ca10d1 100644 --- a/src/common/doc/installation.h +++ b/src/common/doc/installation.h @@ -32,7 +32,10 @@ make \endverbatim * * \subsection testsuites Test suites * To test your build, run the following command in a terminal: - * \verbatim make test \endverbatim + * \verbatim make test \endverbatim + * `make test` is using Ctest<\a> (CMake test driver + * program). If some of the tests are failing, plend send us the result of the following command: + * \verbatim ctest --output-on-failure \endverbatim * * \subsection documentationgeneration Documentation * To generate the documentation, Doxygen is required. diff --git a/src/python/doc/installation.rst b/src/python/doc/installation.rst index 54504413..3553ae51 100644 --- a/src/python/doc/installation.rst +++ b/src/python/doc/installation.rst @@ -98,6 +98,18 @@ following command in a terminal: export PYTHONPATH='$PYTHONPATH:/path-to-gudhi/build/python' make test +`make test` is using +`Ctest `_ (CMake test +driver program). If some of the tests are failing, plend send us the result of +the following command: + +.. code-block:: bash + + cd /path-to-gudhi/build/python + # For windows, you have to set PYTHONPATH environment variable + export PYTHONPATH='$PYTHONPATH:/path-to-gudhi/build/python' + ctest --output-on-failure + Debugging issues ================ -- cgit v1.2.3 From 406d7349a4732a185374822bf465f914e95d07c9 Mon Sep 17 00:00:00 2001 From: ROUVREAU Vincent Date: Mon, 9 Dec 2019 11:11:00 +0100 Subject: Add some debug traces to find why sphinx fails --- .travis.yml | 3 ++- src/python/doc/python3-sphinx-build.py | 2 ++ 2 files changed, 4 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/.travis.yml b/.travis.yml index 51bc26c3..1c490b69 100644 --- a/.travis.yml +++ b/.travis.yml @@ -25,7 +25,7 @@ matrix: - CMAKE_EXAMPLE='OFF' CMAKE_TEST='OFF' CMAKE_UTILITIES='OFF' CMAKE_PYTHON='OFF' MAKE_TARGET='doxygen' CTEST_COMMAND='echo No tests for doxygen target' - env: # 5. Only Python, associated tests and sphinx documentation - - CMAKE_EXAMPLE='OFF' CMAKE_TEST='OFF' CMAKE_UTILITIES='OFF' CMAKE_PYTHON='ON' MAKE_TARGET='all sphinx' CTEST_COMMAND='ctest --output-on-failure' + - CMAKE_EXAMPLE='OFF' CMAKE_TEST='OFF' CMAKE_UTILITIES='OFF' CMAKE_PYTHON='ON' MAKE_TARGET='all' CTEST_COMMAND='ctest --output-on-failure' cache: directories: @@ -56,6 +56,7 @@ install: - python3 -m pip install --upgrade pip setuptools wheel - python3 -m pip install --user pytest Cython sphinx sphinxcontrib-bibtex sphinx-paramlinks matplotlib numpy scipy scikit-learn - python3 -m pip install --user POT + - which python3 script: - rm -rf build diff --git a/src/python/doc/python3-sphinx-build.py b/src/python/doc/python3-sphinx-build.py index 84d158cf..a8eede8a 100755 --- a/src/python/doc/python3-sphinx-build.py +++ b/src/python/doc/python3-sphinx-build.py @@ -5,6 +5,8 @@ Emulate sphinx-build for python3 """ from sys import exit, argv +print(sys.executable) +import sphinx from sphinx import main if __name__ == '__main__': -- cgit v1.2.3 From 3f99285cfbafd7c9fcabad6469bf16b3ba52396f Mon Sep 17 00:00:00 2001 From: ROUVREAU Vincent Date: Mon, 9 Dec 2019 13:31:18 +0100 Subject: need to import sys --- src/python/doc/python3-sphinx-build.py | 1 + 1 file changed, 1 insertion(+) (limited to 'src') diff --git a/src/python/doc/python3-sphinx-build.py b/src/python/doc/python3-sphinx-build.py index a8eede8a..5dc26fd2 100755 --- a/src/python/doc/python3-sphinx-build.py +++ b/src/python/doc/python3-sphinx-build.py @@ -5,6 +5,7 @@ Emulate sphinx-build for python3 """ from sys import exit, argv +import sys print(sys.executable) import sphinx from sphinx import main -- cgit v1.2.3 From 83867c78935460f727831b54e390c5be30bb4eee Mon Sep 17 00:00:00 2001 From: ROUVREAU Vincent Date: Mon, 9 Dec 2019 13:59:07 +0100 Subject: need to import sys --- src/python/doc/python3-sphinx-build.py | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) (limited to 'src') diff --git a/src/python/doc/python3-sphinx-build.py b/src/python/doc/python3-sphinx-build.py index 5dc26fd2..3628e89e 100755 --- a/src/python/doc/python3-sphinx-build.py +++ b/src/python/doc/python3-sphinx-build.py @@ -4,9 +4,8 @@ Emulate sphinx-build for python3 """ -from sys import exit, argv -import sys -print(sys.executable) +from sys import exit, argv, executable +print(executable) import sphinx from sphinx import main -- cgit v1.2.3 From 4391bf38f14f483b9032e3eaf99f315f2f053026 Mon Sep 17 00:00:00 2001 From: ROUVREAU Vincent Date: Tue, 10 Dec 2019 00:04:02 +0100 Subject: Remove debug traces --- .travis.yml | 1 - src/python/doc/python3-sphinx-build.py | 3 +-- 2 files changed, 1 insertion(+), 3 deletions(-) (limited to 'src') diff --git a/.travis.yml b/.travis.yml index b7cd854a..d6c82e70 100644 --- a/.travis.yml +++ b/.travis.yml @@ -60,7 +60,6 @@ install: - python3 -m pip install --upgrade pip setuptools wheel - python3 -m pip install --user pytest Cython sphinx sphinxcontrib-bibtex sphinx-paramlinks matplotlib numpy scipy scikit-learn - python3 -m pip install --user POT - - which python3 script: - rm -rf build diff --git a/src/python/doc/python3-sphinx-build.py b/src/python/doc/python3-sphinx-build.py index 3628e89e..d1f0f08e 100755 --- a/src/python/doc/python3-sphinx-build.py +++ b/src/python/doc/python3-sphinx-build.py @@ -4,8 +4,7 @@ Emulate sphinx-build for python3 """ -from sys import exit, argv, executable -print(executable) +from sys import exit, argv import sphinx from sphinx import main -- cgit v1.2.3 From 329637d2a0a806955a29faccf38915c3fb7cd2fd Mon Sep 17 00:00:00 2001 From: ROUVREAU Vincent Date: Tue, 10 Dec 2019 10:03:53 +0100 Subject: Remove number_of_vertices method from Alpha_complex as there is no added value to Simplex_tree.num_vertices() --- src/Alpha_complex/include/gudhi/Alpha_complex.h | 8 --- src/Alpha_complex/test/Alpha_complex_unit_test.cpp | 60 +++++++++++++++------- 2 files changed, 42 insertions(+), 26 deletions(-) (limited to 'src') diff --git a/src/Alpha_complex/include/gudhi/Alpha_complex.h b/src/Alpha_complex/include/gudhi/Alpha_complex.h index 6f19cb6c..f2a05e95 100644 --- a/src/Alpha_complex/include/gudhi/Alpha_complex.h +++ b/src/Alpha_complex/include/gudhi/Alpha_complex.h @@ -191,14 +191,6 @@ class Alpha_complex { return vertex_handle_to_iterator_.at(vertex)->point(); } - /** \brief number_of_vertices returns the number of vertices (same as the number of points). - * - * @return The number of vertices. - */ - std::size_t number_of_vertices() const { - return vertex_handle_to_iterator_.size(); - } - private: template void init_from_range(const InputPointRange& points) { diff --git a/src/Alpha_complex/test/Alpha_complex_unit_test.cpp b/src/Alpha_complex/test/Alpha_complex_unit_test.cpp index 40b3fe09..27b671dd 100644 --- a/src/Alpha_complex/test/Alpha_complex_unit_test.cpp +++ b/src/Alpha_complex/test/Alpha_complex_unit_test.cpp @@ -53,20 +53,12 @@ BOOST_AUTO_TEST_CASE_TEMPLATE(Alpha_complex_from_OFF_file, TestedKernel, list_of Gudhi::alpha_complex::Alpha_complex alpha_complex_from_file(off_file_name); - std::cout << "alpha_complex_from_points.number_of_vertices()=" << alpha_complex_from_file.number_of_vertices() - << std::endl; - BOOST_CHECK(alpha_complex_from_file.number_of_vertices() == 7); - Gudhi::Simplex_tree<> simplex_tree_60; BOOST_CHECK(alpha_complex_from_file.create_complex(simplex_tree_60, max_alpha_square_value)); std::cout << "simplex_tree_60.dimension()=" << simplex_tree_60.dimension() << std::endl; BOOST_CHECK(simplex_tree_60.dimension() == 2); - std::cout << "alpha_complex_from_points.number_of_vertices()=" << alpha_complex_from_file.number_of_vertices() - << std::endl; - BOOST_CHECK(alpha_complex_from_file.number_of_vertices() == 7); - std::cout << "simplex_tree_60.num_vertices()=" << simplex_tree_60.num_vertices() << std::endl; BOOST_CHECK(simplex_tree_60.num_vertices() == 7); @@ -128,10 +120,6 @@ BOOST_AUTO_TEST_CASE(Alpha_complex_from_points) { Gudhi::Simplex_tree<> simplex_tree; BOOST_CHECK(alpha_complex_from_points.create_complex(simplex_tree)); - std::cout << "alpha_complex_from_points.number_of_vertices()=" << alpha_complex_from_points.number_of_vertices() - << std::endl; - BOOST_CHECK(alpha_complex_from_points.number_of_vertices() == points.size()); - // Another way to check num_simplices std::cout << "Iterator on alpha complex simplices in the filtration order, with [filtration value]:" << std::endl; int num_simplices = 0; @@ -151,7 +139,7 @@ BOOST_AUTO_TEST_CASE(Alpha_complex_from_points) { std::cout << "simplex_tree.dimension()=" << simplex_tree.dimension() << std::endl; BOOST_CHECK(simplex_tree.dimension() == 3); std::cout << "simplex_tree.num_vertices()=" << simplex_tree.num_vertices() << std::endl; - BOOST_CHECK(simplex_tree.num_vertices() == 4); + BOOST_CHECK(simplex_tree.num_vertices() == points.size()); for (auto f_simplex : simplex_tree.filtration_simplex_range()) { switch (simplex_tree.dimension(f_simplex)) { @@ -261,10 +249,6 @@ BOOST_AUTO_TEST_CASE_TEMPLATE(Alpha_complex_from_empty_points, TestedKernel, lis Gudhi::Simplex_tree<> simplex_tree; BOOST_CHECK(!alpha_complex_from_points.create_complex(simplex_tree)); - std::cout << "alpha_complex_from_points.number_of_vertices()=" << alpha_complex_from_points.number_of_vertices() - << std::endl; - BOOST_CHECK(alpha_complex_from_points.number_of_vertices() == points.size()); - std::cout << "simplex_tree.num_simplices()=" << simplex_tree.num_simplices() << std::endl; BOOST_CHECK(simplex_tree.num_simplices() == 0); @@ -272,5 +256,45 @@ BOOST_AUTO_TEST_CASE_TEMPLATE(Alpha_complex_from_empty_points, TestedKernel, lis BOOST_CHECK(simplex_tree.dimension() == -1); std::cout << "simplex_tree.num_vertices()=" << simplex_tree.num_vertices() << std::endl; - BOOST_CHECK(simplex_tree.num_vertices() == 0); + BOOST_CHECK(simplex_tree.num_vertices() == points.size()); +} + +using Inexact_kernel_2 = CGAL::Epick_d< CGAL::Dimension_tag<2> >; +using Exact_kernel_2 = CGAL::Epeck_d< CGAL::Dimension_tag<2> >; +using list_of_kernel_2_variants = boost::mpl::list; + +BOOST_AUTO_TEST_CASE_TEMPLATE(Alpha_complex_with_duplicated_points, TestedKernel, list_of_kernel_2_variants) { + std::cout << "========== Alpha_complex_with_duplicated_points ==========" << std::endl; + + using Point = typename TestedKernel::Point_d; + using Vector_of_points = std::vector; + + // ---------------------------------------------------------------------------- + // Init of a list of points + // ---------------------------------------------------------------------------- + Vector_of_points points; + points.push_back(Point(1.0, 1.0)); + points.push_back(Point(7.0, 0.0)); + points.push_back(Point(4.0, 6.0)); + points.push_back(Point(9.0, 6.0)); + points.push_back(Point(0.0, 14.0)); + points.push_back(Point(2.0, 19.0)); + points.push_back(Point(9.0, 17.0)); + // duplicated points + points.push_back(Point(1.0, 1.0)); + points.push_back(Point(7.0, 0.0)); + + // ---------------------------------------------------------------------------- + // Init of an alpha complex from the list of points + // ---------------------------------------------------------------------------- + std::cout << "Init" << std::endl; + Gudhi::alpha_complex::Alpha_complex alpha_complex_from_points(points); + + Gudhi::Simplex_tree<> simplex_tree; + std::cout << "create_complex" << std::endl; + BOOST_CHECK(alpha_complex_from_points.create_complex(simplex_tree)); + + std::cout << "simplex_tree.num_vertices()=" << simplex_tree.num_vertices() + << std::endl; + BOOST_CHECK(simplex_tree.num_vertices() < points.size()); } -- cgit v1.2.3 From 94118b7c5c723bf62dcdafd404d492e8d78d0019 Mon Sep 17 00:00:00 2001 From: ROUVREAU Vincent Date: Tue, 10 Dec 2019 10:06:00 +0100 Subject: Remove useless import --- src/python/doc/python3-sphinx-build.py | 1 - 1 file changed, 1 deletion(-) (limited to 'src') diff --git a/src/python/doc/python3-sphinx-build.py b/src/python/doc/python3-sphinx-build.py index d1f0f08e..84d158cf 100755 --- a/src/python/doc/python3-sphinx-build.py +++ b/src/python/doc/python3-sphinx-build.py @@ -5,7 +5,6 @@ Emulate sphinx-build for python3 """ from sys import exit, argv -import sphinx from sphinx import main if __name__ == '__main__': -- cgit v1.2.3 From ad0131187e70657b699eb205de901e50ab36a5d9 Mon Sep 17 00:00:00 2001 From: ROUVREAU Vincent Date: Tue, 10 Dec 2019 11:44:21 +0100 Subject: Fix #118 for persistence_intervals --- .../include/gudhi/Persistence_intervals.h | 5 +++++ src/Persistence_representations/test/persistence_intervals_test.cpp | 4 +--- 2 files changed, 6 insertions(+), 3 deletions(-) (limited to 'src') diff --git a/src/Persistence_representations/include/gudhi/Persistence_intervals.h b/src/Persistence_representations/include/gudhi/Persistence_intervals.h index e2db4572..ea4220ea 100644 --- a/src/Persistence_representations/include/gudhi/Persistence_intervals.h +++ b/src/Persistence_representations/include/gudhi/Persistence_intervals.h @@ -6,6 +6,8 @@ * * Modification(s): * - YYYY/MM Author: Description of the modification + * - 2019/12 Vincent Rouvreau: Fix #118 - Make histogram_of_lengths and cumulative_histogram_of_lengths + * return the exact number_of_bins (was failing on x86) */ #ifndef PERSISTENCE_INTERVALS_H_ @@ -335,6 +337,9 @@ std::vector Persistence_intervals::histogram_of_lengths(size_t number_of getchar(); } } + // we want number of bins equals to number_of_bins (some unexpected results on x86) + result[number_of_bins-1]+=result[number_of_bins]; + result.resize(number_of_bins); if (dbg) { for (size_t i = 0; i != result.size(); ++i) std::cerr << result[i] << std::endl; diff --git a/src/Persistence_representations/test/persistence_intervals_test.cpp b/src/Persistence_representations/test/persistence_intervals_test.cpp index 3b7a2049..a29dcbee 100644 --- a/src/Persistence_representations/test/persistence_intervals_test.cpp +++ b/src/Persistence_representations/test/persistence_intervals_test.cpp @@ -85,8 +85,7 @@ BOOST_AUTO_TEST_CASE(check_histogram_of_lengths) { template_histogram.push_back(6); template_histogram.push_back(1); template_histogram.push_back(7); - template_histogram.push_back(1); - template_histogram.push_back(1); + template_histogram.push_back(2); for (size_t i = 0; i != histogram.size(); ++i) { BOOST_CHECK(histogram[i] == template_histogram[i]); } @@ -105,7 +104,6 @@ BOOST_AUTO_TEST_CASE(check_cumulative_histograms_of_lengths) { template_cumulative_histogram.push_back(35); template_cumulative_histogram.push_back(36); template_cumulative_histogram.push_back(43); - template_cumulative_histogram.push_back(44); template_cumulative_histogram.push_back(45); for (size_t i = 0; i != cumulative_histogram.size(); ++i) { -- cgit v1.2.3 From 291286815e282c9693f17615f8c46a49f87bf887 Mon Sep 17 00:00:00 2001 From: ROUVREAU Vincent Date: Tue, 10 Dec 2019 13:33:02 +0100 Subject: Use initializer list instead of push_back to init vectors --- .../test/persistence_intervals_test.cpp | 209 ++++----------------- 1 file changed, 40 insertions(+), 169 deletions(-) (limited to 'src') diff --git a/src/Persistence_representations/test/persistence_intervals_test.cpp b/src/Persistence_representations/test/persistence_intervals_test.cpp index a29dcbee..02ea8edb 100644 --- a/src/Persistence_representations/test/persistence_intervals_test.cpp +++ b/src/Persistence_representations/test/persistence_intervals_test.cpp @@ -6,6 +6,8 @@ * * Modification(s): * - YYYY/MM Author: Description of the modification + * - 2019/12 Vincent Rouvreau: Fix #118 - Make histogram_of_lengths and cumulative_histogram_of_lengths + * return the exact number_of_bins (was failing on x86) */ #define BOOST_TEST_DYN_LINK @@ -32,17 +34,8 @@ BOOST_AUTO_TEST_CASE(check_min_max_function) { BOOST_AUTO_TEST_CASE(check_length_of_dominant_intervals) { Persistence_intervals p("data/file_with_diagram"); std::vector dominant_ten_intervals_length = p.length_of_dominant_intervals(10); - std::vector dominant_intervals_length; - dominant_intervals_length.push_back(0.862625); - dominant_intervals_length.push_back(0.800893); - dominant_intervals_length.push_back(0.762061); - dominant_intervals_length.push_back(0.756501); - dominant_intervals_length.push_back(0.729367); - dominant_intervals_length.push_back(0.718177); - dominant_intervals_length.push_back(0.708395); - dominant_intervals_length.push_back(0.702844); - dominant_intervals_length.push_back(0.700468); - dominant_intervals_length.push_back(0.622177); + std::vector dominant_intervals_length{0.862625, 0.800893, 0.762061, 0.756501, 0.729367, + 0.718177, 0.708395, 0.702844, 0.700468, 0.622177}; for (size_t i = 0; i != dominant_ten_intervals_length.size(); ++i) { GUDHI_TEST_FLOAT_EQUALITY_CHECK(dominant_ten_intervals_length[i], dominant_intervals_length[i], Gudhi::Persistence_representations::epsi); @@ -52,17 +45,11 @@ BOOST_AUTO_TEST_CASE(check_dominant_intervals) { Persistence_intervals p("data/file_with_diagram"); std::vector > ten_dominant_intervals = p.dominant_intervals(10); - std::vector > templ; - templ.push_back(std::pair(0.114718, 0.977343)); - templ.push_back(std::pair(0.133638, 0.93453)); - templ.push_back(std::pair(0.104599, 0.866659)); - templ.push_back(std::pair(0.149798, 0.906299)); - templ.push_back(std::pair(0.247352, 0.976719)); - templ.push_back(std::pair(0.192675, 0.910852)); - templ.push_back(std::pair(0.191836, 0.900231)); - templ.push_back(std::pair(0.284998, 0.987842)); - templ.push_back(std::pair(0.294069, 0.994537)); - templ.push_back(std::pair(0.267421, 0.889597)); + std::vector > templ{ {0.114718, 0.977343}, {0.133638, 0.93453}, + {0.104599, 0.866659}, {0.149798, 0.906299}, + {0.247352, 0.976719}, {0.192675, 0.910852}, + {0.191836, 0.900231}, {0.284998, 0.987842}, + {0.294069, 0.994537}, {0.267421, 0.889597} }; for (size_t i = 0; i != ten_dominant_intervals.size(); ++i) { GUDHI_TEST_FLOAT_EQUALITY_CHECK(ten_dominant_intervals[i].first, templ[i].first, @@ -75,17 +62,7 @@ BOOST_AUTO_TEST_CASE(check_dominant_intervals) { BOOST_AUTO_TEST_CASE(check_histogram_of_lengths) { Persistence_intervals p("data/file_with_diagram"); std::vector histogram = p.histogram_of_lengths(10); - std::vector template_histogram; - template_histogram.push_back(10); - template_histogram.push_back(5); - template_histogram.push_back(3); - template_histogram.push_back(4); - template_histogram.push_back(4); - template_histogram.push_back(3); - template_histogram.push_back(6); - template_histogram.push_back(1); - template_histogram.push_back(7); - template_histogram.push_back(2); + std::vector template_histogram{10, 5, 3, 4, 4, 3, 6, 1, 7, 2}; for (size_t i = 0; i != histogram.size(); ++i) { BOOST_CHECK(histogram[i] == template_histogram[i]); } @@ -94,17 +71,7 @@ BOOST_AUTO_TEST_CASE(check_histogram_of_lengths) { BOOST_AUTO_TEST_CASE(check_cumulative_histograms_of_lengths) { Persistence_intervals p("data/file_with_diagram"); std::vector cumulative_histogram = p.cumulative_histogram_of_lengths(10); - std::vector template_cumulative_histogram; - template_cumulative_histogram.push_back(10); - template_cumulative_histogram.push_back(15); - template_cumulative_histogram.push_back(18); - template_cumulative_histogram.push_back(22); - template_cumulative_histogram.push_back(26); - template_cumulative_histogram.push_back(29); - template_cumulative_histogram.push_back(35); - template_cumulative_histogram.push_back(36); - template_cumulative_histogram.push_back(43); - template_cumulative_histogram.push_back(45); + std::vector template_cumulative_histogram{10, 15, 18, 22, 26, 29, 35, 36, 43, 45}; for (size_t i = 0; i != cumulative_histogram.size(); ++i) { BOOST_CHECK(cumulative_histogram[i] == template_cumulative_histogram[i]); @@ -114,17 +81,8 @@ BOOST_AUTO_TEST_CASE(check_characteristic_function_of_diagram) { Persistence_intervals p("data/file_with_diagram"); std::pair min_max_ = p.get_x_range(); std::vector char_funct_diag = p.characteristic_function_of_diagram(min_max_.first, min_max_.second); - std::vector template_char_funct_diag; - template_char_funct_diag.push_back(0.370665); - template_char_funct_diag.push_back(0.84058); - template_char_funct_diag.push_back(1.24649); - template_char_funct_diag.push_back(1.3664); - template_char_funct_diag.push_back(1.34032); - template_char_funct_diag.push_back(1.31904); - template_char_funct_diag.push_back(1.14076); - template_char_funct_diag.push_back(0.991259); - template_char_funct_diag.push_back(0.800714); - template_char_funct_diag.push_back(0.0676303); + std::vector template_char_funct_diag{0.370665, 0.84058, 1.24649, 1.3664, 1.34032, + 1.31904, 1.14076, 0.991259, 0.800714, 0.0676303}; for (size_t i = 0; i != char_funct_diag.size(); ++i) { GUDHI_TEST_FLOAT_EQUALITY_CHECK(char_funct_diag[i], template_char_funct_diag[i], @@ -137,18 +95,8 @@ BOOST_AUTO_TEST_CASE(check_cumulative_characteristic_function_of_diagram) { std::pair min_max_ = p.get_x_range(); std::vector cumul_char_funct_diag = p.cumulative_characteristic_function_of_diagram(min_max_.first, min_max_.second); - std::vector template_char_funct_diag_cumul; - - template_char_funct_diag_cumul.push_back(0.370665); - template_char_funct_diag_cumul.push_back(1.21125); - template_char_funct_diag_cumul.push_back(2.45774); - template_char_funct_diag_cumul.push_back(3.82414); - template_char_funct_diag_cumul.push_back(5.16446); - template_char_funct_diag_cumul.push_back(6.4835); - template_char_funct_diag_cumul.push_back(7.62426); - template_char_funct_diag_cumul.push_back(8.61552); - template_char_funct_diag_cumul.push_back(9.41623); - template_char_funct_diag_cumul.push_back(9.48386); + std::vector template_char_funct_diag_cumul{0.370665, 1.21125, 2.45774, 3.82414, 5.16446, + 6.4835, 7.62426, 8.61552, 9.41623, 9.48386}; for (size_t i = 0; i != cumul_char_funct_diag.size(); ++i) { GUDHI_TEST_FLOAT_EQUALITY_CHECK(cumul_char_funct_diag[i], template_char_funct_diag_cumul[i], @@ -158,97 +106,29 @@ BOOST_AUTO_TEST_CASE(check_cumulative_characteristic_function_of_diagram) { BOOST_AUTO_TEST_CASE(check_compute_persistent_betti_numbers) { Persistence_intervals p("data/file_with_diagram"); - std::vector > pbns; - pbns.push_back(std::pair(0.0290362, 1)); - pbns.push_back(std::pair(0.0307676, 2)); - pbns.push_back(std::pair(0.0366312, 3)); - pbns.push_back(std::pair(0.0544614, 4)); - pbns.push_back(std::pair(0.0920033, 5)); - pbns.push_back(std::pair(0.104599, 6)); - pbns.push_back(std::pair(0.114718, 7)); - pbns.push_back(std::pair(0.117379, 8)); - pbns.push_back(std::pair(0.123493, 9)); - pbns.push_back(std::pair(0.133638, 10)); - pbns.push_back(std::pair(0.137798, 9)); - pbns.push_back(std::pair(0.149798, 10)); - pbns.push_back(std::pair(0.155421, 11)); - pbns.push_back(std::pair(0.158443, 12)); - pbns.push_back(std::pair(0.176956, 13)); - pbns.push_back(std::pair(0.183234, 12)); - pbns.push_back(std::pair(0.191069, 13)); - pbns.push_back(std::pair(0.191333, 14)); - pbns.push_back(std::pair(0.191836, 15)); - pbns.push_back(std::pair(0.192675, 16)); - pbns.push_back(std::pair(0.208564, 17)); - pbns.push_back(std::pair(0.218425, 18)); - pbns.push_back(std::pair(0.219902, 17)); - pbns.push_back(std::pair(0.23233, 16)); - pbns.push_back(std::pair(0.234558, 17)); - pbns.push_back(std::pair(0.237166, 16)); - pbns.push_back(std::pair(0.247352, 17)); - pbns.push_back(std::pair(0.267421, 18)); - pbns.push_back(std::pair(0.268093, 19)); - pbns.push_back(std::pair(0.278734, 18)); - pbns.push_back(std::pair(0.284722, 19)); - pbns.push_back(std::pair(0.284998, 20)); - pbns.push_back(std::pair(0.294069, 21)); - pbns.push_back(std::pair(0.306293, 22)); - pbns.push_back(std::pair(0.322361, 21)); - pbns.push_back(std::pair(0.323152, 22)); - pbns.push_back(std::pair(0.371021, 23)); - pbns.push_back(std::pair(0.372395, 24)); - pbns.push_back(std::pair(0.387744, 25)); - pbns.push_back(std::pair(0.435537, 26)); - pbns.push_back(std::pair(0.462911, 25)); - pbns.push_back(std::pair(0.483569, 26)); - pbns.push_back(std::pair(0.489209, 25)); - pbns.push_back(std::pair(0.517115, 24)); - pbns.push_back(std::pair(0.522197, 23)); - pbns.push_back(std::pair(0.532665, 22)); - pbns.push_back(std::pair(0.545262, 23)); - pbns.push_back(std::pair(0.587227, 22)); - pbns.push_back(std::pair(0.593036, 23)); - pbns.push_back(std::pair(0.602647, 24)); - pbns.push_back(std::pair(0.605044, 25)); - pbns.push_back(std::pair(0.621962, 24)); - pbns.push_back(std::pair(0.629449, 23)); - pbns.push_back(std::pair(0.636719, 22)); - pbns.push_back(std::pair(0.64957, 21)); - pbns.push_back(std::pair(0.650781, 22)); - pbns.push_back(std::pair(0.654951, 23)); - pbns.push_back(std::pair(0.683489, 24)); - pbns.push_back(std::pair(0.687172, 23)); - pbns.push_back(std::pair(0.69703, 22)); - pbns.push_back(std::pair(0.701174, 21)); - pbns.push_back(std::pair(0.717623, 22)); - pbns.push_back(std::pair(0.722023, 21)); - pbns.push_back(std::pair(0.722298, 20)); - pbns.push_back(std::pair(0.725347, 19)); - pbns.push_back(std::pair(0.73071, 18)); - pbns.push_back(std::pair(0.758355, 17)); - pbns.push_back(std::pair(0.770913, 18)); - pbns.push_back(std::pair(0.790833, 17)); - pbns.push_back(std::pair(0.821211, 16)); - pbns.push_back(std::pair(0.849305, 17)); - pbns.push_back(std::pair(0.853669, 16)); - pbns.push_back(std::pair(0.866659, 15)); - pbns.push_back(std::pair(0.872896, 16)); - pbns.push_back(std::pair(0.889597, 15)); - pbns.push_back(std::pair(0.900231, 14)); - pbns.push_back(std::pair(0.903847, 13)); - pbns.push_back(std::pair(0.906299, 12)); - pbns.push_back(std::pair(0.910852, 11)); - pbns.push_back(std::pair(0.93453, 10)); - pbns.push_back(std::pair(0.944757, 9)); - pbns.push_back(std::pair(0.947812, 8)); - pbns.push_back(std::pair(0.959154, 7)); - pbns.push_back(std::pair(0.975654, 6)); - pbns.push_back(std::pair(0.976719, 5)); - pbns.push_back(std::pair(0.977343, 4)); - pbns.push_back(std::pair(0.980129, 3)); - pbns.push_back(std::pair(0.987842, 2)); - pbns.push_back(std::pair(0.990127, 1)); - pbns.push_back(std::pair(0.994537, 0)); + std::vector > pbns{ {0.0290362, 1}, {0.0307676, 2}, {0.0366312, 3}, {0.0544614, 4}, + {0.0920033, 5}, {0.104599, 6}, {0.114718, 7}, {0.117379, 8}, + {0.123493, 9}, {0.133638, 10}, {0.137798, 9}, {0.149798, 10}, + {0.155421, 11}, {0.158443, 12}, {0.176956, 13}, {0.183234, 12}, + {0.191069, 13}, {0.191333, 14}, {0.191836, 15}, {0.192675, 16}, + {0.208564, 17}, {0.218425, 18}, {0.219902, 17}, {0.23233, 16}, + {0.234558, 17}, {0.237166, 16}, {0.247352, 17}, {0.267421, 18}, + {0.268093, 19}, {0.278734, 18}, {0.284722, 19}, {0.284998, 20}, + {0.294069, 21}, {0.306293, 22}, {0.322361, 21}, {0.323152, 22}, + {0.371021, 23}, {0.372395, 24}, {0.387744, 25}, {0.435537, 26}, + {0.462911, 25}, {0.483569, 26}, {0.489209, 25}, {0.517115, 24}, + {0.522197, 23}, {0.532665, 22}, {0.545262, 23}, {0.587227, 22}, + {0.593036, 23}, {0.602647, 24}, {0.605044, 25}, {0.621962, 24}, + {0.629449, 23}, {0.636719, 22}, {0.64957, 21}, {0.650781, 22}, + {0.654951, 23}, {0.683489, 24}, {0.687172, 23}, {0.69703, 22}, + {0.701174, 21}, {0.717623, 22}, {0.722023, 21}, {0.722298, 20}, + {0.725347, 19}, {0.73071, 18}, {0.758355, 17}, {0.770913, 18}, + {0.790833, 17}, {0.821211, 16}, {0.849305, 17}, {0.853669, 16}, + {0.866659, 15}, {0.872896, 16}, {0.889597, 15}, {0.900231, 14}, + {0.903847, 13}, {0.906299, 12}, {0.910852, 11}, {0.93453, 10}, + {0.944757, 9}, {0.947812, 8}, {0.959154, 7}, {0.975654, 6}, + {0.976719, 5}, {0.977343, 4}, {0.980129, 3}, {0.987842, 2}, + {0.990127, 1}, {0.994537, 0} }; std::vector > pbns_new = p.compute_persistent_betti_numbers(); for (size_t i = 0; i != pbns.size(); ++i) { @@ -260,17 +140,8 @@ BOOST_AUTO_TEST_CASE(check_compute_persistent_betti_numbers) { BOOST_AUTO_TEST_CASE(check_k_n_n) { Persistence_intervals p("data/file_with_diagram"); std::vector knn = p.k_n_n(5); - std::vector knn_template; - knn_template.push_back(1.04208); - knn_template.push_back(1.00344); - knn_template.push_back(0.979395); - knn_template.push_back(0.890643); - knn_template.push_back(0.874769); - knn_template.push_back(0.845787); - knn_template.push_back(0.819713); - knn_template.push_back(0.803984); - knn_template.push_back(0.799864); - knn_template.push_back(0.786945); + std::vector knn_template{1.04208, 1.00344, 0.979395, 0.890643, 0.874769, + 0.845787, 0.819713, 0.803984, 0.799864, 0.786945}; for (size_t i = 0; i != knn.size(); ++i) { GUDHI_TEST_FLOAT_EQUALITY_CHECK(knn[i], knn_template[i], Gudhi::Persistence_representations::epsi); -- cgit v1.2.3 From 5ecc15ba30e7a20604d50c1fdec9e7da2de64898 Mon Sep 17 00:00:00 2001 From: mathieu Date: Tue, 10 Dec 2019 14:24:52 -0500 Subject: fixed doc and examples --- src/python/doc/representations.rst | 4 ++-- src/python/example/diagram_vectorizations_distances_kernels.py | 6 +++--- 2 files changed, 5 insertions(+), 5 deletions(-) (limited to 'src') diff --git a/src/python/doc/representations.rst b/src/python/doc/representations.rst index b338f7f0..409e97da 100644 --- a/src/python/doc/representations.rst +++ b/src/python/doc/representations.rst @@ -10,7 +10,7 @@ Representations manual This module, originally available at https://github.com/MathieuCarriere/sklearn-tda and named sklearn_tda, aims at bridging the gap between persistence diagrams and machine learning, by providing implementations of most of the vector representations for persistence diagrams in the literature, in a scikit-learn format. More specifically, it provides tools, using the scikit-learn standard interface, to compute distances and kernels on persistence diagrams, and to convert these diagrams into vectors in Euclidean space. -A diagram is represented as a numpy array of shape (n,2), as can be obtained from `SimplexTree.persistence_intervals_in_dimension` for instance. Points at infinity are represented as a numpy array of shape (n,1), storing only the birth time. +A diagram is represented as a numpy array of shape (n,2), as can be obtained from :func:`~gudhi.SimplexTree.persistence_intervals_in_dimension` for instance. Points at infinity are represented as a numpy array of shape (n,1), storing only the birth time. A small example is provided @@ -66,4 +66,4 @@ The output is: .. testoutput:: - [[0. 1.25707872 2.51415744 1.88561808 0.7856742 2.04275292 3.29983165 2.51415744 1.25707872 0. 0. 0. 0.31426968 0. 0.62853936 0. 0. 0.31426968 1.25707872 0. ]] + [[1.02851895 2.05703791 2.57129739 1.54277843 0.89995409 1.92847304 2.95699199 3.08555686 0. 0.64282435 0. 0. 0.51425948 0. 0. 0. ]] diff --git a/src/python/example/diagram_vectorizations_distances_kernels.py b/src/python/example/diagram_vectorizations_distances_kernels.py index f777984c..0ea4ba79 100755 --- a/src/python/example/diagram_vectorizations_distances_kernels.py +++ b/src/python/example/diagram_vectorizations_distances_kernels.py @@ -26,9 +26,9 @@ plt.show() LS = Landscape(resolution=1000) L = LS.fit_transform(diags) -plt.plot(L[0][:999]) -plt.plot(L[0][999:2*999]) -plt.plot(L[0][2*999:3*999]) +plt.plot(L[0][:998]) +plt.plot(L[0][998:2*998]) +plt.plot(L[0][2*998:3*998]) plt.title("Landscape") plt.show() -- cgit v1.2.3 From 0474f6a62622608b96eac3a553a081e148cbcabc Mon Sep 17 00:00:00 2001 From: ROUVREAU Vincent Date: Tue, 10 Dec 2019 22:51:08 +0100 Subject: Remove FindMPFR mechanism as the job is already done by CGAL --- src/cmake/modules/FindMPFR.cmake | 51 ---------------------- .../modules/GUDHI_third_party_libraries.cmake | 2 - src/python/CMakeLists.txt | 44 ++++++++----------- 3 files changed, 19 insertions(+), 78 deletions(-) delete mode 100644 src/cmake/modules/FindMPFR.cmake (limited to 'src') diff --git a/src/cmake/modules/FindMPFR.cmake b/src/cmake/modules/FindMPFR.cmake deleted file mode 100644 index 6c963272..00000000 --- a/src/cmake/modules/FindMPFR.cmake +++ /dev/null @@ -1,51 +0,0 @@ -# Try to find the MPFR libraries -# MPFR_FOUND - system has MPFR lib -# MPFR_INCLUDE_DIR - the MPFR include directory -# MPFR_LIBRARIES_DIR - Directory where the MPFR libraries are located -# MPFR_LIBRARIES - the MPFR libraries - -# TODO: support MacOSX - -include(FindPackageHandleStandardArgs) - -if(MPFR_INCLUDE_DIR) - set(MPFR_in_cache TRUE) -else() - set(MPFR_in_cache FALSE) -endif() -if(NOT MPFR_LIBRARIES) - set(MPFR_in_cache FALSE) -endif() - -# Is it already configured? -if (MPFR_in_cache) - set(MPFR_FOUND TRUE) -else() - find_path(MPFR_INCLUDE_DIR - NAMES mpfr.h - HINTS ENV MPFR_INC_DIR - ENV MPFR_DIR - ${CGAL_INSTALLATION_PACKAGE_DIR}/auxiliary/gmp/include - PATH_SUFFIXES include - DOC "The directory containing the MPFR header files" - ) - - find_library(MPFR_LIBRARIES NAMES mpfr libmpfr-4 libmpfr-1 - HINTS ENV MPFR_LIB_DIR - ENV MPFR_DIR - ${CGAL_INSTALLATION_PACKAGE_DIR}/auxiliary/gmp/lib - PATH_SUFFIXES lib - DOC "Path to the MPFR library" - ) - - if ( MPFR_LIBRARIES ) - get_filename_component(MPFR_LIBRARIES_DIR ${MPFR_LIBRARIES} PATH CACHE ) - endif() - - # Attempt to load a user-defined configuration for MPFR if couldn't be found - if ( NOT MPFR_INCLUDE_DIR OR NOT MPFR_LIBRARIES_DIR ) - include( MPFRConfig OPTIONAL ) - endif() - - find_package_handle_standard_args(MPFR "DEFAULT_MSG" MPFR_LIBRARIES MPFR_INCLUDE_DIR) -endif() diff --git a/src/cmake/modules/GUDHI_third_party_libraries.cmake b/src/cmake/modules/GUDHI_third_party_libraries.cmake index d8c7a428..24a34150 100644 --- a/src/cmake/modules/GUDHI_third_party_libraries.cmake +++ b/src/cmake/modules/GUDHI_third_party_libraries.cmake @@ -6,8 +6,6 @@ if(NOT Boost_FOUND) message(FATAL_ERROR "NOTICE: This program requires Boost and will not be compiled.") endif(NOT Boost_FOUND) -find_package(MPFR) - find_package(GMP) if(GMP_FOUND) INCLUDE_DIRECTORIES(${GMP_INCLUDE_DIR}) diff --git a/src/python/CMakeLists.txt b/src/python/CMakeLists.txt index 13a8a909..1704f491 100644 --- a/src/python/CMakeLists.txt +++ b/src/python/CMakeLists.txt @@ -230,14 +230,12 @@ endif(CGAL_FOUND) # Test examples if (NOT CGAL_WITH_EIGEN3_VERSION VERSION_LESS 4.11.0) - if (MPFR_FOUND) - # Bottleneck and Alpha - add_test(NAME alpha_rips_persistence_bottleneck_distance_py_test - WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR} - COMMAND ${CMAKE_COMMAND} -E env "PYTHONPATH=${CMAKE_CURRENT_BINARY_DIR}" - ${PYTHON_EXECUTABLE} "${CMAKE_CURRENT_SOURCE_DIR}/example/alpha_rips_persistence_bottleneck_distance.py" - -f ${CMAKE_SOURCE_DIR}/data/points/tore3D_300.off -t 0.15 -d 3) - endif(MPFR_FOUND) + # Bottleneck and Alpha + add_test(NAME alpha_rips_persistence_bottleneck_distance_py_test + WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR} + COMMAND ${CMAKE_COMMAND} -E env "PYTHONPATH=${CMAKE_CURRENT_BINARY_DIR}" + ${PYTHON_EXECUTABLE} "${CMAKE_CURRENT_SOURCE_DIR}/example/alpha_rips_persistence_bottleneck_distance.py" + -f ${CMAKE_SOURCE_DIR}/data/points/tore3D_300.off -t 0.15 -d 3) if(MATPLOTLIB_FOUND AND NUMPY_FOUND) # Tangential add_test(NAME tangential_complex_plain_homology_from_off_file_example_py_test @@ -308,23 +306,19 @@ endif(CGAL_FOUND) endif (NOT CGAL_VERSION VERSION_LESS 4.11.0) if (NOT CGAL_WITH_EIGEN3_VERSION VERSION_LESS 4.11.0) - if (MPFR_FOUND) - # Alpha - add_test(NAME alpha_complex_from_points_example_py_test - WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR} - COMMAND ${CMAKE_COMMAND} -E env "PYTHONPATH=${CMAKE_CURRENT_BINARY_DIR}" - ${PYTHON_EXECUTABLE} "${CMAKE_CURRENT_SOURCE_DIR}/example/alpha_complex_from_points_example.py") - - if(MATPLOTLIB_FOUND AND NUMPY_FOUND) - add_test(NAME alpha_complex_diagram_persistence_from_off_file_example_py_test - WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR} - COMMAND ${CMAKE_COMMAND} -E env "PYTHONPATH=${CMAKE_CURRENT_BINARY_DIR}" - ${PYTHON_EXECUTABLE} "${CMAKE_CURRENT_SOURCE_DIR}/example/alpha_complex_diagram_persistence_from_off_file_example.py" - --no-diagram -f ${CMAKE_SOURCE_DIR}/data/points/tore3D_300.off -a 0.6) - endif() - - add_gudhi_py_test(test_alpha_complex) - endif(MPFR_FOUND) + # Alpha + add_test(NAME alpha_complex_from_points_example_py_test + WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR} + COMMAND ${CMAKE_COMMAND} -E env "PYTHONPATH=${CMAKE_CURRENT_BINARY_DIR}" + ${PYTHON_EXECUTABLE} "${CMAKE_CURRENT_SOURCE_DIR}/example/alpha_complex_from_points_example.py") + if(MATPLOTLIB_FOUND AND NUMPY_FOUND) + add_test(NAME alpha_complex_diagram_persistence_from_off_file_example_py_test + WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR} + COMMAND ${CMAKE_COMMAND} -E env "PYTHONPATH=${CMAKE_CURRENT_BINARY_DIR}" + ${PYTHON_EXECUTABLE} "${CMAKE_CURRENT_SOURCE_DIR}/example/alpha_complex_diagram_persistence_from_off_file_example.py" + --no-diagram -f ${CMAKE_SOURCE_DIR}/data/points/tore3D_300.off -a 0.6) + endif() + add_gudhi_py_test(test_alpha_complex) endif (NOT CGAL_WITH_EIGEN3_VERSION VERSION_LESS 4.11.0) if (NOT CGAL_WITH_EIGEN3_VERSION VERSION_LESS 4.11.0) -- cgit v1.2.3 From 682f8c8cb18ba898a3d23a82fff454e862541aed Mon Sep 17 00:00:00 2001 From: Mathieu Carrière Date: Wed, 11 Dec 2019 13:48:26 -0500 Subject: Update src/python/doc/representations.rst Co-Authored-By: Vincent Rouvreau <10407034+VincentRouvreau@users.noreply.github.com> --- src/python/doc/representations.rst | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/python/doc/representations.rst b/src/python/doc/representations.rst index 409e97da..470b57bf 100644 --- a/src/python/doc/representations.rst +++ b/src/python/doc/representations.rst @@ -66,4 +66,6 @@ The output is: .. testoutput:: - [[1.02851895 2.05703791 2.57129739 1.54277843 0.89995409 1.92847304 2.95699199 3.08555686 0. 0.64282435 0. 0. 0.51425948 0. 0. 0. ]] + [[1.02851895 2.05703791 2.57129739 1.54277843 0.89995409 1.92847304 + 2.95699199 3.08555686 0. 0.64282435 0. 0. + 0.51425948 0. 0. 0. ]] -- cgit v1.2.3 From 363ae171ee7f45cf11d01653e4d4e9580117cfd0 Mon Sep 17 00:00:00 2001 From: mathieu Date: Wed, 11 Dec 2019 13:50:21 -0500 Subject: fixed landscape --- .../example/diagram_vectorizations_distances_kernels.py | 6 +++--- src/python/gudhi/representations/vector_methods.py | 14 +++++++------- 2 files changed, 10 insertions(+), 10 deletions(-) (limited to 'src') diff --git a/src/python/example/diagram_vectorizations_distances_kernels.py b/src/python/example/diagram_vectorizations_distances_kernels.py index 0ea4ba79..119072eb 100755 --- a/src/python/example/diagram_vectorizations_distances_kernels.py +++ b/src/python/example/diagram_vectorizations_distances_kernels.py @@ -26,9 +26,9 @@ plt.show() LS = Landscape(resolution=1000) L = LS.fit_transform(diags) -plt.plot(L[0][:998]) -plt.plot(L[0][998:2*998]) -plt.plot(L[0][2*998:3*998]) +plt.plot(L[0][:1000]) +plt.plot(L[0][1000:2000]) +plt.plot(L[0][2000:3000]) plt.title("Landscape") plt.show() diff --git a/src/python/gudhi/representations/vector_methods.py b/src/python/gudhi/representations/vector_methods.py index 083551a4..cd532275 100644 --- a/src/python/gudhi/representations/vector_methods.py +++ b/src/python/gudhi/representations/vector_methods.py @@ -129,19 +129,19 @@ class Landscape(BaseEstimator, TransformerMixin): diagram, num_pts_in_diag = X[i], X[i].shape[0] - ls = np.zeros([self.num_landscapes, self.resolution]) + ls = np.zeros([self.num_landscapes, self.resolution + self.nan_in_range.sum()]) events = [] - for j in range(self.resolution): + for j in range(self.resolution + self.nan_in_range.sum()): events.append([]) for j in range(num_pts_in_diag): [px,py] = diagram[j,:2] - min_idx = np.clip(np.ceil((px - self.sample_range[0]) / step_x).astype(int), 0, self.resolution) - mid_idx = np.clip(np.ceil((0.5*(py+px) - self.sample_range[0]) / step_x).astype(int), 0, self.resolution) - max_idx = np.clip(np.ceil((py - self.sample_range[0]) / step_x).astype(int), 0, self.resolution) + min_idx = np.clip(np.ceil((px - self.sample_range[0]) / step_x).astype(int), 0, self.resolution + self.nan_in_range.sum()) + mid_idx = np.clip(np.ceil((0.5*(py+px) - self.sample_range[0]) / step_x).astype(int), 0, self.resolution + self.nan_in_range.sum()) + max_idx = np.clip(np.ceil((py - self.sample_range[0]) / step_x).astype(int), 0, self.resolution + self.nan_in_range.sum()) - if min_idx < self.resolution and max_idx > 0: + if min_idx < self.resolution + self.nan_in_range.sum() and max_idx > 0: landscape_value = self.sample_range[0] + min_idx * step_x - px for k in range(min_idx, mid_idx): @@ -153,7 +153,7 @@ class Landscape(BaseEstimator, TransformerMixin): events[k].append(landscape_value) landscape_value -= step_x - for j in range(self.resolution): + for j in range(self.resolution + self.nan_in_range.sum()): events[j].sort(reverse=True) for k in range( min(self.num_landscapes, len(events[j])) ): ls[k,j] = events[j][k] -- cgit v1.2.3 From 9e75cc1832403f8ffec38fc3a4f6b1081fe4770e Mon Sep 17 00:00:00 2001 From: mathieu Date: Wed, 11 Dec 2019 13:57:15 -0500 Subject: update example --- src/python/doc/representations.rst | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/python/doc/representations.rst b/src/python/doc/representations.rst index 470b57bf..11dcbcf9 100644 --- a/src/python/doc/representations.rst +++ b/src/python/doc/representations.rst @@ -67,5 +67,6 @@ The output is: .. testoutput:: [[1.02851895 2.05703791 2.57129739 1.54277843 0.89995409 1.92847304 - 2.95699199 3.08555686 0. 0.64282435 0. 0. - 0.51425948 0. 0. 0. ]] + 2.95699199 3.08555686 2.05703791 1.02851895 0. 0.64282435 + 0. 0. 0.51425948 0. 0. 0. + 0.77138922 1.02851895]] -- cgit v1.2.3 From 2886885ff4cf1f134863de0fa97b64f824d67622 Mon Sep 17 00:00:00 2001 From: mathieu Date: Wed, 11 Dec 2019 15:30:45 -0500 Subject: cleanup --- src/python/gudhi/representations/vector_methods.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/python/gudhi/representations/vector_methods.py b/src/python/gudhi/representations/vector_methods.py index cd532275..9b280f68 100644 --- a/src/python/gudhi/representations/vector_methods.py +++ b/src/python/gudhi/representations/vector_methods.py @@ -95,6 +95,7 @@ class Landscape(BaseEstimator, TransformerMixin): sample_range ([double, double]): minimum and maximum of all piecewise-linear function domains, of the form [x_min, x_max] (default [numpy.nan, numpy.nan]). It is the interval on which samples will be drawn evenly. If one of the values is numpy.nan, it can be computed from the persistence diagrams with the fit() method. """ self.num_landscapes, self.resolution, self.sample_range = num_landscapes, resolution, sample_range + self.nan_in_range = np.isnan(np.array(self.sample_range)) def fit(self, X, y=None): """ @@ -104,8 +105,7 @@ class Landscape(BaseEstimator, TransformerMixin): X (list of n x 2 numpy arrays): input persistence diagrams. y (n x 1 array): persistence diagram labels (unused). """ - self.nan_in_range = np.isnan(np.array(self.sample_range)) - if np.isnan(np.array(self.sample_range)).any(): + if self.nan_in_range.any(): pre = DiagramScaler(use=True, scalers=[([0], MinMaxScaler()), ([1], MinMaxScaler())]).fit(X,y) [mx,my],[Mx,My] = [pre.scalers[0][1].data_min_[0], pre.scalers[1][1].data_min_[0]], [pre.scalers[0][1].data_max_[0], pre.scalers[1][1].data_max_[0]] self.sample_range = np.where(self.nan_in_range, np.array([mx, My]), np.array(self.sample_range)) -- cgit v1.2.3 From 7bd6907e577e22803fec179f652ecf0ec64dcb4a Mon Sep 17 00:00:00 2001 From: mathieu Date: Wed, 11 Dec 2019 15:38:00 -0500 Subject: cleanup for landscape resolution --- src/python/gudhi/representations/vector_methods.py | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) (limited to 'src') diff --git a/src/python/gudhi/representations/vector_methods.py b/src/python/gudhi/representations/vector_methods.py index 9b280f68..fe26dbe2 100644 --- a/src/python/gudhi/representations/vector_methods.py +++ b/src/python/gudhi/representations/vector_methods.py @@ -96,6 +96,7 @@ class Landscape(BaseEstimator, TransformerMixin): """ self.num_landscapes, self.resolution, self.sample_range = num_landscapes, resolution, sample_range self.nan_in_range = np.isnan(np.array(self.sample_range)) + self.new_resolution = self.resolution + self.nan_in_range.sum() def fit(self, X, y=None): """ @@ -122,26 +123,26 @@ class Landscape(BaseEstimator, TransformerMixin): numpy array with shape (number of diagrams) x (number of samples = **num_landscapes** x **resolution**): output persistence landscapes. """ num_diag, Xfit = len(X), [] - x_values = np.linspace(self.sample_range[0], self.sample_range[1], self.resolution + self.nan_in_range.sum()) + x_values = np.linspace(self.sample_range[0], self.sample_range[1], self.new_resolution) step_x = x_values[1] - x_values[0] for i in range(num_diag): diagram, num_pts_in_diag = X[i], X[i].shape[0] - ls = np.zeros([self.num_landscapes, self.resolution + self.nan_in_range.sum()]) + ls = np.zeros([self.num_landscapes, self.new_resolution]) events = [] - for j in range(self.resolution + self.nan_in_range.sum()): + for j in range(self.new_resolution): events.append([]) for j in range(num_pts_in_diag): [px,py] = diagram[j,:2] - min_idx = np.clip(np.ceil((px - self.sample_range[0]) / step_x).astype(int), 0, self.resolution + self.nan_in_range.sum()) - mid_idx = np.clip(np.ceil((0.5*(py+px) - self.sample_range[0]) / step_x).astype(int), 0, self.resolution + self.nan_in_range.sum()) - max_idx = np.clip(np.ceil((py - self.sample_range[0]) / step_x).astype(int), 0, self.resolution + self.nan_in_range.sum()) + min_idx = np.clip(np.ceil((px - self.sample_range[0]) / step_x).astype(int), 0, self.new_resolution) + mid_idx = np.clip(np.ceil((0.5*(py+px) - self.sample_range[0]) / step_x).astype(int), 0, self.new_resolution) + max_idx = np.clip(np.ceil((py - self.sample_range[0]) / step_x).astype(int), 0, self.new_resolution) - if min_idx < self.resolution + self.nan_in_range.sum() and max_idx > 0: + if min_idx < self.new_resolution and max_idx > 0: landscape_value = self.sample_range[0] + min_idx * step_x - px for k in range(min_idx, mid_idx): @@ -153,7 +154,7 @@ class Landscape(BaseEstimator, TransformerMixin): events[k].append(landscape_value) landscape_value -= step_x - for j in range(self.resolution + self.nan_in_range.sum()): + for j in range(self.new_resolution): events[j].sort(reverse=True) for k in range( min(self.num_landscapes, len(events[j])) ): ls[k,j] = events[j][k] -- cgit v1.2.3 From 7f426f5a85051676ffb6f8952689bd400ddcc10b Mon Sep 17 00:00:00 2001 From: Vincent Rouvreau <10407034+VincentRouvreau@users.noreply.github.com> Date: Thu, 12 Dec 2019 09:40:35 +0100 Subject: Code review: Typo in src/common/doc/installation.h Co-Authored-By: Marc Glisse --- src/common/doc/installation.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src') diff --git a/src/common/doc/installation.h b/src/common/doc/installation.h index c4ca10d1..d70a2efa 100644 --- a/src/common/doc/installation.h +++ b/src/common/doc/installation.h @@ -34,7 +34,7 @@ make \endverbatim * To test your build, run the following command in a terminal: * \verbatim make test \endverbatim * `make test` is using Ctest<\a> (CMake test driver - * program). If some of the tests are failing, plend send us the result of the following command: + * program). If some of the tests are failing, please send us the result of the following command: * \verbatim ctest --output-on-failure \endverbatim * * \subsection documentationgeneration Documentation -- cgit v1.2.3 From a1b6e5a034bc698b02d3c93e1707cab5622eaea6 Mon Sep 17 00:00:00 2001 From: Vincent Rouvreau <10407034+VincentRouvreau@users.noreply.github.com> Date: Thu, 12 Dec 2019 09:41:04 +0100 Subject: Code review: typo in src/python/doc/installation.rst Co-Authored-By: Marc Glisse --- src/python/doc/installation.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src') diff --git a/src/python/doc/installation.rst b/src/python/doc/installation.rst index 3553ae51..c3ddc017 100644 --- a/src/python/doc/installation.rst +++ b/src/python/doc/installation.rst @@ -100,7 +100,7 @@ following command in a terminal: `make test` is using `Ctest `_ (CMake test -driver program). If some of the tests are failing, plend send us the result of +driver program). If some of the tests are failing, please send us the result of the following command: .. code-block:: bash -- cgit v1.2.3 From 38f0ff98cf6da1e882b6b44fc3ed7b3d310fb91f Mon Sep 17 00:00:00 2001 From: ROUVREAU Vincent Date: Thu, 12 Dec 2019 10:00:10 +0100 Subject: Doc review: use ctest directly and provide options suggestions --- src/python/doc/installation.rst | 22 ++++++++++------------ 1 file changed, 10 insertions(+), 12 deletions(-) (limited to 'src') diff --git a/src/python/doc/installation.rst b/src/python/doc/installation.rst index 3553ae51..50a697c7 100644 --- a/src/python/doc/installation.rst +++ b/src/python/doc/installation.rst @@ -83,32 +83,30 @@ Or install it definitely in your Python packages folder: .. code-block:: bash - python setup.py install --prefix /home/gudhi # Install in /home/gudhi directory + python setup.py install --prefix /home/gudhi # Install in /home/gudhi directory Test suites =========== -To test your build, `py.test `_ is optional. Run the -following command in a terminal: +To test your build, `py.test `_ is required. Run the +following `Ctest `_ +(CMake test driver program) command in a terminal: .. code-block:: bash cd /path-to-gudhi/build/python # For windows, you have to set PYTHONPATH environment variable export PYTHONPATH='$PYTHONPATH:/path-to-gudhi/build/python' - make test + ctest -`make test` is using -`Ctest `_ (CMake test -driver program). If some of the tests are failing, plend send us the result of -the following command: +.. note:: + + One can use :code:`ctest` specific options in the python directory: .. code-block:: bash - cd /path-to-gudhi/build/python - # For windows, you have to set PYTHONPATH environment variable - export PYTHONPATH='$PYTHONPATH:/path-to-gudhi/build/python' - ctest --output-on-failure + # Launch tests in parallel on 8 cores and set failing tests in verbose mode + ctest -j 8 --output-on-failure Debugging issues ================ -- cgit v1.2.3 From b884a620824a9d707cec82c9dddf7ab236263b95 Mon Sep 17 00:00:00 2001 From: ROUVREAU Vincent Date: Thu, 12 Dec 2019 10:04:59 +0100 Subject: conflict resolution --- src/python/doc/installation.rst | 7 ------- 1 file changed, 7 deletions(-) (limited to 'src') diff --git a/src/python/doc/installation.rst b/src/python/doc/installation.rst index 14000ecf..50a697c7 100644 --- a/src/python/doc/installation.rst +++ b/src/python/doc/installation.rst @@ -99,16 +99,9 @@ following `Ctest `_ export PYTHONPATH='$PYTHONPATH:/path-to-gudhi/build/python' ctest -<<<<<<< HEAD .. note:: One can use :code:`ctest` specific options in the python directory: -======= -`make test` is using -`Ctest `_ (CMake test -driver program). If some of the tests are failing, please send us the result of -the following command: ->>>>>>> a1b6e5a034bc698b02d3c93e1707cab5622eaea6 .. code-block:: bash -- cgit v1.2.3 From 3f2eb763d4cdbf895a95c89ee938940962a9d938 Mon Sep 17 00:00:00 2001 From: ROUVREAU Vincent Date: Fri, 13 Dec 2019 11:32:38 +0100 Subject: Add a more representative image for python persistence representations --- src/Persistence_representations/doc/sklearn-tda.png | Bin 0 -> 388075 bytes src/python/doc/representations_sum.inc | 2 +- 2 files changed, 1 insertion(+), 1 deletion(-) create mode 100644 src/Persistence_representations/doc/sklearn-tda.png (limited to 'src') diff --git a/src/Persistence_representations/doc/sklearn-tda.png b/src/Persistence_representations/doc/sklearn-tda.png new file mode 100644 index 00000000..f0ff07f4 Binary files /dev/null and b/src/Persistence_representations/doc/sklearn-tda.png differ diff --git a/src/python/doc/representations_sum.inc b/src/python/doc/representations_sum.inc index 7b167a17..d4fe37f6 100644 --- a/src/python/doc/representations_sum.inc +++ b/src/python/doc/representations_sum.inc @@ -3,7 +3,7 @@ +------------------------------------------------------------------+----------------------------------------------------------------+-----------------------------------------------+ | .. figure:: | Vectorizations, distances and kernels that work on persistence | :Author: Mathieu Carrière | - | ../../doc/Persistence_representations/average_landscape.png | diagrams, compatible with scikit-learn. | | + | ../../doc/Persistence_representations/sklearn-tda.png | diagrams, compatible with scikit-learn. | | | | | :Introduced in: GUDHI 3.1.0 | | | | | | | | :Copyright: MIT | -- cgit v1.2.3 From 03c577e3b2b4cea844d64c7aeb68b9f73db4602a Mon Sep 17 00:00:00 2001 From: ROUVREAU Vincent Date: Fri, 13 Dec 2019 12:05:06 +0100 Subject: Move image in python img instead of C++ one --- src/Persistence_representations/doc/sklearn-tda.png | Bin 388075 -> 0 bytes src/python/doc/img/sklearn-tda.png | Bin 0 -> 388075 bytes src/python/doc/representations_sum.inc | 2 +- 3 files changed, 1 insertion(+), 1 deletion(-) delete mode 100644 src/Persistence_representations/doc/sklearn-tda.png create mode 100644 src/python/doc/img/sklearn-tda.png (limited to 'src') diff --git a/src/Persistence_representations/doc/sklearn-tda.png b/src/Persistence_representations/doc/sklearn-tda.png deleted file mode 100644 index f0ff07f4..00000000 Binary files a/src/Persistence_representations/doc/sklearn-tda.png and /dev/null differ diff --git a/src/python/doc/img/sklearn-tda.png b/src/python/doc/img/sklearn-tda.png new file mode 100644 index 00000000..f0ff07f4 Binary files /dev/null and b/src/python/doc/img/sklearn-tda.png differ diff --git a/src/python/doc/representations_sum.inc b/src/python/doc/representations_sum.inc index d4fe37f6..700828f1 100644 --- a/src/python/doc/representations_sum.inc +++ b/src/python/doc/representations_sum.inc @@ -3,7 +3,7 @@ +------------------------------------------------------------------+----------------------------------------------------------------+-----------------------------------------------+ | .. figure:: | Vectorizations, distances and kernels that work on persistence | :Author: Mathieu Carrière | - | ../../doc/Persistence_representations/sklearn-tda.png | diagrams, compatible with scikit-learn. | | + | img/sklearn-tda.png | diagrams, compatible with scikit-learn. | | | | | :Introduced in: GUDHI 3.1.0 | | | | | | | | :Copyright: MIT | -- cgit v1.2.3 From 7b2ac5ccd53ec8988854e5ac2c3c20176e0c24ed Mon Sep 17 00:00:00 2001 From: ROUVREAU Vincent Date: Mon, 16 Dec 2019 10:47:34 +0100 Subject: Fix MPFR when CGAL is not header only --- src/python/CMakeLists.txt | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'src') diff --git a/src/python/CMakeLists.txt b/src/python/CMakeLists.txt index 1704f491..b558d4c4 100644 --- a/src/python/CMakeLists.txt +++ b/src/python/CMakeLists.txt @@ -169,6 +169,10 @@ if(PYTHONINTERP_FOUND) add_gudhi_debug_info("MPFR_LIBRARIES = ${MPFR_LIBRARIES}") set(GUDHI_PYTHON_EXTRA_COMPILE_ARGS "${GUDHI_PYTHON_EXTRA_COMPILE_ARGS}'-DCGAL_USE_MPFR', ") add_GUDHI_PYTHON_lib("${MPFR_LIBRARIES}") + # In case CGAL is not header only, all MPFR variables are set except MPFR_LIBRARIES_DIR - Just set it + if(NOT MPFR_LIBRARIES_DIR) + get_filename_component(MPFR_LIBRARIES_DIR ${MPFR_LIBRARIES} PATH) + endif(NOT MPFR_LIBRARIES_DIR) set(GUDHI_PYTHON_LIBRARY_DIRS "${GUDHI_PYTHON_LIBRARY_DIRS}'${MPFR_LIBRARIES_DIR}', ") message("** Add mpfr ${MPFR_LIBRARIES}") endif(MPFR_FOUND) -- cgit v1.2.3 From 490a5774601e344bb732de5eab2a8cf6d5a7e81f Mon Sep 17 00:00:00 2001 From: ROUVREAU Vincent Date: Mon, 16 Dec 2019 13:38:58 +0100 Subject: Rollback exact version mechanism --- src/python/gudhi/alpha_complex.pyx | 11 +++-------- src/python/include/Alpha_complex_interface.h | 4 ++-- src/python/test/test_alpha_complex.py | 12 +++--------- 3 files changed, 8 insertions(+), 19 deletions(-) (limited to 'src') diff --git a/src/python/gudhi/alpha_complex.pyx b/src/python/gudhi/alpha_complex.pyx index bfb9783a..24e36bea 100644 --- a/src/python/gudhi/alpha_complex.pyx +++ b/src/python/gudhi/alpha_complex.pyx @@ -28,7 +28,7 @@ cdef extern from "Alpha_complex_interface.h" namespace "Gudhi": # bool from_file is a workaround for cython to find the correct signature Alpha_complex_interface(string off_file, bool from_file) vector[double] get_point(int vertex) - void create_simplex_tree(Simplex_tree_interface_full_featured* simplex_tree, double max_alpha_square, bool exact_version) + void create_simplex_tree(Simplex_tree_interface_full_featured* simplex_tree, double max_alpha_square) # AlphaComplex python interface cdef class AlphaComplex: @@ -99,22 +99,17 @@ cdef class AlphaComplex: cdef vector[double] point = self.thisptr.get_point(vertex) return point - def create_simplex_tree(self, max_alpha_square = float('inf'), - exact_version = False): + def create_simplex_tree(self, max_alpha_square = float('inf')): """ :param max_alpha_square: The maximum alpha square threshold the simplices shall not exceed. Default is set to infinity, and there is very little point using anything else since it does not save time. :type max_alpha_square: float - :param exact_version: :code:`EXACT` computation version if set. - Default is false which means :code:`SAFE` version is used. - :type exact_version: bool :returns: A simplex tree created from the Delaunay Triangulation. :rtype: SimplexTree """ stree = SimplexTree() cdef intptr_t stree_int_ptr=stree.thisptr - self.thisptr.create_simplex_tree(stree_int_ptr, - max_alpha_square, exact_version) + self.thisptr.create_simplex_tree(stree_int_ptr, max_alpha_square) return stree diff --git a/src/python/include/Alpha_complex_interface.h b/src/python/include/Alpha_complex_interface.h index a7621f2b..e9bbadb0 100644 --- a/src/python/include/Alpha_complex_interface.h +++ b/src/python/include/Alpha_complex_interface.h @@ -60,8 +60,8 @@ class Alpha_complex_interface { return vd; } - void create_simplex_tree(Simplex_tree_interface<>* simplex_tree, double max_alpha_square, bool exact_version) { - alpha_complex_->create_complex(*simplex_tree, max_alpha_square, exact_version); + void create_simplex_tree(Simplex_tree_interface<>* simplex_tree, double max_alpha_square) { + alpha_complex_->create_complex(*simplex_tree, max_alpha_square); simplex_tree->initialize_filtration(); } diff --git a/src/python/test/test_alpha_complex.py b/src/python/test/test_alpha_complex.py index ab84daaa..9b27fff2 100755 --- a/src/python/test/test_alpha_complex.py +++ b/src/python/test/test_alpha_complex.py @@ -93,7 +93,7 @@ def test_filtered_alpha(): assert simplex_tree.get_star([0]) == [([0], 0.0), ([0, 1], 0.25), ([0, 2], 0.25)] assert simplex_tree.get_cofaces([0], 1) == [([0, 1], 0.25), ([0, 2], 0.25)] -def alpha_persistence_comparison(exact_version): +def test_safe_alpha_persistence_comparison(): #generate periodic signal time = np.arange(0, 10, 1) signal = [math.sin(x) for x in time] @@ -106,10 +106,10 @@ def alpha_persistence_comparison(exact_version): #build alpha complex and simplex tree alpha_complex1 = AlphaComplex(points=embedding1) - simplex_tree1 = alpha_complex1.create_simplex_tree(exact_version = exact_version) + simplex_tree1 = alpha_complex1.create_simplex_tree() alpha_complex2 = AlphaComplex(points=embedding2) - simplex_tree2 = alpha_complex2.create_simplex_tree(exact_version = exact_version) + simplex_tree2 = alpha_complex2.create_simplex_tree() diag1 = simplex_tree1.persistence() diag2 = simplex_tree2.persistence() @@ -117,9 +117,3 @@ def alpha_persistence_comparison(exact_version): for (first_p, second_p) in itertools.zip_longest(diag1, diag2): assert first_p[0] == pytest.approx(second_p[0]) assert first_p[1] == pytest.approx(second_p[1]) - -def test_exact_alpha_version(): - alpha_persistence_comparison(exact_version = True) - -def test_safe_alpha_version(): - alpha_persistence_comparison(exact_version = False) -- cgit v1.2.3 From b5510c0c362cd2bef79d82fd9809e654aea73957 Mon Sep 17 00:00:00 2001 From: ROUVREAU Vincent Date: Mon, 16 Dec 2019 23:10:24 +0100 Subject: Add numpy ndarray to init a cubical and a periodic one --- src/python/doc/cubical_complex_user.rst | 4 +-- src/python/gudhi/cubical_complex.pyx | 27 ++++++++++++++----- src/python/gudhi/periodic_cubical_complex.pyx | 39 ++++++++++++++++++++++----- src/python/test/test_cubical_complex.py | 33 ++++++++++++++++++++--- 4 files changed, 84 insertions(+), 19 deletions(-) (limited to 'src') diff --git a/src/python/doc/cubical_complex_user.rst b/src/python/doc/cubical_complex_user.rst index b13b500e..21806038 100644 --- a/src/python/doc/cubical_complex_user.rst +++ b/src/python/doc/cubical_complex_user.rst @@ -142,8 +142,8 @@ Or it can be defined as follows: .. testcode:: from gudhi import PeriodicCubicalComplex as pcc - periodic_cc = pcc(dimensions=[3,3], - top_dimensional_cells= [0, 0, 0, 0, 1, 0, 0, 0, 0], + from numpy import array as np_array + periodic_cc = pcc(numpy_array = np_array([[0, 0, 0], [0, 1, 0], [0, 0, 0]]), periodic_dimensions=[True, False]) result_str = 'Periodic cubical complex is of dimension ' + repr(periodic_cc.dimension()) + ' - ' + \ repr(periodic_cc.num_simplices()) + ' simplices.' diff --git a/src/python/gudhi/cubical_complex.pyx b/src/python/gudhi/cubical_complex.pyx index 011c407c..2ec0146a 100644 --- a/src/python/gudhi/cubical_complex.pyx +++ b/src/python/gudhi/cubical_complex.pyx @@ -5,7 +5,7 @@ from libcpp.string cimport string from libcpp cimport bool import os -from numpy import array as np_array +import numpy as np # This file is part of the Gudhi Library - https://gudhi.inria.fr/ - which is released under MIT. # See file LICENSE or go to https://gudhi.inria.fr/licensing/ for full license details. @@ -47,7 +47,7 @@ cdef class CubicalComplex: # Fake constructor that does nothing but documenting the constructor def __init__(self, dimensions=None, top_dimensional_cells=None, - perseus_file=''): + numpy_array=None, perseus_file=''): """CubicalComplex constructor from dimensions and top_dimensional_cells or from a Perseus-style file name. @@ -58,16 +58,31 @@ cdef class CubicalComplex: Or + :param numpy_array: Filtration values in a d-array. + :type numpy_array: numpy ndarray + + Or + :param perseus_file: A Perseus-style file name. :type perseus_file: string """ # The real cython constructor def __cinit__(self, dimensions=None, top_dimensional_cells=None, - perseus_file=''): - if (dimensions is not None) and (top_dimensional_cells is not None) and (perseus_file == ''): + numpy_array=None, perseus_file=''): + if ((dimensions is not None) and (top_dimensional_cells is not None) + and (numpy_array is None) and (perseus_file == '')): self.thisptr = new Bitmap_cubical_complex_base_interface(dimensions, top_dimensional_cells) - elif (dimensions is None) and (top_dimensional_cells is None) and (perseus_file != ''): + elif ((dimensions is None) and (top_dimensional_cells is None) + and (numpy_array is not None) and (perseus_file == '')): + if isinstance(numpy_array, np.ndarray): + dimensions = list(numpy_array.shape) + top_dimensional_cells = numpy_array.flatten().tolist() + self.thisptr = new Bitmap_cubical_complex_base_interface(dimensions, top_dimensional_cells) + else: + print("numpy_array is not an instance of ndarray. It is a " + type(numpy_array)) + elif ((dimensions is None) and (top_dimensional_cells is None) + and (numpy_array is None) and (perseus_file != '')): if os.path.isfile(perseus_file): self.thisptr = new Bitmap_cubical_complex_base_interface(str.encode(perseus_file)) else: @@ -184,4 +199,4 @@ cdef class CubicalComplex: else: print("intervals_in_dim function requires persistence function" " to be launched first.") - return np_array(intervals_result) + return np.array(intervals_result) diff --git a/src/python/gudhi/periodic_cubical_complex.pyx b/src/python/gudhi/periodic_cubical_complex.pyx index c89055db..8318b7d3 100644 --- a/src/python/gudhi/periodic_cubical_complex.pyx +++ b/src/python/gudhi/periodic_cubical_complex.pyx @@ -5,7 +5,7 @@ from libcpp.string cimport string from libcpp cimport bool import os -from numpy import array as np_array +import numpy as np # This file is part of the Gudhi Library - https://gudhi.inria.fr/ - which is released under MIT. # See file LICENSE or go to https://gudhi.inria.fr/licensing/ for full license details. @@ -47,7 +47,7 @@ cdef class PeriodicCubicalComplex: # Fake constructor that does nothing but documenting the constructor def __init__(self, dimensions=None, top_dimensional_cells=None, - periodic_dimensions=None, perseus_file=''): + numpy_array=None, periodic_dimensions=None, perseus_file=''): """PeriodicCubicalComplex constructor from dimensions and top_dimensional_cells or from a Perseus-style file name. @@ -60,16 +60,41 @@ cdef class PeriodicCubicalComplex: Or + :param numpy_array: Filtration values in a d-array. + :type numpy_array: numpy ndarray + :param periodic_dimensions: A list of top dimensional cells periodicity value. + :type periodic_dimensions: list of boolean + + Or + :param perseus_file: A Perseus-style file name. :type perseus_file: string """ # The real cython constructor def __cinit__(self, dimensions=None, top_dimensional_cells=None, - periodic_dimensions=None, perseus_file=''): - if (dimensions is not None) and (top_dimensional_cells is not None) and (periodic_dimensions is not None) and (perseus_file == ''): - self.thisptr = new Periodic_cubical_complex_base_interface(dimensions, top_dimensional_cells, periodic_dimensions) - elif (dimensions is None) and (top_dimensional_cells is None) and (periodic_dimensions is None) and (perseus_file != ''): + numpy_array=None, periodic_dimensions=None, + perseus_file=''): + if ((dimensions is not None) and (top_dimensional_cells is not None) + and (numpy_array is None) and (periodic_dimensions is not None) + and (perseus_file == '')): + self.thisptr = new Periodic_cubical_complex_base_interface(dimensions, + top_dimensional_cells, + periodic_dimensions) + elif ((dimensions is None) and (top_dimensional_cells is None) + and (numpy_array is not None) and (periodic_dimensions is not None) + and (perseus_file == '')): + if isinstance(numpy_array, np.ndarray): + dimensions = list(numpy_array.shape) + top_dimensional_cells = numpy_array.flatten().tolist() + self.thisptr = new Periodic_cubical_complex_base_interface(dimensions, + top_dimensional_cells, + periodic_dimensions) + else: + print("numpy_array is not an instance of ndarray. It is a " + type(numpy_array)) + elif ((dimensions is None) and (top_dimensional_cells is None) + and (numpy_array is None) and (periodic_dimensions is None) + and (perseus_file != '')): if os.path.isfile(perseus_file): self.thisptr = new Periodic_cubical_complex_base_interface(str.encode(perseus_file)) else: @@ -186,4 +211,4 @@ cdef class PeriodicCubicalComplex: else: print("intervals_in_dim function requires persistence function" " to be launched first.") - return np_array(intervals_result) + return np.array(intervals_result) diff --git a/src/python/test/test_cubical_complex.py b/src/python/test/test_cubical_complex.py index 68f54fbe..a37d7821 100755 --- a/src/python/test/test_cubical_complex.py +++ b/src/python/test/test_cubical_complex.py @@ -1,4 +1,5 @@ from gudhi import CubicalComplex +import numpy as np """ This file is part of the Gudhi Library - https://gudhi.inria.fr/ - which is released under MIT. See file LICENSE or go to https://gudhi.inria.fr/licensing/ for full license details. @@ -56,7 +57,7 @@ def test_dimension_or_perseus_file_constructor(): assert cub.__is_persistence_defined() == False -def test_dimension_simple_constructor(): +def simple_constructor(cub): cub = CubicalComplex( dimensions=[3, 3], top_dimensional_cells=[1, 2, 3, 4, 5, 6, 7, 8, 9] ) @@ -67,12 +68,22 @@ def test_dimension_simple_constructor(): assert cub.betti_numbers() == [1, 0, 0] assert cub.persistent_betti_numbers(0, 1000) == [0, 0, 0] - -def test_user_case_simple_constructor(): +def test_simple_constructor_from_top_cells(): cub = CubicalComplex( dimensions=[3, 3], - top_dimensional_cells=[float("inf"), 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 0.0], + top_dimensional_cells=[1, 2, 3, 4, 5, 6, 7, 8, 9], ) + simple_constructor(cub) + +def test_simple_constructor_from_numpy_array(): + cub = CubicalComplex( + numpy_array=np.array([[1, 2, 3], + [4, 5, 6], + [7, 8, 9]]) + ) + simple_constructor(cub) + +def user_case_simple_constructor(cub): assert cub.__is_defined() == True assert cub.__is_persistence_defined() == False assert cub.persistence() == [(1, (0.0, 1.0)), (0, (0.0, float("inf")))] @@ -83,6 +94,20 @@ def test_user_case_simple_constructor(): ) assert other_cub.persistence() == [(1, (0.0, 1.0)), (0, (0.0, float("inf")))] +def test_user_case_simple_constructor_from_top_cells(): + cub = CubicalComplex( + dimensions=[3, 3], + top_dimensional_cells=[float("inf"), 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 0.0], + ) + user_case_simple_constructor(cub) + +def test_user_case_simple_constructor_from_numpy_array(): + cub = CubicalComplex( + numpy_array=np.array([[float("inf"), 0.0, 0.0], + [0.0, 1.0, 0.0], + [0.0, 0.0, 0.0]]) + ) + user_case_simple_constructor(cub) def test_dimension_file_constructor(): # Create test file -- cgit v1.2.3 From b63be266effe24646823acc59fe397021bb13a3e Mon Sep 17 00:00:00 2001 From: ROUVREAU Vincent Date: Wed, 18 Dec 2019 10:44:17 +0100 Subject: Reuse top_dimensional_cells instead of numpy_array argument to create a cubical --- src/python/doc/cubical_complex_user.rst | 2 +- src/python/gudhi/cubical_complex.pyx | 25 ++++++++++--------- src/python/gudhi/periodic_cubical_complex.pyx | 35 +++++++++++++-------------- src/python/test/test_cubical_complex.py | 12 ++++----- 4 files changed, 37 insertions(+), 37 deletions(-) (limited to 'src') diff --git a/src/python/doc/cubical_complex_user.rst b/src/python/doc/cubical_complex_user.rst index 21806038..d56c8789 100644 --- a/src/python/doc/cubical_complex_user.rst +++ b/src/python/doc/cubical_complex_user.rst @@ -143,7 +143,7 @@ Or it can be defined as follows: from gudhi import PeriodicCubicalComplex as pcc from numpy import array as np_array - periodic_cc = pcc(numpy_array = np_array([[0, 0, 0], [0, 1, 0], [0, 0, 0]]), + periodic_cc = pcc(top_dimensional_cells = np_array([[0, 0, 0], [0, 1, 0], [0, 0, 0]]), periodic_dimensions=[True, False]) result_str = 'Periodic cubical complex is of dimension ' + repr(periodic_cc.dimension()) + ' - ' + \ repr(periodic_cc.num_simplices()) + ' simplices.' diff --git a/src/python/gudhi/cubical_complex.pyx b/src/python/gudhi/cubical_complex.pyx index 2ec0146a..1aa1164c 100644 --- a/src/python/gudhi/cubical_complex.pyx +++ b/src/python/gudhi/cubical_complex.pyx @@ -47,7 +47,7 @@ cdef class CubicalComplex: # Fake constructor that does nothing but documenting the constructor def __init__(self, dimensions=None, top_dimensional_cells=None, - numpy_array=None, perseus_file=''): + perseus_file=''): """CubicalComplex constructor from dimensions and top_dimensional_cells or from a Perseus-style file name. @@ -58,8 +58,9 @@ cdef class CubicalComplex: Or - :param numpy_array: Filtration values in a d-array. - :type numpy_array: numpy ndarray + :param top_dimensional_cells: A multidimensional array of cells + filtration values. + :type top_dimensional_cells: numpy ndarray Or @@ -69,20 +70,20 @@ cdef class CubicalComplex: # The real cython constructor def __cinit__(self, dimensions=None, top_dimensional_cells=None, - numpy_array=None, perseus_file=''): + perseus_file=''): if ((dimensions is not None) and (top_dimensional_cells is not None) - and (numpy_array is None) and (perseus_file == '')): + and (perseus_file == '')): self.thisptr = new Bitmap_cubical_complex_base_interface(dimensions, top_dimensional_cells) - elif ((dimensions is None) and (top_dimensional_cells is None) - and (numpy_array is not None) and (perseus_file == '')): - if isinstance(numpy_array, np.ndarray): - dimensions = list(numpy_array.shape) - top_dimensional_cells = numpy_array.flatten().tolist() + elif ((dimensions is None) and (top_dimensional_cells is not None) + and (perseus_file == '')): + if isinstance(top_dimensional_cells, np.ndarray): + dimensions = list(top_dimensional_cells.shape) + top_dimensional_cells = top_dimensional_cells.flatten().tolist() self.thisptr = new Bitmap_cubical_complex_base_interface(dimensions, top_dimensional_cells) else: - print("numpy_array is not an instance of ndarray. It is a " + type(numpy_array)) + print("top_dimensional_cells is not an instance of ndarray. It is a " + type(top_dimensional_cells)) elif ((dimensions is None) and (top_dimensional_cells is None) - and (numpy_array is None) and (perseus_file != '')): + and (perseus_file != '')): if os.path.isfile(perseus_file): self.thisptr = new Bitmap_cubical_complex_base_interface(str.encode(perseus_file)) else: diff --git a/src/python/gudhi/periodic_cubical_complex.pyx b/src/python/gudhi/periodic_cubical_complex.pyx index 8318b7d3..e623058a 100644 --- a/src/python/gudhi/periodic_cubical_complex.pyx +++ b/src/python/gudhi/periodic_cubical_complex.pyx @@ -47,7 +47,7 @@ cdef class PeriodicCubicalComplex: # Fake constructor that does nothing but documenting the constructor def __init__(self, dimensions=None, top_dimensional_cells=None, - numpy_array=None, periodic_dimensions=None, perseus_file=''): + periodic_dimensions=None, perseus_file=''): """PeriodicCubicalComplex constructor from dimensions and top_dimensional_cells or from a Perseus-style file name. @@ -60,8 +60,9 @@ cdef class PeriodicCubicalComplex: Or - :param numpy_array: Filtration values in a d-array. - :type numpy_array: numpy ndarray + :param top_dimensional_cells: A multidimensional array of cells + filtration values. + :type top_dimensional_cells: numpy ndarray :param periodic_dimensions: A list of top dimensional cells periodicity value. :type periodic_dimensions: list of boolean @@ -73,35 +74,33 @@ cdef class PeriodicCubicalComplex: # The real cython constructor def __cinit__(self, dimensions=None, top_dimensional_cells=None, - numpy_array=None, periodic_dimensions=None, - perseus_file=''): + periodic_dimensions=None, perseus_file=''): if ((dimensions is not None) and (top_dimensional_cells is not None) - and (numpy_array is None) and (periodic_dimensions is not None) - and (perseus_file == '')): + and (periodic_dimensions is not None) and (perseus_file == '')): self.thisptr = new Periodic_cubical_complex_base_interface(dimensions, top_dimensional_cells, periodic_dimensions) - elif ((dimensions is None) and (top_dimensional_cells is None) - and (numpy_array is not None) and (periodic_dimensions is not None) - and (perseus_file == '')): - if isinstance(numpy_array, np.ndarray): - dimensions = list(numpy_array.shape) - top_dimensional_cells = numpy_array.flatten().tolist() + elif ((dimensions is None) and (top_dimensional_cells is not None) + and (periodic_dimensions is not None) and (perseus_file == '')): + if isinstance(top_dimensional_cells, np.ndarray): + dimensions = list(top_dimensional_cells.shape) + top_dimensional_cells = top_dimensional_cells.flatten().tolist() self.thisptr = new Periodic_cubical_complex_base_interface(dimensions, top_dimensional_cells, periodic_dimensions) else: - print("numpy_array is not an instance of ndarray. It is a " + type(numpy_array)) + print("top_dimensional_cells is not an instance of ndarray. It is a " + type(top_dimensional_cells)) elif ((dimensions is None) and (top_dimensional_cells is None) - and (numpy_array is None) and (periodic_dimensions is None) - and (perseus_file != '')): + and (periodic_dimensions is None) and (perseus_file != '')): if os.path.isfile(perseus_file): self.thisptr = new Periodic_cubical_complex_base_interface(str.encode(perseus_file)) else: print("file " + perseus_file + " not found.") else: - print("CubicalComplex can be constructed from dimensions and " - "top_dimensional_cells or from a Perseus-style file name.") + print("CubicalComplex can be constructed from dimensions, " + "top_dimensional_cells and periodic_dimensions, or from " + "top_dimensional_cells and periodic_dimensions or from " + "a Perseus-style file name.") def __dealloc__(self): if self.thisptr != NULL: diff --git a/src/python/test/test_cubical_complex.py b/src/python/test/test_cubical_complex.py index a37d7821..6d4e0309 100755 --- a/src/python/test/test_cubical_complex.py +++ b/src/python/test/test_cubical_complex.py @@ -77,9 +77,9 @@ def test_simple_constructor_from_top_cells(): def test_simple_constructor_from_numpy_array(): cub = CubicalComplex( - numpy_array=np.array([[1, 2, 3], - [4, 5, 6], - [7, 8, 9]]) + top_dimensional_cells=np.array([[1, 2, 3], + [4, 5, 6], + [7, 8, 9]]) ) simple_constructor(cub) @@ -103,9 +103,9 @@ def test_user_case_simple_constructor_from_top_cells(): def test_user_case_simple_constructor_from_numpy_array(): cub = CubicalComplex( - numpy_array=np.array([[float("inf"), 0.0, 0.0], - [0.0, 1.0, 0.0], - [0.0, 0.0, 0.0]]) + top_dimensional_cells=np.array([[float("inf"), 0.0, 0.0], + [0.0, 1.0, 0.0], + [0.0, 0.0, 0.0]]) ) user_case_simple_constructor(cub) -- cgit v1.2.3 From 32a9c5e4df26e59f5f376e54c05c7bec92012cff Mon Sep 17 00:00:00 2001 From: ROUVREAU Vincent Date: Wed, 18 Dec 2019 10:57:31 +0100 Subject: use ravel instead of flatten (that makes a copy) and no more converting to a list --- src/python/gudhi/cubical_complex.pyx | 4 ++-- src/python/gudhi/periodic_cubical_complex.pyx | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) (limited to 'src') diff --git a/src/python/gudhi/cubical_complex.pyx b/src/python/gudhi/cubical_complex.pyx index 1aa1164c..756a9dab 100644 --- a/src/python/gudhi/cubical_complex.pyx +++ b/src/python/gudhi/cubical_complex.pyx @@ -77,8 +77,8 @@ cdef class CubicalComplex: elif ((dimensions is None) and (top_dimensional_cells is not None) and (perseus_file == '')): if isinstance(top_dimensional_cells, np.ndarray): - dimensions = list(top_dimensional_cells.shape) - top_dimensional_cells = top_dimensional_cells.flatten().tolist() + dimensions = top_dimensional_cells.shape + top_dimensional_cells = top_dimensional_cells.ravel(order='C') self.thisptr = new Bitmap_cubical_complex_base_interface(dimensions, top_dimensional_cells) else: print("top_dimensional_cells is not an instance of ndarray. It is a " + type(top_dimensional_cells)) diff --git a/src/python/gudhi/periodic_cubical_complex.pyx b/src/python/gudhi/periodic_cubical_complex.pyx index e623058a..c3d64123 100644 --- a/src/python/gudhi/periodic_cubical_complex.pyx +++ b/src/python/gudhi/periodic_cubical_complex.pyx @@ -83,8 +83,8 @@ cdef class PeriodicCubicalComplex: elif ((dimensions is None) and (top_dimensional_cells is not None) and (periodic_dimensions is not None) and (perseus_file == '')): if isinstance(top_dimensional_cells, np.ndarray): - dimensions = list(top_dimensional_cells.shape) - top_dimensional_cells = top_dimensional_cells.flatten().tolist() + dimensions = top_dimensional_cells.shape + top_dimensional_cells = top_dimensional_cells.ravel(order='C') self.thisptr = new Periodic_cubical_complex_base_interface(dimensions, top_dimensional_cells, periodic_dimensions) -- cgit v1.2.3 From ba406558f707f55b638be92d197ae3039595b29a Mon Sep 17 00:00:00 2001 From: ROUVREAU Vincent Date: Fri, 20 Dec 2019 16:57:36 +0100 Subject: Fix dimension cell linearization and test connected sublevel sets --- src/python/gudhi/cubical_complex.pyx | 2 +- src/python/gudhi/periodic_cubical_complex.pyx | 2 +- src/python/test/test_cubical_complex.py | 28 ++++++++++++++++++++++++++- 3 files changed, 29 insertions(+), 3 deletions(-) (limited to 'src') diff --git a/src/python/gudhi/cubical_complex.pyx b/src/python/gudhi/cubical_complex.pyx index 756a9dab..04b22921 100644 --- a/src/python/gudhi/cubical_complex.pyx +++ b/src/python/gudhi/cubical_complex.pyx @@ -78,7 +78,7 @@ cdef class CubicalComplex: and (perseus_file == '')): if isinstance(top_dimensional_cells, np.ndarray): dimensions = top_dimensional_cells.shape - top_dimensional_cells = top_dimensional_cells.ravel(order='C') + top_dimensional_cells = top_dimensional_cells.ravel(order='F') self.thisptr = new Bitmap_cubical_complex_base_interface(dimensions, top_dimensional_cells) else: print("top_dimensional_cells is not an instance of ndarray. It is a " + type(top_dimensional_cells)) diff --git a/src/python/gudhi/periodic_cubical_complex.pyx b/src/python/gudhi/periodic_cubical_complex.pyx index c3d64123..1d6f1e59 100644 --- a/src/python/gudhi/periodic_cubical_complex.pyx +++ b/src/python/gudhi/periodic_cubical_complex.pyx @@ -84,7 +84,7 @@ cdef class PeriodicCubicalComplex: and (periodic_dimensions is not None) and (perseus_file == '')): if isinstance(top_dimensional_cells, np.ndarray): dimensions = top_dimensional_cells.shape - top_dimensional_cells = top_dimensional_cells.ravel(order='C') + top_dimensional_cells = top_dimensional_cells.ravel(order='F') self.thisptr = new Periodic_cubical_complex_base_interface(dimensions, top_dimensional_cells, periodic_dimensions) diff --git a/src/python/test/test_cubical_complex.py b/src/python/test/test_cubical_complex.py index 6d4e0309..121da12a 100755 --- a/src/python/test/test_cubical_complex.py +++ b/src/python/test/test_cubical_complex.py @@ -1,4 +1,4 @@ -from gudhi import CubicalComplex +from gudhi import CubicalComplex, PeriodicCubicalComplex import numpy as np """ This file is part of the Gudhi Library - https://gudhi.inria.fr/ - which is released under MIT. @@ -121,3 +121,29 @@ def test_dimension_file_constructor(): assert cub.__is_persistence_defined() == True assert cub.betti_numbers() == [1, 0, 0] assert cub.persistent_betti_numbers(0, 1000) == [1, 0, 0] + +def test_connected_sublevel_sets(): + array_cells = np.array([[3, 3], [2, 2], [4, 4]]) + linear_cells = [3, 3, 2, 2, 4, 4] + dimensions = [2, 3] + periodic_dimensions = [False, False] + # with a numpy array version + cub = CubicalComplex(top_dimensional_cells = array_cells) + assert cub.persistence() == [(0, (2.0, float("inf")))] + assert cub.betti_numbers() == [1, 0, 0] + # with vector of dimensions + cub = CubicalComplex(dimensions = dimensions, + top_dimensional_cells = linear_cells) + assert cub.persistence() == [(0, (2.0, float("inf")))] + assert cub.betti_numbers() == [1, 0, 0] + # periodic with a numpy array version + cub = PeriodicCubicalComplex(top_dimensional_cells = array_cells, + periodic_dimensions = periodic_dimensions) + assert cub.persistence() == [(0, (2.0, float("inf")))] + assert cub.betti_numbers() == [1, 0, 0] + # periodic with vector of dimensions + cub = PeriodicCubicalComplex(dimensions = dimensions, + top_dimensional_cells = linear_cells, + periodic_dimensions = periodic_dimensions) + assert cub.persistence() == [(0, (2.0, float("inf")))] + assert cub.betti_numbers() == [1, 0, 0] -- cgit v1.2.3 From d316f8ca62a3335d530784a71b4110bc2219c2dd Mon Sep 17 00:00:00 2001 From: Marc Glisse Date: Fri, 3 Jan 2020 22:02:48 +0100 Subject: Remove implicit this capture in [=] --- src/Nerve_GIC/include/gudhi/GIC.h | 2 +- src/Simplex_tree/include/gudhi/Simplex_tree.h | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/Nerve_GIC/include/gudhi/GIC.h b/src/Nerve_GIC/include/gudhi/GIC.h index b8169c59..a47d6889 100644 --- a/src/Nerve_GIC/include/gudhi/GIC.h +++ b/src/Nerve_GIC/include/gudhi/GIC.h @@ -707,7 +707,7 @@ class Cover_complex { // Sort points according to function values std::vector points(n); for (int i = 0; i < n; i++) points[i] = i; - std::sort(points.begin(), points.end(), [=](const int & p1, const int & p2){return (this->func[p1] < this->func[p2]);}); + std::sort(points.begin(), points.end(), [this](int p1, int p2){return (this->func[p1] < this->func[p2]);}); int id = 0; int pos = 0; diff --git a/src/Simplex_tree/include/gudhi/Simplex_tree.h b/src/Simplex_tree/include/gudhi/Simplex_tree.h index fafdb01c..76608008 100644 --- a/src/Simplex_tree/include/gudhi/Simplex_tree.h +++ b/src/Simplex_tree/include/gudhi/Simplex_tree.h @@ -1378,7 +1378,7 @@ class Simplex_tree { private: bool rec_prune_above_filtration(Siblings* sib, Filtration_value filt) { auto&& list = sib->members(); - auto last = std::remove_if(list.begin(), list.end(), [=](Dit_value_t& simplex) { + auto last = std::remove_if(list.begin(), list.end(), [this,filt](Dit_value_t& simplex) { if (simplex.second.filtration() <= filt) return false; if (has_children(&simplex)) rec_delete(simplex.second.children()); // dimension may need to be lowered -- cgit v1.2.3 From bcc49c54943e20b117a3a83579d94f6c1b0efd04 Mon Sep 17 00:00:00 2001 From: Marc Glisse Date: Sat, 4 Jan 2020 12:50:14 +0100 Subject: Link the doc for subsampling & point file readers, some reorg --- src/python/doc/diagram_readers_ref.rst | 11 ++++++++++ src/python/doc/index.rst | 40 ++++++++++++++++------------------ src/python/doc/point_cloud.rst | 22 +++++++++++++++++++ src/python/doc/point_cloud_sum.inc | 15 +++++++++++++ src/python/doc/reader_utils_ref.rst | 15 ------------- src/python/gudhi/off_reader.pyx | 2 +- src/python/gudhi/reader_utils.pyx | 6 ++--- src/python/gudhi/subsampling.pyx | 12 +++++----- 8 files changed, 77 insertions(+), 46 deletions(-) create mode 100644 src/python/doc/diagram_readers_ref.rst create mode 100644 src/python/doc/point_cloud.rst create mode 100644 src/python/doc/point_cloud_sum.inc delete mode 100644 src/python/doc/reader_utils_ref.rst (limited to 'src') diff --git a/src/python/doc/diagram_readers_ref.rst b/src/python/doc/diagram_readers_ref.rst new file mode 100644 index 00000000..c79daf9c --- /dev/null +++ b/src/python/doc/diagram_readers_ref.rst @@ -0,0 +1,11 @@ +:orphan: + +.. To get rid of WARNING: document isn't included in any toctree + +================================ +Diagram readers reference manual +================================ + +.. autofunction:: gudhi.read_persistence_intervals_grouped_by_dimension + +.. autofunction:: gudhi.read_persistence_intervals_in_dimension diff --git a/src/python/doc/index.rst b/src/python/doc/index.rst index c36a578f..9513deb0 100644 --- a/src/python/doc/index.rst +++ b/src/python/doc/index.rst @@ -6,8 +6,8 @@ GUDHI Python modules documentation :alt: Gudhi banner :figclass: align-center -Complexes -********* +Data structures for cell complexes +********************************** Cubical complexes ================= @@ -17,18 +17,26 @@ Cubical complexes Simplicial complexes ==================== +Simplex tree +------------ + +.. include:: simplex_tree_sum.inc + +Filtrations and reconstructions +******************************* + Alpha complex -------------- +============= .. include:: alpha_complex_sum.inc Rips complex ------------- +============ .. include:: rips_complex_sum.inc Witness complex ---------------- +=============== .. include:: witness_complex_sum.inc @@ -37,16 +45,10 @@ Cover complexes .. include:: nerve_gic_complex_sum.inc -Data structures and basic operations -************************************ - -Data structures -=============== - -Simplex tree ------------- +Tangential complex +================== -.. include:: simplex_tree_sum.inc +.. include:: tangential_complex_sum.inc Topological descriptors computation *********************************** @@ -56,14 +58,10 @@ Persistence cohomology .. include:: persistent_cohomology_sum.inc -Manifold reconstruction -*********************** - -Tangential complex -================== - -.. include:: tangential_complex_sum.inc +Point cloud utilities +********************* +.. include:: point_cloud_sum.inc Topological descriptors tools ***************************** diff --git a/src/python/doc/point_cloud.rst b/src/python/doc/point_cloud.rst new file mode 100644 index 00000000..6a74d253 --- /dev/null +++ b/src/python/doc/point_cloud.rst @@ -0,0 +1,22 @@ +:orphan: + +.. To get rid of WARNING: document isn't included in any toctree + +============================ +Point cloud utilities manual +============================ + +File Readers +------------ + +.. autofunction:: gudhi.read_off + +.. autofunction:: gudhi.read_lower_triangular_matrix_from_csv_file + +Subsampling +----------- + +.. automodule:: gudhi.subsampling + :members: + :special-members: + :show-inheritance: diff --git a/src/python/doc/point_cloud_sum.inc b/src/python/doc/point_cloud_sum.inc new file mode 100644 index 00000000..cefcf1c8 --- /dev/null +++ b/src/python/doc/point_cloud_sum.inc @@ -0,0 +1,15 @@ +.. table:: + :widths: 30 50 20 + + +----------------------------------------------------------------+------------------------------------------------------------------------+-----------------------------------------------------------------------------------------------------------------------------+ + | :math:`(x_1, x_2, \ldots, x_d)` | Utilities to process point clouds: read from file, subsample, etc. | :Author: Vincent Rouvreau | + | :math:`(y_1, y_2, \ldots, y_d)` | | | + | | | :Introduced in: GUDHI 2.0.0 | + | | | | + | | | :Copyright: MIT (`GPL v3 `_) | + | | Parts of this package require CGAL. | | + | | | :Requires: `Eigen `__ :math:`\geq` 3.1.0 and `CGAL `__ :math:`\geq` 4.11.0 | + | | | | + +----------------------------------------------------------------+------------------------------------------------------------------------+-----------------------------------------------------------------------------------------------------------------------------+ + | * :doc:`point_cloud` | + +----------------------------------------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ diff --git a/src/python/doc/reader_utils_ref.rst b/src/python/doc/reader_utils_ref.rst deleted file mode 100644 index f3ecebad..00000000 --- a/src/python/doc/reader_utils_ref.rst +++ /dev/null @@ -1,15 +0,0 @@ -:orphan: - -.. To get rid of WARNING: document isn't included in any toctree - -============================= -Reader utils reference manual -============================= - -.. autofunction:: gudhi.read_off - -.. autofunction:: gudhi.read_lower_triangular_matrix_from_csv_file - -.. autofunction:: gudhi.read_persistence_intervals_grouped_by_dimension - -.. autofunction:: gudhi.read_persistence_intervals_in_dimension diff --git a/src/python/gudhi/off_reader.pyx b/src/python/gudhi/off_reader.pyx index 225e981c..e45356be 100644 --- a/src/python/gudhi/off_reader.pyx +++ b/src/python/gudhi/off_reader.pyx @@ -26,7 +26,7 @@ def read_off(off_file=''): :type off_file: string :returns: The point set. - :rtype: vector[vector[double]] + :rtype: list(list(float)) """ if off_file: if os.path.isfile(off_file): diff --git a/src/python/gudhi/reader_utils.pyx b/src/python/gudhi/reader_utils.pyx index 6994c4f9..5a756e4b 100644 --- a/src/python/gudhi/reader_utils.pyx +++ b/src/python/gudhi/reader_utils.pyx @@ -34,7 +34,7 @@ def read_lower_triangular_matrix_from_csv_file(csv_file='', separator=';'): :type separator: char :returns: The lower triangular matrix. - :rtype: vector[vector[double]] + :rtype: list(list(float)) """ if csv_file: if path.isfile(csv_file): @@ -45,7 +45,7 @@ def read_lower_triangular_matrix_from_csv_file(csv_file='', separator=';'): def read_persistence_intervals_grouped_by_dimension(persistence_file=''): """Reads a file containing persistence intervals. Each line might contain 2, 3 or 4 values: [[field] dimension] birth death - The return value is an `map[dim, vector[pair[birth, death]]]` + The return value is a `dict(dim, list(tuple(birth, death)))` where `dim` is an `int`, `birth` a `double`, and `death` a `double`. Note: the function does not check that birth <= death. @@ -53,7 +53,7 @@ def read_persistence_intervals_grouped_by_dimension(persistence_file=''): :type persistence_file: string :returns: The persistence pairs grouped by dimension. - :rtype: map[int, vector[pair[double, double]]] + :rtype: dict(int, list(tuple(float, float))) """ if persistence_file: if path.isfile(persistence_file): diff --git a/src/python/gudhi/subsampling.pyx b/src/python/gudhi/subsampling.pyx index e0cd1348..04f66219 100644 --- a/src/python/gudhi/subsampling.pyx +++ b/src/python/gudhi/subsampling.pyx @@ -33,7 +33,7 @@ def choose_n_farthest_points(points=None, off_file='', nb_points=0, starting_poi The iteration starts with the landmark `starting point`. :param points: The input point set. - :type points: vector[vector[double]]. + :type points: list(list(float)). Or @@ -47,7 +47,7 @@ def choose_n_farthest_points(points=None, off_file='', nb_points=0, starting_poi index is chosen randomly. :type starting_point: unsigned. :returns: The subsample point set. - :rtype: vector[vector[double]] + :rtype: list(list(float)). """ if off_file: if os.path.isfile(off_file): @@ -74,7 +74,7 @@ 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. - :type points: vector[vector[double]]. + :type points: list(list(float)). Or @@ -84,7 +84,7 @@ def pick_n_random_points(points=None, off_file='', nb_points=0): :param nb_points: Number of points of the subsample. :type nb_points: unsigned. :returns: The subsample point set. - :rtype: vector[vector[double]] + :rtype: list(list(float)) """ if off_file: if os.path.isfile(off_file): @@ -103,7 +103,7 @@ def sparsify_point_set(points=None, off_file='', min_squared_dist=0.0): between any two points is greater than or equal to min_squared_dist. :param points: The input point set. - :type points: vector[vector[double]]. + :type points: list(list(float)). Or @@ -114,7 +114,7 @@ def sparsify_point_set(points=None, off_file='', min_squared_dist=0.0): points. :type min_squared_dist: float. :returns: The subsample point set. - :rtype: vector[vector[double]] + :rtype: list(list(float)) """ if off_file: if os.path.isfile(off_file): -- cgit v1.2.3 From d832d3585bf47c48f28d861469730fc47f4956c8 Mon Sep 17 00:00:00 2001 From: ROUVREAU Vincent Date: Tue, 7 Jan 2020 12:24:45 +0100 Subject: Code review: less strict with numpy arrays for cubical ctors. Also accept lists --- src/python/gudhi/cubical_complex.pyx | 14 +++++++------- src/python/gudhi/periodic_cubical_complex.pyx | 18 +++++++++--------- 2 files changed, 16 insertions(+), 16 deletions(-) (limited to 'src') diff --git a/src/python/gudhi/cubical_complex.pyx b/src/python/gudhi/cubical_complex.pyx index 04b22921..63911478 100644 --- a/src/python/gudhi/cubical_complex.pyx +++ b/src/python/gudhi/cubical_complex.pyx @@ -60,7 +60,7 @@ cdef class CubicalComplex: :param top_dimensional_cells: A multidimensional array of cells filtration values. - :type top_dimensional_cells: numpy ndarray + :type top_dimensional_cells: numpy ndarray or list of list of double Or @@ -76,12 +76,12 @@ cdef class CubicalComplex: self.thisptr = new Bitmap_cubical_complex_base_interface(dimensions, top_dimensional_cells) elif ((dimensions is None) and (top_dimensional_cells is not None) and (perseus_file == '')): - if isinstance(top_dimensional_cells, np.ndarray): - dimensions = top_dimensional_cells.shape - top_dimensional_cells = top_dimensional_cells.ravel(order='F') - self.thisptr = new Bitmap_cubical_complex_base_interface(dimensions, top_dimensional_cells) - else: - print("top_dimensional_cells is not an instance of ndarray. It is a " + type(top_dimensional_cells)) + top_dimensional_cells = np.array(top_dimensional_cells, + copy = False, + order = 'F') + dimensions = top_dimensional_cells.shape + top_dimensional_cells = top_dimensional_cells.ravel(order='F') + self.thisptr = new Bitmap_cubical_complex_base_interface(dimensions, top_dimensional_cells) elif ((dimensions is None) and (top_dimensional_cells is None) and (perseus_file != '')): if os.path.isfile(perseus_file): diff --git a/src/python/gudhi/periodic_cubical_complex.pyx b/src/python/gudhi/periodic_cubical_complex.pyx index 1d6f1e59..3c0f529b 100644 --- a/src/python/gudhi/periodic_cubical_complex.pyx +++ b/src/python/gudhi/periodic_cubical_complex.pyx @@ -62,7 +62,7 @@ cdef class PeriodicCubicalComplex: :param top_dimensional_cells: A multidimensional array of cells filtration values. - :type top_dimensional_cells: numpy ndarray + :type top_dimensional_cells: numpy ndarray or list of list of double :param periodic_dimensions: A list of top dimensional cells periodicity value. :type periodic_dimensions: list of boolean @@ -82,14 +82,14 @@ cdef class PeriodicCubicalComplex: periodic_dimensions) elif ((dimensions is None) and (top_dimensional_cells is not None) and (periodic_dimensions is not None) and (perseus_file == '')): - if isinstance(top_dimensional_cells, np.ndarray): - dimensions = top_dimensional_cells.shape - top_dimensional_cells = top_dimensional_cells.ravel(order='F') - self.thisptr = new Periodic_cubical_complex_base_interface(dimensions, - top_dimensional_cells, - periodic_dimensions) - else: - print("top_dimensional_cells is not an instance of ndarray. It is a " + type(top_dimensional_cells)) + top_dimensional_cells = np.array(top_dimensional_cells, + copy = False, + order = 'F') + dimensions = top_dimensional_cells.shape + top_dimensional_cells = top_dimensional_cells.ravel(order='F') + self.thisptr = new Periodic_cubical_complex_base_interface(dimensions, + top_dimensional_cells, + periodic_dimensions) elif ((dimensions is None) and (top_dimensional_cells is None) and (periodic_dimensions is None) and (perseus_file != '')): if os.path.isfile(perseus_file): -- cgit v1.2.3 From 82b556c554a60e3b05942ba53300463dc00b8538 Mon Sep 17 00:00:00 2001 From: ROUVREAU Vincent Date: Tue, 7 Jan 2020 12:27:19 +0100 Subject: Code review: use list in examples instead of numpy arrays --- src/python/doc/cubical_complex_user.rst | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) (limited to 'src') diff --git a/src/python/doc/cubical_complex_user.rst b/src/python/doc/cubical_complex_user.rst index d56c8789..6fdcd9df 100644 --- a/src/python/doc/cubical_complex_user.rst +++ b/src/python/doc/cubical_complex_user.rst @@ -142,9 +142,7 @@ Or it can be defined as follows: .. testcode:: from gudhi import PeriodicCubicalComplex as pcc - from numpy import array as np_array - periodic_cc = pcc(top_dimensional_cells = np_array([[0, 0, 0], [0, 1, 0], [0, 0, 0]]), - periodic_dimensions=[True, False]) + periodic_cc = pcc(top_dimensional_cells = [[0, 0, 0], [0, 1, 0], [0, 0, 0]] result_str = 'Periodic cubical complex is of dimension ' + repr(periodic_cc.dimension()) + ' - ' + \ repr(periodic_cc.num_simplices()) + ' simplices.' print(result_str) -- cgit v1.2.3 From 44484a8f9242e45ead34cb49226df015c4b6c19a Mon Sep 17 00:00:00 2001 From: ROUVREAU Vincent Date: Tue, 7 Jan 2020 12:27:43 +0100 Subject: Code review: use list in examples instead of numpy arrays --- src/python/doc/cubical_complex_user.rst | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/python/doc/cubical_complex_user.rst b/src/python/doc/cubical_complex_user.rst index 6fdcd9df..56cf0170 100644 --- a/src/python/doc/cubical_complex_user.rst +++ b/src/python/doc/cubical_complex_user.rst @@ -142,7 +142,8 @@ Or it can be defined as follows: .. testcode:: from gudhi import PeriodicCubicalComplex as pcc - periodic_cc = pcc(top_dimensional_cells = [[0, 0, 0], [0, 1, 0], [0, 0, 0]] + periodic_cc = pcc(top_dimensional_cells = [[0, 0, 0], [0, 1, 0], [0, 0, 0]], + periodic_dimensions=[True, False]) result_str = 'Periodic cubical complex is of dimension ' + repr(periodic_cc.dimension()) + ' - ' + \ repr(periodic_cc.num_simplices()) + ' simplices.' print(result_str) -- cgit v1.2.3 From 6a7a7b6d6d81946dd903f68f525389ab2fd51f71 Mon Sep 17 00:00:00 2001 From: ROUVREAU Vincent Date: Tue, 7 Jan 2020 13:31:18 +0100 Subject: Doc review: anything convertible to a numpy ndarray --- src/python/gudhi/cubical_complex.pyx | 2 +- src/python/gudhi/periodic_cubical_complex.pyx | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/python/gudhi/cubical_complex.pyx b/src/python/gudhi/cubical_complex.pyx index 63911478..b7047d4f 100644 --- a/src/python/gudhi/cubical_complex.pyx +++ b/src/python/gudhi/cubical_complex.pyx @@ -60,7 +60,7 @@ cdef class CubicalComplex: :param top_dimensional_cells: A multidimensional array of cells filtration values. - :type top_dimensional_cells: numpy ndarray or list of list of double + :type top_dimensional_cells: anything convertible to a numpy ndarray Or diff --git a/src/python/gudhi/periodic_cubical_complex.pyx b/src/python/gudhi/periodic_cubical_complex.pyx index 3c0f529b..eb96ab5f 100644 --- a/src/python/gudhi/periodic_cubical_complex.pyx +++ b/src/python/gudhi/periodic_cubical_complex.pyx @@ -62,7 +62,7 @@ cdef class PeriodicCubicalComplex: :param top_dimensional_cells: A multidimensional array of cells filtration values. - :type top_dimensional_cells: numpy ndarray or list of list of double + :type top_dimensional_cells: anything convertible to a numpy ndarray :param periodic_dimensions: A list of top dimensional cells periodicity value. :type periodic_dimensions: list of boolean -- cgit v1.2.3 From 98b4aa0026a7208230d396bc9fb28c7a3b72be6d Mon Sep 17 00:00:00 2001 From: tlacombe Date: Tue, 7 Jan 2020 18:06:13 +0100 Subject: changing variable name from (p, q) to (q, internal_p). Must also be done in tests files and doc --- src/python/gudhi/wasserstein.py | 46 ++++++++++++++++++++--------------------- 1 file changed, 23 insertions(+), 23 deletions(-) (limited to 'src') diff --git a/src/python/gudhi/wasserstein.py b/src/python/gudhi/wasserstein.py index d8a3104c..2acf93d6 100644 --- a/src/python/gudhi/wasserstein.py +++ b/src/python/gudhi/wasserstein.py @@ -23,26 +23,26 @@ def _proj_on_diag(X): return np.array([Z , Z]).T -def _build_dist_matrix(X, Y, p=2., q=2.): +def _build_dist_matrix(X, Y, q=2., internal_p=2.): ''' :param X: (n x 2) numpy.array encoding the (points of the) first diagram. :param Y: (m x 2) numpy.array encoding the second diagram. - :param q: Ground metric (i.e. norm l_q). - :param p: exponent for the Wasserstein metric. + :param internal_p: Ground metric (i.e. norm l_q). + :param q: exponent for the Wasserstein metric. :returns: (n+1) x (m+1) np.array encoding the cost matrix C. For 1 <= i <= n, 1 <= j <= m, C[i,j] encodes the distance between X[i] and Y[j], while C[i, m+1] (resp. C[n+1, j]) encodes the distance (to the p) between X[i] (resp Y[j]) and its orthogonal proj onto the diagonal. note also that C[n+1, m+1] = 0 (it costs nothing to move from the diagonal to the diagonal). ''' Xdiag = _proj_on_diag(X) Ydiag = _proj_on_diag(Y) - if np.isinf(q): - C = sc.cdist(X,Y, metric='chebyshev')**p - Cxd = np.linalg.norm(X - Xdiag, ord=q, axis=1)**p - Cdy = np.linalg.norm(Y - Ydiag, ord=q, axis=1)**p + if np.isinf(internal_p): + C = sc.cdist(X,Y, metric='chebyshev')**q + Cxd = np.linalg.norm(X - Xdiag, ord=internal_p, axis=1)**q + Cdy = np.linalg.norm(Y - Ydiag, ord=internal_p, axis=1)**q else: - C = sc.cdist(X,Y, metric='minkowski', p=q)**p - Cxd = np.linalg.norm(X - Xdiag, ord=q, axis=1)**p - Cdy = np.linalg.norm(Y - Ydiag, ord=q, axis=1)**p + C = sc.cdist(X,Y, metric='minkowski', p=internal_p)**q + Cxd = np.linalg.norm(X - Xdiag, ord=internal_p, axis=1)**q + Cdy = np.linalg.norm(Y - Ydiag, ord=internal_p, axis=1)**q Cf = np.hstack((C, Cxd[:,None])) Cdy = np.append(Cdy, 0) @@ -51,24 +51,24 @@ def _build_dist_matrix(X, Y, p=2., q=2.): return Cf -def _perstot(X, p, q): +def _perstot(X, q, internal_p): ''' :param X: (n x 2) numpy.array (points of a given diagram). - :param q: Ground metric on the (upper-half) plane (i.e. norm l_q in R^2); Default value is 2 (Euclidean norm). - :param p: exponent for Wasserstein; Default value is 2. + :param internal_p: Ground metric on the (upper-half) plane (i.e. norm l_p in R^2); Default value is 2 (Euclidean norm). + :param q: exponent for Wasserstein; Default value is 2. :returns: float, the total persistence of the diagram (that is, its distance to the empty diagram). ''' Xdiag = _proj_on_diag(X) - return (np.sum(np.linalg.norm(X - Xdiag, ord=q, axis=1)**p))**(1./p) + return (np.sum(np.linalg.norm(X - Xdiag, ord=internal_p, axis=1)**q))**(1./q) -def wasserstein_distance(X, Y, p=2., q=2.): +def wasserstein_distance(X, Y, q=2., internal_p=2.): ''' :param X: (n x 2) numpy.array encoding the (finite points of the) first diagram. Must not contain essential points (i.e. with infinite coordinate). :param Y: (m x 2) numpy.array encoding the second diagram. - :param q: Ground metric on the (upper-half) plane (i.e. norm l_q in R^2); Default value is 2 (euclidean norm). - :param p: exponent for Wasserstein; Default value is 2. - :returns: the p-Wasserstein distance (1 <= p < infinity) with respect to the q-norm as ground metric. + :param internal_p: Ground metric on the (upper-half) plane (i.e. norm l_p in R^2); Default value is 2 (euclidean norm). + :param q: exponent for Wasserstein; Default value is 2. + :returns: the q-Wasserstein distance (1 <= q < infinity) with respect to the internal_p-norm as ground metric. :rtype: float ''' n = len(X) @@ -79,20 +79,20 @@ def wasserstein_distance(X, Y, p=2., q=2.): if Y.size == 0: return 0. else: - return _perstot(Y, p, q) + return _perstot(Y, q, internal_p) elif Y.size == 0: - return _perstot(X, p, q) + return _perstot(X, q, internal_p) - M = _build_dist_matrix(X, Y, p=p, q=q) + M = _build_dist_matrix(X, Y, q=q, internal_p=internal_p) a = np.full(n+1, 1. / (n + m) ) # weight vector of the input diagram. Uniform here. a[-1] = a[-1] * m # normalized so that we have a probability measure, required by POT b = np.full(m+1, 1. / (n + m) ) # weight vector of the input diagram. Uniform here. b[-1] = b[-1] * n # so that we have a probability measure, required by POT # Comptuation of the otcost using the ot.emd2 library. - # Note: it is the squared Wasserstein distance. + # Note: it is the Wasserstein distance to the power q. # The default numItermax=100000 is not sufficient for some examples with 5000 points, what is a good value? ot_cost = (n+m) * ot.emd2(a, b, M, numItermax=2000000) - return ot_cost ** (1./p) + return ot_cost ** (1./q) -- cgit v1.2.3 From f3dc8e802d2a6226532f92a252f96ddbd7b6a411 Mon Sep 17 00:00:00 2001 From: tlacombe Date: Wed, 8 Jan 2020 09:41:31 +0100 Subject: changing variable name in test files --- src/python/test/test_wasserstein_distance.py | 34 ++++++++++++++-------------- 1 file changed, 17 insertions(+), 17 deletions(-) (limited to 'src') diff --git a/src/python/test/test_wasserstein_distance.py b/src/python/test/test_wasserstein_distance.py index a6bf9901..40112c1b 100755 --- a/src/python/test/test_wasserstein_distance.py +++ b/src/python/test/test_wasserstein_distance.py @@ -23,26 +23,26 @@ def test_basic_wasserstein(): diag4 = np.array([[0, 3], [4, 8]]) emptydiag = np.array([[]]) - assert wasserstein_distance(emptydiag, emptydiag, q=2., p=1.) == 0. - assert wasserstein_distance(emptydiag, emptydiag, q=np.inf, p=1.) == 0. - assert wasserstein_distance(emptydiag, emptydiag, q=np.inf, p=2.) == 0. - assert wasserstein_distance(emptydiag, emptydiag, q=2., p=2.) == 0. + assert wasserstein_distance(emptydiag, emptydiag, internal_p=2., q=1.) == 0. + assert wasserstein_distance(emptydiag, emptydiag, internal_p=np.inf, q=1.) == 0. + assert wasserstein_distance(emptydiag, emptydiag, internal_p=np.inf, q=2.) == 0. + assert wasserstein_distance(emptydiag, emptydiag, internal_p=2., q=2.) == 0. - assert wasserstein_distance(diag3, emptydiag, q=np.inf, p=1.) == 2. - assert wasserstein_distance(diag3, emptydiag, q=1., p=1.) == 4. + assert wasserstein_distance(diag3, emptydiag, internal_p=np.inf, q=1.) == 2. + assert wasserstein_distance(diag3, emptydiag, internal_p=1., q=1.) == 4. - assert wasserstein_distance(diag4, emptydiag, q=1., p=2.) == 5. # thank you Pythagorician triplets - assert wasserstein_distance(diag4, emptydiag, q=np.inf, p=2.) == 2.5 - assert wasserstein_distance(diag4, emptydiag, q=2., p=2.) == 3.5355339059327378 + assert wasserstein_distance(diag4, emptydiag, internal_p=1., q=2.) == 5. # thank you Pythagorician triplets + assert wasserstein_distance(diag4, emptydiag, internal_p=np.inf, q=2.) == 2.5 + assert wasserstein_distance(diag4, emptydiag, internal_p=2., q=2.) == 3.5355339059327378 - assert wasserstein_distance(diag1, diag2, q=2., p=1.) == 1.4453593023967701 - assert wasserstein_distance(diag1, diag2, q=2.35, p=1.74) == 0.9772734057168739 + assert wasserstein_distance(diag1, diag2, internal_p=2., q=1.) == 1.4453593023967701 + assert wasserstein_distance(diag1, diag2, internal_p=2.35, q=1.74) == 0.9772734057168739 - assert wasserstein_distance(diag1, emptydiag, q=2.35, p=1.7863) == 3.141592214572228 + assert wasserstein_distance(diag1, emptydiag, internal_p=2.35, q=1.7863) == 3.141592214572228 - assert wasserstein_distance(diag3, diag4, q=1., p=1.) == 3. - assert wasserstein_distance(diag3, diag4, q=np.inf, p=1.) == 3. # no diag matching here - assert wasserstein_distance(diag3, diag4, q=np.inf, p=2.) == np.sqrt(5) - assert wasserstein_distance(diag3, diag4, q=1., p=2.) == np.sqrt(5) - assert wasserstein_distance(diag3, diag4, q=4.5, p=2.) == np.sqrt(5) + assert wasserstein_distance(diag3, diag4, internal_p=1., q=1.) == 3. + assert wasserstein_distance(diag3, diag4, internal_p=np.inf, q=1.) == 3. # no diag matching here + assert wasserstein_distance(diag3, diag4, internal_p=np.inf, q=2.) == np.sqrt(5) + assert wasserstein_distance(diag3, diag4, internal_p=1., q=2.) == np.sqrt(5) + assert wasserstein_distance(diag3, diag4, internal_p=4.5, q=2.) == np.sqrt(5) -- cgit v1.2.3 From 4bcdd64974900302f420fb08435275cc8faa794a Mon Sep 17 00:00:00 2001 From: tlacombe Date: Wed, 8 Jan 2020 09:44:36 +0100 Subject: update variable name in doc --- src/python/doc/wasserstein_distance_sum.inc | 6 +++--- src/python/doc/wasserstein_distance_user.rst | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) (limited to 'src') diff --git a/src/python/doc/wasserstein_distance_sum.inc b/src/python/doc/wasserstein_distance_sum.inc index ffd4d312..a97f428d 100644 --- a/src/python/doc/wasserstein_distance_sum.inc +++ b/src/python/doc/wasserstein_distance_sum.inc @@ -2,12 +2,12 @@ :widths: 30 50 20 +-----------------------------------------------------------------+----------------------------------------------------------------------+------------------------------------------------------------------+ - | .. figure:: | The p-Wasserstein distance measures the similarity between two | :Author: Theo Lacombe | + | .. figure:: | The q-Wasserstein distance measures the similarity between two | :Author: Theo Lacombe | | ../../doc/Bottleneck_distance/perturb_pd.png | persistence diagrams. It's the minimum value c that can be achieved | | | :figclass: align-center | by a perfect matching between the points of the two diagrams (+ all | :Introduced in: GUDHI 3.1.0 | | | diagonal points), where the value of a matching is defined as the | | - | Wasserstein distance is the p-th root of the sum of the | p-th root of the sum of all edge lengths to the power p. Edge lengths| :Copyright: MIT | - | edge lengths to the power p. | are measured in norm q, for :math:`1 \leq q \leq \infty`. | | + | Wasserstein distance is the q-th root of the sum of the | q-th root of the sum of all edge lengths to the power q. Edge lengths| :Copyright: MIT | + | edge lengths to the power q. | are measured in norm p, for :math:`1 \leq p \leq \infty`. | | | | | :Requires: Python Optimal Transport (POT) :math:`\geq` 0.5.1 | +-----------------------------------------------------------------+----------------------------------------------------------------------+------------------------------------------------------------------+ | * :doc:`wasserstein_distance_user` | | diff --git a/src/python/doc/wasserstein_distance_user.rst b/src/python/doc/wasserstein_distance_user.rst index a049cfb5..8862a5ce 100644 --- a/src/python/doc/wasserstein_distance_user.rst +++ b/src/python/doc/wasserstein_distance_user.rst @@ -30,7 +30,7 @@ Note that persistence diagrams must be submitted as (n x 2) numpy arrays and mus diag1 = np.array([[2.7, 3.7],[9.6, 14.],[34.2, 34.974]]) diag2 = np.array([[2.8, 4.45],[9.5, 14.1]]) - message = "Wasserstein distance value = " + '%.2f' % gudhi.wasserstein.wasserstein_distance(diag1, diag2, q=2., p=1.) + message = "Wasserstein distance value = " + '%.2f' % gudhi.wasserstein.wasserstein_distance(diag1, diag2, internal_p=2., q=1.) print(message) The output is: -- cgit v1.2.3 From 18c98020adea4a7d0c53fe4e76c92bab23e7ad76 Mon Sep 17 00:00:00 2001 From: Marc Glisse Date: Thu, 9 Jan 2020 18:03:39 +0100 Subject: Spell out types as in PEP 484 but don't actually use annotations. A quick try with sphinx-autodoc-typehints failed, I didn't investigate much, it can wait. --- src/python/gudhi/off_reader.pyx | 2 +- src/python/gudhi/reader_utils.pyx | 6 +++--- src/python/gudhi/subsampling.pyx | 12 ++++++------ 3 files changed, 10 insertions(+), 10 deletions(-) (limited to 'src') diff --git a/src/python/gudhi/off_reader.pyx b/src/python/gudhi/off_reader.pyx index e45356be..3a31eba6 100644 --- a/src/python/gudhi/off_reader.pyx +++ b/src/python/gudhi/off_reader.pyx @@ -26,7 +26,7 @@ def read_off(off_file=''): :type off_file: string :returns: The point set. - :rtype: list(list(float)) + :rtype: List[List[float]] """ if off_file: if os.path.isfile(off_file): diff --git a/src/python/gudhi/reader_utils.pyx b/src/python/gudhi/reader_utils.pyx index 5a756e4b..9ced6bca 100644 --- a/src/python/gudhi/reader_utils.pyx +++ b/src/python/gudhi/reader_utils.pyx @@ -34,7 +34,7 @@ def read_lower_triangular_matrix_from_csv_file(csv_file='', separator=';'): :type separator: char :returns: The lower triangular matrix. - :rtype: list(list(float)) + :rtype: List[List[float]] """ if csv_file: if path.isfile(csv_file): @@ -46,14 +46,14 @@ def read_persistence_intervals_grouped_by_dimension(persistence_file=''): """Reads a file containing persistence intervals. Each line might contain 2, 3 or 4 values: [[field] dimension] birth death The return value is a `dict(dim, list(tuple(birth, death)))` - where `dim` is an `int`, `birth` a `double`, and `death` a `double`. + where `dim` is an `int`, `birth` a `float`, and `death` a `float`. Note: the function does not check that birth <= death. :param persistence_file: A persistence file style name. :type persistence_file: string :returns: The persistence pairs grouped by dimension. - :rtype: dict(int, list(tuple(float, float))) + :rtype: Dict[int, List[Tuple[float, float]]] """ if persistence_file: if path.isfile(persistence_file): diff --git a/src/python/gudhi/subsampling.pyx b/src/python/gudhi/subsampling.pyx index 04f66219..f50f4b0c 100644 --- a/src/python/gudhi/subsampling.pyx +++ b/src/python/gudhi/subsampling.pyx @@ -33,7 +33,7 @@ def choose_n_farthest_points(points=None, off_file='', nb_points=0, starting_poi The iteration starts with the landmark `starting point`. :param points: The input point set. - :type points: list(list(float)). + :type points: Iterable[Iterable[float]]. Or @@ -47,7 +47,7 @@ def choose_n_farthest_points(points=None, off_file='', nb_points=0, starting_poi index is chosen randomly. :type starting_point: unsigned. :returns: The subsample point set. - :rtype: list(list(float)). + :rtype: List[List[float]]. """ if off_file: if os.path.isfile(off_file): @@ -74,7 +74,7 @@ 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. - :type points: list(list(float)). + :type points: Iterable[Iterable[float]]. Or @@ -84,7 +84,7 @@ def pick_n_random_points(points=None, off_file='', nb_points=0): :param nb_points: Number of points of the subsample. :type nb_points: unsigned. :returns: The subsample point set. - :rtype: list(list(float)) + :rtype: List[List[float]] """ if off_file: if os.path.isfile(off_file): @@ -103,7 +103,7 @@ def sparsify_point_set(points=None, off_file='', min_squared_dist=0.0): between any two points is greater than or equal to min_squared_dist. :param points: The input point set. - :type points: list(list(float)). + :type points: Iterable[Iterable[float]]. Or @@ -114,7 +114,7 @@ def sparsify_point_set(points=None, off_file='', min_squared_dist=0.0): points. :type min_squared_dist: float. :returns: The subsample point set. - :rtype: list(list(float)) + :rtype: List[List[float]] """ if off_file: if os.path.isfile(off_file): -- cgit v1.2.3 From 2f7f4d84df64172c1af8b8741112c6dd9c883944 Mon Sep 17 00:00:00 2001 From: Marc Glisse Date: Thu, 9 Jan 2020 18:22:24 +0100 Subject: Move point utilities in the index they we between computing diagrams and using diagrams, it looked strange --- src/python/doc/index.rst | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'src') diff --git a/src/python/doc/index.rst b/src/python/doc/index.rst index 9513deb0..3387a64f 100644 --- a/src/python/doc/index.rst +++ b/src/python/doc/index.rst @@ -58,11 +58,6 @@ Persistence cohomology .. include:: persistent_cohomology_sum.inc -Point cloud utilities -********************* - -.. include:: point_cloud_sum.inc - Topological descriptors tools ***************************** @@ -86,6 +81,11 @@ Persistence graphical tools .. include:: persistence_graphical_tools_sum.inc +Point cloud utilities +********************* + +.. include:: point_cloud_sum.inc + Bibliography ************ -- cgit v1.2.3 From 051c9760a214a11e8e4af14ae6221e34bb876350 Mon Sep 17 00:00:00 2001 From: Marc Glisse Date: Thu, 9 Jan 2020 20:56:48 +0100 Subject: align text --- src/python/doc/point_cloud_sum.inc | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/python/doc/point_cloud_sum.inc b/src/python/doc/point_cloud_sum.inc index cefcf1c8..85d52de7 100644 --- a/src/python/doc/point_cloud_sum.inc +++ b/src/python/doc/point_cloud_sum.inc @@ -2,8 +2,8 @@ :widths: 30 50 20 +----------------------------------------------------------------+------------------------------------------------------------------------+-----------------------------------------------------------------------------------------------------------------------------+ - | :math:`(x_1, x_2, \ldots, x_d)` | Utilities to process point clouds: read from file, subsample, etc. | :Author: Vincent Rouvreau | - | :math:`(y_1, y_2, \ldots, y_d)` | | | + | | :math:`(x_1, x_2, \ldots, x_d)` | Utilities to process point clouds: read from file, subsample, etc. | :Author: Vincent Rouvreau | + | | :math:`(y_1, y_2, \ldots, y_d)` | | | | | | :Introduced in: GUDHI 2.0.0 | | | | | | | | :Copyright: MIT (`GPL v3 `_) | -- cgit v1.2.3 From 6d30726d9279a2ccaacdae6244fd50a6fd34528c Mon Sep 17 00:00:00 2001 From: ROUVREAU Vincent Date: Fri, 10 Jan 2020 10:59:32 +0100 Subject: Fix #105: Add alpha value on the picture, clarify simplices removal from the Delaunay complex, use max_alpha_square=32 in the Python example --- src/Alpha_complex/doc/Intro_alpha_complex.h | 14 +++++++------- .../doc/alpha_complex_representation.ipe | 6 +++--- .../doc/alpha_complex_representation.png | Bin 14606 -> 19568 bytes src/common/doc/main_page.md | 4 ++-- src/python/doc/alpha_complex_sum.inc | 6 +++--- src/python/doc/alpha_complex_user.rst | 19 +++++++++---------- 6 files changed, 24 insertions(+), 25 deletions(-) (limited to 'src') diff --git a/src/Alpha_complex/doc/Intro_alpha_complex.h b/src/Alpha_complex/doc/Intro_alpha_complex.h index 3c32a1e6..a8b1a106 100644 --- a/src/Alpha_complex/doc/Intro_alpha_complex.h +++ b/src/Alpha_complex/doc/Intro_alpha_complex.h @@ -31,8 +31,8 @@ namespace alpha_complex { * circumsphere is empty (the simplex is then said to be Gabriel), and as the minimum of the filtration * values of the codimension 1 cofaces that make it not Gabriel otherwise. * - * All simplices that have a filtration value strictly greater than a given alpha squared value are not inserted into - * the complex. + * All simplices that have a filtration value \f$ > \alpha^2 \f$ are removed from the Delaunay complex + * when creating the simplicial complex if it is specified. * * \image html "alpha_complex_representation.png" "Alpha-complex representation" * @@ -46,8 +46,8 @@ namespace alpha_complex { * \cite cgal:s-gkd-19b from CGAL as template parameter. * * \remark - * - When the simplicial complex is constructed with an infinite value of alpha, the complex is a Delaunay - * complex. + * - When an \f$\alpha\f$-complex is constructed with an infinite value of \f$ \alpha^2 \f$, the complex is a Delaunay + * complex (with special filtration values). * - For people only interested in the topology of the \ref alpha_complex (for instance persistence), * \ref alpha_complex is equivalent to the \ref cech_complex and much smaller if you do not bound the radii. * \ref cech_complex can still make sense in higher dimension precisely because you can bound the radii. @@ -135,13 +135,13 @@ namespace alpha_complex { * * \subsubsection nondecreasing Non decreasing filtration values * - * As the squared radii computed by CGAL are an approximation, it might happen that these alpha squared values do not - * quite define a proper filtration (i.e. non-decreasing with respect to inclusion). + * As the squared radii computed by CGAL are an approximation, it might happen that these \f$ \alpha^2 \f$ values do + * not quite define a proper filtration (i.e. non-decreasing with respect to inclusion). * We fix that up by calling `SimplicialComplexForAlpha::make_filtration_non_decreasing()`. * * \subsubsection pruneabove Prune above given filtration value * - * The simplex tree is pruned from the given maximum alpha squared value (cf. + * The simplex tree is pruned from the given maximum \f$ \alpha^2 \f$ value (cf. * `SimplicialComplexForAlpha::prune_above_filtration()`). * In the following example, the value is given by the user as argument of the program. * diff --git a/src/Alpha_complex/doc/alpha_complex_representation.ipe b/src/Alpha_complex/doc/alpha_complex_representation.ipe index e8096b93..40ff1d0f 100644 --- a/src/Alpha_complex/doc/alpha_complex_representation.ipe +++ b/src/Alpha_complex/doc/alpha_complex_representation.ipe @@ -1,7 +1,7 @@ - - + + @@ -305,7 +305,7 @@ h 108.275 743.531 m 166.45 743.531 l -$\alpha$ +\alpha = \sqrt{32.0} diff --git a/src/Alpha_complex/doc/alpha_complex_representation.png b/src/Alpha_complex/doc/alpha_complex_representation.png index 7b81cd69..5ebb1e75 100644 Binary files a/src/Alpha_complex/doc/alpha_complex_representation.png and b/src/Alpha_complex/doc/alpha_complex_representation.png differ diff --git a/src/common/doc/main_page.md b/src/common/doc/main_page.md index e8d11fdf..0b4bfb7a 100644 --- a/src/common/doc/main_page.md +++ b/src/common/doc/main_page.md @@ -43,8 +43,8 @@ The filtration value of each simplex is computed as the square of the circumradius of the simplex if the circumsphere is empty (the simplex is then said to be Gabriel), and as the minimum of the filtration values of the codimension 1 cofaces that make it not Gabriel otherwise. - All simplices that have a filtration value strictly greater than a given alpha squared value are not inserted into - the complex.
+ All simplices that have a filtration value \f$ > \alpha^2 \f$ are removed from the Delaunay complex + when creating the simplicial complex if it is specified.
For performances reasons, it is advised to use \ref cgal ≥ 5.0.0. diff --git a/src/python/doc/alpha_complex_sum.inc b/src/python/doc/alpha_complex_sum.inc index c5ba9dc7..a1184663 100644 --- a/src/python/doc/alpha_complex_sum.inc +++ b/src/python/doc/alpha_complex_sum.inc @@ -9,9 +9,9 @@ | | circumradius of the simplex if the circumsphere is empty (the simplex | :Copyright: MIT (`GPL v3 `_) | | | is then said to be Gabriel), and as the minimum of the filtration | | | | values of the codimension 1 cofaces that make it not Gabriel | :Requires: `Eigen `__ :math:`\geq` 3.1.0 and `CGAL `__ :math:`\geq` 4.11.0 | - | | otherwise. All simplices that have a filtration value strictly | | - | | greater than a given alpha squared value are not inserted into the | | - | | complex. | | + | | otherwise. All simplices that have a filtration value | | + | | :math:`> \alpha^2` are removed from the Delaunay complex | | + | | when creating the simplicial complex if it is specified. | | | | | | | | This package requires having CGAL version 4.7 or higher (4.8.1 is | | | | advised for better performance). | | diff --git a/src/python/doc/alpha_complex_user.rst b/src/python/doc/alpha_complex_user.rst index b7e69e12..60319e84 100644 --- a/src/python/doc/alpha_complex_user.rst +++ b/src/python/doc/alpha_complex_user.rst @@ -16,7 +16,8 @@ Definition Remarks ^^^^^^^ -When an :math:`\alpha`-complex is constructed with an infinite value of :math:`\alpha`, the complex is a Delaunay complex (with special filtration values). +When an :math:`\alpha`-complex is constructed with an infinite value of :math:`\alpha^2`, +the complex is a Delaunay complex (with special filtration values). Example from points ------------------- @@ -137,19 +138,20 @@ sets the filtration value (0 in case of a vertex - propagation will have no effe Non decreasing filtration values ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -As the squared radii computed by CGAL are an approximation, it might happen that these alpha squared values do not -quite define a proper filtration (i.e. non-decreasing with respect to inclusion). +As the squared radii computed by CGAL are an approximation, it might happen that these +:math:`\alpha^2` values do not quite define a proper filtration (i.e. non-decreasing with +respect to inclusion). We fix that up by calling :func:`~gudhi.SimplexTree.make_filtration_non_decreasing` (cf. `C++ version `_). Prune above given filtration value ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -The simplex tree is pruned from the given maximum alpha squared value (cf. +The simplex tree is pruned from the given maximum :math:`\alpha^2` value (cf. :func:`~gudhi.SimplexTree.prune_above_filtration`). Note that this does not provide any kind of speed-up, since we always first build the full filtered complex, so it is recommended not to use :paramref:`~gudhi.AlphaComplex.create_simplex_tree.max_alpha_square`. -In the following example, a threshold of 59 is used. +In the following example, a threshold of :math:`\alpha^2 = 32.0` is used. Example from OFF file @@ -166,7 +168,7 @@ Then, it is asked to display information about the alpha complex: import gudhi alpha_complex = gudhi.AlphaComplex(off_file=gudhi.__root_source_dir__ + \ '/data/points/alphacomplexdoc.off') - simplex_tree = alpha_complex.create_simplex_tree(max_alpha_square=59.0) + simplex_tree = alpha_complex.create_simplex_tree(max_alpha_square=32.0) result_str = 'Alpha complex is of dimension ' + repr(simplex_tree.dimension()) + ' - ' + \ repr(simplex_tree.num_simplices()) + ' simplices - ' + \ repr(simplex_tree.num_vertices()) + ' vertices.' @@ -179,7 +181,7 @@ the program output is: .. testoutput:: - Alpha complex is of dimension 2 - 23 simplices - 7 vertices. + Alpha complex is of dimension 2 - 20 simplices - 7 vertices. [0] -> 0.00 [1] -> 0.00 [2] -> 0.00 @@ -200,9 +202,6 @@ the program output is: [4, 6] -> 22.74 [4, 5, 6] -> 22.74 [3, 6] -> 30.25 - [2, 6] -> 36.50 - [2, 3, 6] -> 36.50 - [2, 4, 6] -> 37.24 CGAL citations ============== -- cgit v1.2.3 From 609d4a5307cb8faef5f5002be9f51eee7bf3916e Mon Sep 17 00:00:00 2001 From: ROUVREAU Vincent Date: Fri, 10 Jan 2020 11:20:07 +0100 Subject: Bug fix: a href tag was badly closed --- src/common/doc/installation.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src') diff --git a/src/common/doc/installation.h b/src/common/doc/installation.h index d70a2efa..ce2c5448 100644 --- a/src/common/doc/installation.h +++ b/src/common/doc/installation.h @@ -33,7 +33,7 @@ make \endverbatim * \subsection testsuites Test suites * To test your build, run the following command in a terminal: * \verbatim make test \endverbatim - * `make test` is using
Ctest<\a> (CMake test driver + * `make test` is using Ctest (CMake test driver * program). If some of the tests are failing, please send us the result of the following command: * \verbatim ctest --output-on-failure \endverbatim * -- cgit v1.2.3 From 8f5cb043bf78b8f008b67e292668543a899e6795 Mon Sep 17 00:00:00 2001 From: ROUVREAU Vincent Date: Fri, 10 Jan 2020 19:43:04 +0100 Subject: Reorder import and docstrings. Modify test_representations --- src/python/gudhi/__init__.py.in | 8 +++----- src/python/gudhi/alpha_complex.pyx | 18 +++++++++--------- src/python/gudhi/bottleneck.pyx | 10 +++++----- src/python/gudhi/cubical_complex.pyx | 18 +++++++++--------- src/python/gudhi/euclidean_strong_witness_complex.pyx | 16 ++++++++-------- src/python/gudhi/euclidean_witness_complex.pyx | 16 ++++++++-------- src/python/gudhi/nerve_gic.pyx | 18 +++++++++--------- src/python/gudhi/off_reader.pyx | 10 +++++----- src/python/gudhi/periodic_cubical_complex.pyx | 18 +++++++++--------- src/python/gudhi/persistence_graphical_tools.py | 14 +++++++------- src/python/gudhi/reader_utils.pyx | 18 +++++++++--------- src/python/gudhi/rips_complex.pyx | 18 +++++++++--------- src/python/gudhi/simplex_tree.pxd | 19 +++++++++---------- src/python/gudhi/simplex_tree.pyx | 8 ++++---- src/python/gudhi/strong_witness_complex.pyx | 16 ++++++++-------- src/python/gudhi/subsampling.pyx | 12 ++++++------ src/python/gudhi/tangential_complex.pyx | 18 +++++++++--------- src/python/gudhi/wasserstein.py | 14 +++++++------- src/python/gudhi/witness_complex.pyx | 16 ++++++++-------- src/python/setup.py.in | 8 ++++---- src/python/test/test_alpha_complex.py | 12 ++++++------ src/python/test/test_bottleneck_distance.py | 4 ++-- src/python/test/test_cover_complex.py | 4 ++-- src/python/test/test_cubical_complex.py | 6 +++--- src/python/test/test_euclidean_witness_complex.py | 4 ++-- src/python/test/test_reader_utils.py | 6 +++--- src/python/test/test_representations.py | 15 ++++++++------- src/python/test/test_rips_complex.py | 6 +++--- src/python/test/test_simplex_tree.py | 4 ++-- src/python/test/test_subsampling.py | 4 ++-- src/python/test/test_tangential_complex.py | 4 ++-- src/python/test/test_wasserstein_distance.py | 6 +++--- src/python/test/test_witness_complex.py | 4 ++-- 33 files changed, 185 insertions(+), 187 deletions(-) (limited to 'src') diff --git a/src/python/gudhi/__init__.py.in b/src/python/gudhi/__init__.py.in index 0c462b02..79e12fbc 100644 --- a/src/python/gudhi/__init__.py.in +++ b/src/python/gudhi/__init__.py.in @@ -1,5 +1,3 @@ -from importlib import import_module - # This file is part of the Gudhi Library - https://gudhi.inria.fr/ - which is released under MIT. # See file LICENSE or go to https://gudhi.inria.fr/licensing/ for full license details. # Author(s): Vincent Rouvreau @@ -9,6 +7,9 @@ from importlib import import_module # Modification(s): # - YYYY/MM Author: Description of the modification +from importlib import import_module +from sys import exc_info + __author__ = "GUDHI Editorial Board" __copyright__ = "Copyright (C) 2016 Inria" __license__ = "https://gudhi.inria.fr/licensing/" @@ -17,9 +18,6 @@ __version__ = "@GUDHI_VERSION@" __root_source_dir__ = "@CMAKE_SOURCE_DIR@" __debug_info__ = @GUDHI_PYTHON_DEBUG_INFO@ -from sys import exc_info -from importlib import import_module - __all__ = [@GUDHI_PYTHON_MODULES@ @GUDHI_PYTHON_MODULES_EXTRA@] __available_modules = '' diff --git a/src/python/gudhi/alpha_complex.pyx b/src/python/gudhi/alpha_complex.pyx index 24e36bea..db11416c 100644 --- a/src/python/gudhi/alpha_complex.pyx +++ b/src/python/gudhi/alpha_complex.pyx @@ -1,3 +1,12 @@ +# This file is part of the Gudhi Library - https://gudhi.inria.fr/ - which is released under MIT. +# See file LICENSE or go to https://gudhi.inria.fr/licensing/ for full license details. +# Author(s): Vincent Rouvreau +# +# Copyright (C) 2016 Inria +# +# Modification(s): +# - YYYY/MM Author: Description of the modification + from cython cimport numeric from libcpp.vector cimport vector from libcpp.utility cimport pair @@ -9,15 +18,6 @@ import os from gudhi.simplex_tree cimport * from gudhi.simplex_tree import SimplexTree -# This file is part of the Gudhi Library - https://gudhi.inria.fr/ - which is released under MIT. -# See file LICENSE or go to https://gudhi.inria.fr/licensing/ for full license details. -# Author(s): Vincent Rouvreau -# -# Copyright (C) 2016 Inria -# -# Modification(s): -# - YYYY/MM Author: Description of the modification - __author__ = "Vincent Rouvreau" __copyright__ = "Copyright (C) 2016 Inria" __license__ = "GPL v3" diff --git a/src/python/gudhi/bottleneck.pyx b/src/python/gudhi/bottleneck.pyx index c2361024..af011e88 100644 --- a/src/python/gudhi/bottleneck.pyx +++ b/src/python/gudhi/bottleneck.pyx @@ -1,8 +1,3 @@ -from cython cimport numeric -from libcpp.vector cimport vector -from libcpp.utility cimport pair -import os - # This file is part of the Gudhi Library - https://gudhi.inria.fr/ - which is released under MIT. # See file LICENSE or go to https://gudhi.inria.fr/licensing/ for full license details. # Author(s): Vincent Rouvreau @@ -12,6 +7,11 @@ import os # Modification(s): # - YYYY/MM Author: Description of the modification +from cython cimport numeric +from libcpp.vector cimport vector +from libcpp.utility cimport pair +import os + __author__ = "Vincent Rouvreau" __copyright__ = "Copyright (C) 2016 Inria" __license__ = "GPL v3" diff --git a/src/python/gudhi/cubical_complex.pyx b/src/python/gudhi/cubical_complex.pyx index b7047d4f..92ff6411 100644 --- a/src/python/gudhi/cubical_complex.pyx +++ b/src/python/gudhi/cubical_complex.pyx @@ -1,12 +1,3 @@ -from cython cimport numeric -from libcpp.vector cimport vector -from libcpp.utility cimport pair -from libcpp.string cimport string -from libcpp cimport bool -import os - -import numpy as np - # This file is part of the Gudhi Library - https://gudhi.inria.fr/ - which is released under MIT. # See file LICENSE or go to https://gudhi.inria.fr/licensing/ for full license details. # Author(s): Vincent Rouvreau @@ -16,6 +7,15 @@ import numpy as np # Modification(s): # - YYYY/MM Author: Description of the modification +from cython cimport numeric +from libcpp.vector cimport vector +from libcpp.utility cimport pair +from libcpp.string cimport string +from libcpp cimport bool +import os + +import numpy as np + __author__ = "Vincent Rouvreau" __copyright__ = "Copyright (C) 2016 Inria" __license__ = "MIT" diff --git a/src/python/gudhi/euclidean_strong_witness_complex.pyx b/src/python/gudhi/euclidean_strong_witness_complex.pyx index e3f451f0..9889f92c 100644 --- a/src/python/gudhi/euclidean_strong_witness_complex.pyx +++ b/src/python/gudhi/euclidean_strong_witness_complex.pyx @@ -1,11 +1,3 @@ -from cython cimport numeric -from libcpp.vector cimport vector -from libcpp.utility cimport pair -from libc.stdint cimport intptr_t - -from gudhi.simplex_tree cimport * -from gudhi.simplex_tree import SimplexTree - # This file is part of the Gudhi Library - https://gudhi.inria.fr/ - which is released under MIT. # See file LICENSE or go to https://gudhi.inria.fr/licensing/ for full license details. # Author(s): Vincent Rouvreau @@ -15,6 +7,14 @@ from gudhi.simplex_tree import SimplexTree # Modification(s): # - YYYY/MM Author: Description of the modification +from cython cimport numeric +from libcpp.vector cimport vector +from libcpp.utility cimport pair +from libc.stdint cimport intptr_t + +from gudhi.simplex_tree cimport * +from gudhi.simplex_tree import SimplexTree + __author__ = "Vincent Rouvreau" __copyright__ = "Copyright (C) 2016 Inria" __license__ = "GPL v3" diff --git a/src/python/gudhi/euclidean_witness_complex.pyx b/src/python/gudhi/euclidean_witness_complex.pyx index 84a8ea1a..e3ce0e82 100644 --- a/src/python/gudhi/euclidean_witness_complex.pyx +++ b/src/python/gudhi/euclidean_witness_complex.pyx @@ -1,11 +1,3 @@ -from cython cimport numeric -from libcpp.vector cimport vector -from libcpp.utility cimport pair -from libc.stdint cimport intptr_t - -from gudhi.simplex_tree cimport * -from gudhi.simplex_tree import SimplexTree - # This file is part of the Gudhi Library - https://gudhi.inria.fr/ - which is released under MIT. # See file LICENSE or go to https://gudhi.inria.fr/licensing/ for full license details. # Author(s): Vincent Rouvreau @@ -15,6 +7,14 @@ from gudhi.simplex_tree import SimplexTree # Modification(s): # - YYYY/MM Author: Description of the modification +from cython cimport numeric +from libcpp.vector cimport vector +from libcpp.utility cimport pair +from libc.stdint cimport intptr_t + +from gudhi.simplex_tree cimport * +from gudhi.simplex_tree import SimplexTree + __author__ = "Vincent Rouvreau" __copyright__ = "Copyright (C) 2016 Inria" __license__ = "GPL v3" diff --git a/src/python/gudhi/nerve_gic.pyx b/src/python/gudhi/nerve_gic.pyx index acb78564..68c06432 100644 --- a/src/python/gudhi/nerve_gic.pyx +++ b/src/python/gudhi/nerve_gic.pyx @@ -1,3 +1,12 @@ +# This file is part of the Gudhi Library - https://gudhi.inria.fr/ - which is released under MIT. +# See file LICENSE or go to https://gudhi.inria.fr/licensing/ for full license details. +# Author(s): Vincent Rouvreau +# +# Copyright (C) 2018 Inria +# +# Modification(s): +# - YYYY/MM Author: Description of the modification + from cython cimport numeric from libcpp.vector cimport vector from libcpp.utility cimport pair @@ -9,15 +18,6 @@ from libc.stdint cimport intptr_t from gudhi.simplex_tree cimport * from gudhi.simplex_tree import SimplexTree -# This file is part of the Gudhi Library - https://gudhi.inria.fr/ - which is released under MIT. -# See file LICENSE or go to https://gudhi.inria.fr/licensing/ for full license details. -# Author(s): Vincent Rouvreau -# -# Copyright (C) 2018 Inria -# -# Modification(s): -# - YYYY/MM Author: Description of the modification - __author__ = "Vincent Rouvreau" __copyright__ = "Copyright (C) 2018 Inria" __license__ = "GPL v3" diff --git a/src/python/gudhi/off_reader.pyx b/src/python/gudhi/off_reader.pyx index 225e981c..54a275e2 100644 --- a/src/python/gudhi/off_reader.pyx +++ b/src/python/gudhi/off_reader.pyx @@ -1,8 +1,3 @@ -from cython cimport numeric -from libcpp.vector cimport vector -from libcpp.string cimport string -import os - # This file is part of the Gudhi Library - https://gudhi.inria.fr/ - which is released under MIT. # See file LICENSE or go to https://gudhi.inria.fr/licensing/ for full license details. # Author(s): Vincent Rouvreau @@ -12,6 +7,11 @@ import os # Modification(s): # - YYYY/MM Author: Description of the modification +from cython cimport numeric +from libcpp.vector cimport vector +from libcpp.string cimport string +import os + __author__ = "Vincent Rouvreau" __copyright__ = "Copyright (C) 2016 Inria" __license__ = "MIT" diff --git a/src/python/gudhi/periodic_cubical_complex.pyx b/src/python/gudhi/periodic_cubical_complex.pyx index eb96ab5f..b5dece10 100644 --- a/src/python/gudhi/periodic_cubical_complex.pyx +++ b/src/python/gudhi/periodic_cubical_complex.pyx @@ -1,12 +1,3 @@ -from cython cimport numeric -from libcpp.vector cimport vector -from libcpp.utility cimport pair -from libcpp.string cimport string -from libcpp cimport bool -import os - -import numpy as np - # This file is part of the Gudhi Library - https://gudhi.inria.fr/ - which is released under MIT. # See file LICENSE or go to https://gudhi.inria.fr/licensing/ for full license details. # Author(s): Vincent Rouvreau @@ -16,6 +7,15 @@ import numpy as np # Modification(s): # - YYYY/MM Author: Description of the modification +from cython cimport numeric +from libcpp.vector cimport vector +from libcpp.utility cimport pair +from libcpp.string cimport string +from libcpp cimport bool +import os + +import numpy as np + __author__ = "Vincent Rouvreau" __copyright__ = "Copyright (C) 2016 Inria" __license__ = "MIT" diff --git a/src/python/gudhi/persistence_graphical_tools.py b/src/python/gudhi/persistence_graphical_tools.py index 7d232c85..246280de 100644 --- a/src/python/gudhi/persistence_graphical_tools.py +++ b/src/python/gudhi/persistence_graphical_tools.py @@ -1,10 +1,3 @@ -from os import path -from math import isfinite -import numpy as np - -from gudhi.reader_utils import read_persistence_intervals_in_dimension -from gudhi.reader_utils import read_persistence_intervals_grouped_by_dimension - # This file is part of the Gudhi Library - https://gudhi.inria.fr/ - which is released under MIT. # See file LICENSE or go to https://gudhi.inria.fr/licensing/ for full license details. # Author(s): Vincent Rouvreau, Bertrand Michel @@ -14,6 +7,13 @@ from gudhi.reader_utils import read_persistence_intervals_grouped_by_dimension # Modification(s): # - YYYY/MM Author: Description of the modification +from os import path +from math import isfinite +import numpy as np + +from gudhi.reader_utils import read_persistence_intervals_in_dimension +from gudhi.reader_utils import read_persistence_intervals_grouped_by_dimension + __author__ = "Vincent Rouvreau, Bertrand Michel" __copyright__ = "Copyright (C) 2016 Inria" __license__ = "MIT" diff --git a/src/python/gudhi/reader_utils.pyx b/src/python/gudhi/reader_utils.pyx index 6994c4f9..345c92f8 100644 --- a/src/python/gudhi/reader_utils.pyx +++ b/src/python/gudhi/reader_utils.pyx @@ -1,12 +1,3 @@ -from cython cimport numeric -from libcpp.vector cimport vector -from libcpp.string cimport string -from libcpp.map cimport map -from libcpp.pair cimport pair - -from os import path -from numpy import array as np_array - # This file is part of the Gudhi Library - https://gudhi.inria.fr/ - which is released under MIT. # See file LICENSE or go to https://gudhi.inria.fr/licensing/ for full license details. # Author(s): Vincent Rouvreau @@ -16,6 +7,15 @@ from numpy import array as np_array # Modification(s): # - YYYY/MM Author: Description of the modification +from cython cimport numeric +from libcpp.vector cimport vector +from libcpp.string cimport string +from libcpp.map cimport map +from libcpp.pair cimport pair + +from os import path +from numpy import array as np_array + __author__ = "Vincent Rouvreau" __copyright__ = "Copyright (C) 2017 Inria" __license__ = "MIT" diff --git a/src/python/gudhi/rips_complex.pyx b/src/python/gudhi/rips_complex.pyx index cbbbab0d..722cdcdc 100644 --- a/src/python/gudhi/rips_complex.pyx +++ b/src/python/gudhi/rips_complex.pyx @@ -1,3 +1,12 @@ +# This file is part of the Gudhi Library - https://gudhi.inria.fr/ - which is released under MIT. +# See file LICENSE or go to https://gudhi.inria.fr/licensing/ for full license details. +# Author(s): Vincent Rouvreau +# +# Copyright (C) 2016 Inria +# +# Modification(s): +# - YYYY/MM Author: Description of the modification + from cython cimport numeric from libcpp.vector cimport vector from libcpp.utility cimport pair @@ -8,15 +17,6 @@ from libc.stdint cimport intptr_t from gudhi.simplex_tree cimport * from gudhi.simplex_tree import SimplexTree -# This file is part of the Gudhi Library - https://gudhi.inria.fr/ - which is released under MIT. -# See file LICENSE or go to https://gudhi.inria.fr/licensing/ for full license details. -# Author(s): Vincent Rouvreau -# -# Copyright (C) 2016 Inria -# -# Modification(s): -# - YYYY/MM Author: Description of the modification - __author__ = "Vincent Rouvreau" __copyright__ = "Copyright (C) 2016 Inria" __license__ = "MIT" diff --git a/src/python/gudhi/simplex_tree.pxd b/src/python/gudhi/simplex_tree.pxd index 5f86cfe2..1066d44b 100644 --- a/src/python/gudhi/simplex_tree.pxd +++ b/src/python/gudhi/simplex_tree.pxd @@ -1,19 +1,18 @@ +# This file is part of the Gudhi Library - https://gudhi.inria.fr/ - which is released under MIT. +# See file LICENSE or go to https://gudhi.inria.fr/licensing/ for full license details. +# Author(s): Vincent Rouvreau +# +# Copyright (C) 2016 Inria +# +# Modification(s): +# - YYYY/MM Author: Description of the modification + from cython cimport numeric from libcpp.vector cimport vector from libcpp.utility cimport pair from libcpp cimport bool from libcpp.string cimport string -""" This file is part of the Gudhi Library - https://gudhi.inria.fr/ - which is released under MIT. - See file LICENSE or go to https://gudhi.inria.fr/licensing/ for full license details. - Author(s): Vincent Rouvreau - - Copyright (C) 2016 Inria - - Modification(s): - - YYYY/MM Author: Description of the modification -""" - __author__ = "Vincent Rouvreau" __copyright__ = "Copyright (C) 2016 Inria" __license__ = "MIT" diff --git a/src/python/gudhi/simplex_tree.pyx b/src/python/gudhi/simplex_tree.pyx index 4a3cd9bc..85d25492 100644 --- a/src/python/gudhi/simplex_tree.pyx +++ b/src/python/gudhi/simplex_tree.pyx @@ -1,7 +1,3 @@ -from libc.stdint cimport intptr_t -from numpy import array as np_array -cimport simplex_tree - # This file is part of the Gudhi Library - https://gudhi.inria.fr/ - which is released under MIT. # See file LICENSE or go to https://gudhi.inria.fr/licensing/ for full license details. # Author(s): Vincent Rouvreau @@ -11,6 +7,10 @@ cimport simplex_tree # Modification(s): # - YYYY/MM Author: Description of the modification +from libc.stdint cimport intptr_t +from numpy import array as np_array +cimport simplex_tree + __author__ = "Vincent Rouvreau" __copyright__ = "Copyright (C) 2016 Inria" __license__ = "MIT" diff --git a/src/python/gudhi/strong_witness_complex.pyx b/src/python/gudhi/strong_witness_complex.pyx index 66d49b49..2c33c3f2 100644 --- a/src/python/gudhi/strong_witness_complex.pyx +++ b/src/python/gudhi/strong_witness_complex.pyx @@ -1,11 +1,3 @@ -from cython cimport numeric -from libcpp.vector cimport vector -from libcpp.utility cimport pair -from libc.stdint cimport intptr_t - -from gudhi.simplex_tree cimport * -from gudhi.simplex_tree import SimplexTree - # This file is part of the Gudhi Library - https://gudhi.inria.fr/ - which is released under MIT. # See file LICENSE or go to https://gudhi.inria.fr/licensing/ for full license details. # Author(s): Vincent Rouvreau @@ -15,6 +7,14 @@ from gudhi.simplex_tree import SimplexTree # Modification(s): # - YYYY/MM Author: Description of the modification +from cython cimport numeric +from libcpp.vector cimport vector +from libcpp.utility cimport pair +from libc.stdint cimport intptr_t + +from gudhi.simplex_tree cimport * +from gudhi.simplex_tree import SimplexTree + __author__ = "Vincent Rouvreau" __copyright__ = "Copyright (C) 2016 Inria" __license__ = "MIT" diff --git a/src/python/gudhi/subsampling.pyx b/src/python/gudhi/subsampling.pyx index e0cd1348..b1812087 100644 --- a/src/python/gudhi/subsampling.pyx +++ b/src/python/gudhi/subsampling.pyx @@ -1,9 +1,3 @@ -from cython cimport numeric -from libcpp.vector cimport vector -from libcpp.string cimport string -from libcpp cimport bool -import os - # This file is part of the Gudhi Library - https://gudhi.inria.fr/ - which is released under MIT. # See file LICENSE or go to https://gudhi.inria.fr/licensing/ for full license details. # Author(s): Vincent Rouvreau @@ -13,6 +7,12 @@ import os # Modification(s): # - YYYY/MM Author: Description of the modification +from cython cimport numeric +from libcpp.vector cimport vector +from libcpp.string cimport string +from libcpp cimport bool +import os + __author__ = "Vincent Rouvreau" __copyright__ = "Copyright (C) 2016 Inria" __license__ = "GPL v3" diff --git a/src/python/gudhi/tangential_complex.pyx b/src/python/gudhi/tangential_complex.pyx index f4c8b079..0083033c 100644 --- a/src/python/gudhi/tangential_complex.pyx +++ b/src/python/gudhi/tangential_complex.pyx @@ -1,3 +1,12 @@ +# This file is part of the Gudhi Library - https://gudhi.inria.fr/ - which is released under MIT. +# See file LICENSE or go to https://gudhi.inria.fr/licensing/ for full license details. +# Author(s): Vincent Rouvreau +# +# Copyright (C) 2016 Inria +# +# Modification(s): +# - YYYY/MM Author: Description of the modification + from cython cimport numeric from libcpp.vector cimport vector from libcpp.utility cimport pair @@ -9,15 +18,6 @@ import os from gudhi.simplex_tree cimport * from gudhi.simplex_tree import SimplexTree -# This file is part of the Gudhi Library - https://gudhi.inria.fr/ - which is released under MIT. -# See file LICENSE or go to https://gudhi.inria.fr/licensing/ for full license details. -# Author(s): Vincent Rouvreau -# -# Copyright (C) 2016 Inria -# -# Modification(s): -# - YYYY/MM Author: Description of the modification - __author__ = "Vincent Rouvreau" __copyright__ = "Copyright (C) 2016 Inria" __license__ = "GPL v3" diff --git a/src/python/gudhi/wasserstein.py b/src/python/gudhi/wasserstein.py index d8a3104c..1906eeb1 100644 --- a/src/python/gudhi/wasserstein.py +++ b/src/python/gudhi/wasserstein.py @@ -1,10 +1,3 @@ -import numpy as np -import scipy.spatial.distance as sc -try: - import ot -except ImportError: - print("POT (Python Optimal Transport) package is not installed. Try to run $ conda install -c conda-forge pot ; or $ pip install POT") - # This file is part of the Gudhi Library - https://gudhi.inria.fr/ - which is released under MIT. # See file LICENSE or go to https://gudhi.inria.fr/licensing/ for full license details. # Author(s): Theo Lacombe @@ -14,6 +7,13 @@ except ImportError: # Modification(s): # - YYYY/MM Author: Description of the modification +import numpy as np +import scipy.spatial.distance as sc +try: + import ot +except ImportError: + print("POT (Python Optimal Transport) package is not installed. Try to run $ conda install -c conda-forge pot ; or $ pip install POT") + def _proj_on_diag(X): ''' :param X: (n x 2) array encoding the points of a persistent diagram. diff --git a/src/python/gudhi/witness_complex.pyx b/src/python/gudhi/witness_complex.pyx index 153fc615..b032a5a1 100644 --- a/src/python/gudhi/witness_complex.pyx +++ b/src/python/gudhi/witness_complex.pyx @@ -1,11 +1,3 @@ -from cython cimport numeric -from libcpp.vector cimport vector -from libcpp.utility cimport pair -from libc.stdint cimport intptr_t - -from gudhi.simplex_tree cimport * -from gudhi.simplex_tree import SimplexTree - # This file is part of the Gudhi Library - https://gudhi.inria.fr/ - which is released under MIT. # See file LICENSE or go to https://gudhi.inria.fr/licensing/ for full license details. # Author(s): Vincent Rouvreau @@ -15,6 +7,14 @@ from gudhi.simplex_tree import SimplexTree # Modification(s): # - YYYY/MM Author: Description of the modification +from cython cimport numeric +from libcpp.vector cimport vector +from libcpp.utility cimport pair +from libc.stdint cimport intptr_t + +from gudhi.simplex_tree cimport * +from gudhi.simplex_tree import SimplexTree + __author__ = "Vincent Rouvreau" __copyright__ = "Copyright (C) 2016 Inria" __license__ = "MIT" diff --git a/src/python/setup.py.in b/src/python/setup.py.in index 3f1d4424..24d05025 100644 --- a/src/python/setup.py.in +++ b/src/python/setup.py.in @@ -1,7 +1,3 @@ -from setuptools import setup, Extension -from Cython.Build import cythonize -from numpy import get_include as numpy_get_include - """This file is part of the Gudhi Library - https://gudhi.inria.fr/ - which is released under MIT. See file LICENSE or go to https://gudhi.inria.fr/licensing/ for full license details. Author(s): Vincent Rouvreau @@ -12,6 +8,10 @@ from numpy import get_include as numpy_get_include - YYYY/MM Author: Description of the modification """ +from setuptools import setup, Extension +from Cython.Build import cythonize +from numpy import get_include as numpy_get_include + __author__ = "Vincent Rouvreau" __copyright__ = "Copyright (C) 2016 Inria" __license__ = "MIT" diff --git a/src/python/test/test_alpha_complex.py b/src/python/test/test_alpha_complex.py index 9b27fff2..712a50b6 100755 --- a/src/python/test/test_alpha_complex.py +++ b/src/python/test/test_alpha_complex.py @@ -1,9 +1,3 @@ -from gudhi import AlphaComplex, SimplexTree -import math -import numpy as np -import itertools -import pytest - """ This file is part of the Gudhi Library - https://gudhi.inria.fr/ - which is released under MIT. See file LICENSE or go to https://gudhi.inria.fr/licensing/ for full license details. Author(s): Vincent Rouvreau @@ -14,6 +8,12 @@ import pytest - YYYY/MM Author: Description of the modification """ +from gudhi import AlphaComplex, SimplexTree +import math +import numpy as np +import itertools +import pytest + __author__ = "Vincent Rouvreau" __copyright__ = "Copyright (C) 2016 Inria" __license__ = "MIT" diff --git a/src/python/test/test_bottleneck_distance.py b/src/python/test/test_bottleneck_distance.py index f5f019b9..70b2abad 100755 --- a/src/python/test/test_bottleneck_distance.py +++ b/src/python/test/test_bottleneck_distance.py @@ -1,5 +1,3 @@ -import gudhi - """ This file is part of the Gudhi Library - https://gudhi.inria.fr/ - which is released under MIT. See file LICENSE or go to https://gudhi.inria.fr/licensing/ for full license details. Author(s): Vincent Rouvreau @@ -10,6 +8,8 @@ import gudhi - YYYY/MM Author: Description of the modification """ +import gudhi + __author__ = "Vincent Rouvreau" __copyright__ = "Copyright (C) 2016 Inria" __license__ = "MIT" diff --git a/src/python/test/test_cover_complex.py b/src/python/test/test_cover_complex.py index 8cd12272..32bc5a26 100755 --- a/src/python/test/test_cover_complex.py +++ b/src/python/test/test_cover_complex.py @@ -1,5 +1,3 @@ -from gudhi import CoverComplex - """ This file is part of the Gudhi Library - https://gudhi.inria.fr/ - which is released under MIT. See file LICENSE or go to https://gudhi.inria.fr/licensing/ for full license details. Author(s): Vincent Rouvreau @@ -10,6 +8,8 @@ from gudhi import CoverComplex - YYYY/MM Author: Description of the modification """ +from gudhi import CoverComplex + __author__ = "Vincent Rouvreau" __copyright__ = "Copyright (C) 2018 Inria" __license__ = "MIT" diff --git a/src/python/test/test_cubical_complex.py b/src/python/test/test_cubical_complex.py index 121da12a..8c1b2600 100755 --- a/src/python/test/test_cubical_complex.py +++ b/src/python/test/test_cubical_complex.py @@ -1,6 +1,3 @@ -from gudhi import CubicalComplex, PeriodicCubicalComplex -import numpy as np - """ This file is part of the Gudhi Library - https://gudhi.inria.fr/ - which is released under MIT. See file LICENSE or go to https://gudhi.inria.fr/licensing/ for full license details. Author(s): Vincent Rouvreau @@ -11,6 +8,9 @@ import numpy as np - YYYY/MM Author: Description of the modification """ +from gudhi import CubicalComplex, PeriodicCubicalComplex +import numpy as np + __author__ = "Vincent Rouvreau" __copyright__ = "Copyright (C) 2016 Inria" __license__ = "MIT" diff --git a/src/python/test/test_euclidean_witness_complex.py b/src/python/test/test_euclidean_witness_complex.py index f5eae5fa..c18d2484 100755 --- a/src/python/test/test_euclidean_witness_complex.py +++ b/src/python/test/test_euclidean_witness_complex.py @@ -1,5 +1,3 @@ -import gudhi - """ This file is part of the Gudhi Library - https://gudhi.inria.fr/ - which is released under MIT. See file LICENSE or go to https://gudhi.inria.fr/licensing/ for full license details. Author(s): Vincent Rouvreau @@ -10,6 +8,8 @@ import gudhi - YYYY/MM Author: Description of the modification """ +import gudhi + __author__ = "Vincent Rouvreau" __copyright__ = "Copyright (C) 2016 Inria" __license__ = "MIT" diff --git a/src/python/test/test_reader_utils.py b/src/python/test/test_reader_utils.py index 4c7b32c2..90da6651 100755 --- a/src/python/test/test_reader_utils.py +++ b/src/python/test/test_reader_utils.py @@ -1,6 +1,3 @@ -import gudhi -import numpy as np - """ This file is part of the Gudhi Library - https://gudhi.inria.fr/ - which is released under MIT. See file LICENSE or go to https://gudhi.inria.fr/licensing/ for full license details. Author(s): Vincent Rouvreau @@ -11,6 +8,9 @@ import numpy as np - YYYY/MM Author: Description of the modification """ +import gudhi +import numpy as np + __author__ = "Vincent Rouvreau" __copyright__ = "Copyright (C) 2017 Inria" __license__ = "MIT" diff --git a/src/python/test/test_representations.py b/src/python/test/test_representations.py index 4ff65f98..dba7f952 100755 --- a/src/python/test/test_representations.py +++ b/src/python/test/test_representations.py @@ -1,11 +1,12 @@ import os import sys import matplotlib.pyplot as plt -# Disable graphics for testing purposes -plt.show = lambda:None -here = os.path.dirname(os.path.realpath(__file__)) -sys.path.append(here + "/../example") -import diagram_vectorizations_distances_kernels -# pytest is unhappy if there are 0 tests -def test_nothing(): + +def test_representations_examples(): + # Disable graphics for testing purposes + plt.show = lambda:None + here = os.path.dirname(os.path.realpath(__file__)) + sys.path.append(here + "/../example") + import diagram_vectorizations_distances_kernels + return None diff --git a/src/python/test/test_rips_complex.py b/src/python/test/test_rips_complex.py index d55ae22f..b02a68e1 100755 --- a/src/python/test/test_rips_complex.py +++ b/src/python/test/test_rips_complex.py @@ -1,6 +1,3 @@ -from gudhi import RipsComplex -from math import sqrt - """ This file is part of the Gudhi Library - https://gudhi.inria.fr/ - which is released under MIT. See file LICENSE or go to https://gudhi.inria.fr/licensing/ for full license details. Author(s): Vincent Rouvreau @@ -11,6 +8,9 @@ from math import sqrt - YYYY/MM Author: Description of the modification """ +from gudhi import RipsComplex +from math import sqrt + __author__ = "Vincent Rouvreau" __copyright__ = "Copyright (C) 2016 Inria" __license__ = "MIT" diff --git a/src/python/test/test_simplex_tree.py b/src/python/test/test_simplex_tree.py index 8d8971c1..1822c43b 100755 --- a/src/python/test/test_simplex_tree.py +++ b/src/python/test/test_simplex_tree.py @@ -1,5 +1,3 @@ -from gudhi import SimplexTree - """ This file is part of the Gudhi Library - https://gudhi.inria.fr/ - which is released under MIT. See file LICENSE or go to https://gudhi.inria.fr/licensing/ for full license details. Author(s): Vincent Rouvreau @@ -10,6 +8,8 @@ from gudhi import SimplexTree - YYYY/MM Author: Description of the modification """ +from gudhi import SimplexTree + __author__ = "Vincent Rouvreau" __copyright__ = "Copyright (C) 2016 Inria" __license__ = "MIT" diff --git a/src/python/test/test_subsampling.py b/src/python/test/test_subsampling.py index c816e203..fe0985fa 100755 --- a/src/python/test/test_subsampling.py +++ b/src/python/test/test_subsampling.py @@ -1,5 +1,3 @@ -import gudhi - """ This file is part of the Gudhi Library - https://gudhi.inria.fr/ - which is released under MIT. See file LICENSE or go to https://gudhi.inria.fr/licensing/ for full license details. Author(s): Vincent Rouvreau @@ -10,6 +8,8 @@ import gudhi - YYYY/MM Author: Description of the modification """ +import gudhi + __author__ = "Vincent Rouvreau" __copyright__ = "Copyright (C) 2016 Inria" __license__ = "MIT" diff --git a/src/python/test/test_tangential_complex.py b/src/python/test/test_tangential_complex.py index 0f828d8e..e650e99c 100755 --- a/src/python/test/test_tangential_complex.py +++ b/src/python/test/test_tangential_complex.py @@ -1,5 +1,3 @@ -from gudhi import TangentialComplex, SimplexTree - """ This file is part of the Gudhi Library - https://gudhi.inria.fr/ - which is released under MIT. See file LICENSE or go to https://gudhi.inria.fr/licensing/ for full license details. Author(s): Vincent Rouvreau @@ -10,6 +8,8 @@ from gudhi import TangentialComplex, SimplexTree - YYYY/MM Author: Description of the modification """ +from gudhi import TangentialComplex, SimplexTree + __author__ = "Vincent Rouvreau" __copyright__ = "Copyright (C) 2016 Inria" __license__ = "MIT" diff --git a/src/python/test/test_wasserstein_distance.py b/src/python/test/test_wasserstein_distance.py index a6bf9901..bb59b3c2 100755 --- a/src/python/test/test_wasserstein_distance.py +++ b/src/python/test/test_wasserstein_distance.py @@ -1,6 +1,3 @@ -from gudhi.wasserstein import wasserstein_distance -import numpy as np - """ This file is part of the Gudhi Library - https://gudhi.inria.fr/ - which is released under MIT. See file LICENSE or go to https://gudhi.inria.fr/licensing/ for full license details. Author(s): Theo Lacombe @@ -11,6 +8,9 @@ import numpy as np - YYYY/MM Author: Description of the modification """ +from gudhi.wasserstein import wasserstein_distance +import numpy as np + __author__ = "Theo Lacombe" __copyright__ = "Copyright (C) 2019 Inria" __license__ = "MIT" diff --git a/src/python/test/test_witness_complex.py b/src/python/test/test_witness_complex.py index 36ced635..7baf18c9 100755 --- a/src/python/test/test_witness_complex.py +++ b/src/python/test/test_witness_complex.py @@ -1,5 +1,3 @@ -from gudhi import WitnessComplex, StrongWitnessComplex, SimplexTree - """ This file is part of the Gudhi Library - https://gudhi.inria.fr/ - which is released under MIT. See file LICENSE or go to https://gudhi.inria.fr/licensing/ for full license details. Author(s): Vincent Rouvreau @@ -10,6 +8,8 @@ from gudhi import WitnessComplex, StrongWitnessComplex, SimplexTree - YYYY/MM Author: Description of the modification """ +from gudhi import WitnessComplex, StrongWitnessComplex, SimplexTree + __author__ = "Vincent Rouvreau" __copyright__ = "Copyright (C) 2016 Inria" __license__ = "MIT" -- cgit v1.2.3 From b6e1d3025e27eed08eb8a1c5f95a80d6c6a9ce15 Mon Sep 17 00:00:00 2001 From: ROUVREAU Vincent Date: Mon, 13 Jan 2020 09:55:01 +0100 Subject: Fix #194 : Rename read_off as it only read points from OFF file --- src/python/doc/persistence_graphical_tools_user.rst | 2 +- src/python/doc/reader_utils_ref.rst | 2 +- src/python/doc/rips_complex_user.rst | 3 ++- src/python/doc/witness_complex_user.rst | 2 +- src/python/example/alpha_rips_persistence_bottleneck_distance.py | 2 +- ...strong_witness_complex_diagram_persistence_from_off_file_example.py | 2 +- ...lidean_witness_complex_diagram_persistence_from_off_file_example.py | 2 +- src/python/example/plot_rips_complex.py | 2 +- .../example/rips_complex_diagram_persistence_from_off_file_example.py | 2 +- src/python/gudhi/off_reader.pyx | 2 +- 10 files changed, 11 insertions(+), 10 deletions(-) (limited to 'src') diff --git a/src/python/doc/persistence_graphical_tools_user.rst b/src/python/doc/persistence_graphical_tools_user.rst index f41a926b..80002db6 100644 --- a/src/python/doc/persistence_graphical_tools_user.rst +++ b/src/python/doc/persistence_graphical_tools_user.rst @@ -24,7 +24,7 @@ This function can display the persistence result as a barcode: import gudhi off_file = gudhi.__root_source_dir__ + '/data/points/tore3D_300.off' - point_cloud = gudhi.read_off(off_file=off_file) + point_cloud = gudhi.read_points_from_off_file(off_file=off_file) rips_complex = gudhi.RipsComplex(points=point_cloud, max_edge_length=0.7) simplex_tree = rips_complex.create_simplex_tree(max_dimension=3) diff --git a/src/python/doc/reader_utils_ref.rst b/src/python/doc/reader_utils_ref.rst index f3ecebad..b8977a5a 100644 --- a/src/python/doc/reader_utils_ref.rst +++ b/src/python/doc/reader_utils_ref.rst @@ -6,7 +6,7 @@ Reader utils reference manual ============================= -.. autofunction:: gudhi.read_off +.. autofunction:: gudhi.read_points_from_off_file .. autofunction:: gudhi.read_lower_triangular_matrix_from_csv_file diff --git a/src/python/doc/rips_complex_user.rst b/src/python/doc/rips_complex_user.rst index a8659542..a27573e8 100644 --- a/src/python/doc/rips_complex_user.rst +++ b/src/python/doc/rips_complex_user.rst @@ -136,7 +136,8 @@ Finally, it is asked to display information about the Rips complex. .. testcode:: import gudhi - point_cloud = gudhi.read_off(off_file=gudhi.__root_source_dir__ + '/data/points/alphacomplexdoc.off') + off_file = gudhi.__root_source_dir__ + '/data/points/alphacomplexdoc.off' + point_cloud = gudhi.read_points_from_off_file(off_file = off_file) rips_complex = gudhi.RipsComplex(points=point_cloud, max_edge_length=12.0) simplex_tree = rips_complex.create_simplex_tree(max_dimension=1) result_str = 'Rips complex is of dimension ' + repr(simplex_tree.dimension()) + ' - ' + \ diff --git a/src/python/doc/witness_complex_user.rst b/src/python/doc/witness_complex_user.rst index 45ba5b3b..7087fa98 100644 --- a/src/python/doc/witness_complex_user.rst +++ b/src/python/doc/witness_complex_user.rst @@ -101,7 +101,7 @@ Let's start with a simple example, which reads an off point file and computes a print("#####################################################################") print("EuclideanWitnessComplex creation from points read in a OFF file") - witnesses = gudhi.read_off(off_file=args.file) + witnesses = gudhi.read_points_from_off_file(off_file=args.file) landmarks = gudhi.pick_n_random_points(points=witnesses, nb_points=args.number_of_landmarks) message = "EuclideanWitnessComplex with max_edge_length=" + repr(args.max_alpha_square) + \ diff --git a/src/python/example/alpha_rips_persistence_bottleneck_distance.py b/src/python/example/alpha_rips_persistence_bottleneck_distance.py index 086307ee..d5c33ec8 100755 --- a/src/python/example/alpha_rips_persistence_bottleneck_distance.py +++ b/src/python/example/alpha_rips_persistence_bottleneck_distance.py @@ -35,7 +35,7 @@ args = parser.parse_args() with open(args.file, "r") as f: first_line = f.readline() if (first_line == "OFF\n") or (first_line == "nOFF\n"): - point_cloud = gudhi.read_off(off_file=args.file) + point_cloud = gudhi.read_points_from_off_file(off_file=args.file) print("#####################################################################") print("RipsComplex creation from points read in a OFF file") diff --git a/src/python/example/euclidean_strong_witness_complex_diagram_persistence_from_off_file_example.py b/src/python/example/euclidean_strong_witness_complex_diagram_persistence_from_off_file_example.py index 0eedd140..4903667e 100755 --- a/src/python/example/euclidean_strong_witness_complex_diagram_persistence_from_off_file_example.py +++ b/src/python/example/euclidean_strong_witness_complex_diagram_persistence_from_off_file_example.py @@ -47,7 +47,7 @@ with open(args.file, "r") as f: print("#####################################################################") print("EuclideanStrongWitnessComplex creation from points read in a OFF file") - witnesses = gudhi.read_off(off_file=args.file) + witnesses = gudhi.read_points_from_off_file(off_file=args.file) landmarks = gudhi.pick_n_random_points( points=witnesses, nb_points=args.number_of_landmarks ) diff --git a/src/python/example/euclidean_witness_complex_diagram_persistence_from_off_file_example.py b/src/python/example/euclidean_witness_complex_diagram_persistence_from_off_file_example.py index 1fe55737..339a8577 100755 --- a/src/python/example/euclidean_witness_complex_diagram_persistence_from_off_file_example.py +++ b/src/python/example/euclidean_witness_complex_diagram_persistence_from_off_file_example.py @@ -46,7 +46,7 @@ with open(args.file, "r") as f: print("#####################################################################") print("EuclideanWitnessComplex creation from points read in a OFF file") - witnesses = gudhi.read_off(off_file=args.file) + witnesses = gudhi.read_points_from_off_file(off_file=args.file) landmarks = gudhi.pick_n_random_points( points=witnesses, nb_points=args.number_of_landmarks ) diff --git a/src/python/example/plot_rips_complex.py b/src/python/example/plot_rips_complex.py index 1c878db1..214a3c0a 100755 --- a/src/python/example/plot_rips_complex.py +++ b/src/python/example/plot_rips_complex.py @@ -2,7 +2,7 @@ import numpy as np import gudhi -points = np.array(gudhi.read_off('../../data/points/Kl.off')) +points = np.array(gudhi.read_points_from_off_file('../../data/points/Kl.off')) rc = gudhi.RipsComplex(points=points, max_edge_length=.2) st = rc.create_simplex_tree(max_dimension=2) # We are only going to plot the triangles diff --git a/src/python/example/rips_complex_diagram_persistence_from_off_file_example.py b/src/python/example/rips_complex_diagram_persistence_from_off_file_example.py index b9074cf9..c757aca7 100755 --- a/src/python/example/rips_complex_diagram_persistence_from_off_file_example.py +++ b/src/python/example/rips_complex_diagram_persistence_from_off_file_example.py @@ -48,7 +48,7 @@ with open(args.file, "r") as f: message = "RipsComplex with max_edge_length=" + repr(args.max_edge_length) print(message) - point_cloud = gudhi.read_off(off_file=args.file) + point_cloud = gudhi.read_points_from_off_file(off_file=args.file) rips_complex = gudhi.RipsComplex( points=point_cloud, max_edge_length=args.max_edge_length ) diff --git a/src/python/gudhi/off_reader.pyx b/src/python/gudhi/off_reader.pyx index 225e981c..ee369976 100644 --- a/src/python/gudhi/off_reader.pyx +++ b/src/python/gudhi/off_reader.pyx @@ -19,7 +19,7 @@ __license__ = "MIT" cdef extern from "Off_reader_interface.h" namespace "Gudhi": vector[vector[double]] read_points_from_OFF_file(string off_file) -def read_off(off_file=''): +def read_points_from_off_file(off_file=''): """Read points from OFF file. :param off_file: An OFF file style name. -- cgit v1.2.3 From 79bf59738ff9ee18824ae874b60138a6b26fd336 Mon Sep 17 00:00:00 2001 From: ROUVREAU Vincent Date: Mon, 13 Jan 2020 13:05:22 +0100 Subject: Add scikit-learn as a third party library as it is required by persistence representations --- src/python/doc/installation.rst | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'src') diff --git a/src/python/doc/installation.rst b/src/python/doc/installation.rst index 50a697c7..40f3f44b 100644 --- a/src/python/doc/installation.rst +++ b/src/python/doc/installation.rst @@ -257,6 +257,13 @@ The :doc:`Wasserstein distance ` module requires `POT `_, a library that provides several solvers for optimization problems related to Optimal Transport. +Scikit-learn +============ + +The :doc:`persistence representations ` module require +`scikit-learn `_, a Python-based ecosystem of +open-source software for machine learning. + SciPy ===== -- cgit v1.2.3 From e807654f30363ec92c0d24b702bfd081ec8aae5a Mon Sep 17 00:00:00 2001 From: tlacombe Date: Mon, 13 Jan 2020 15:13:35 +0100 Subject: update variable names, going for order and internal_p --- src/python/doc/wasserstein_distance_user.rst | 2 +- src/python/gudhi/wasserstein.py | 34 ++++++++++++++-------------- src/python/test/test_wasserstein_distance.py | 34 ++++++++++++++-------------- 3 files changed, 35 insertions(+), 35 deletions(-) (limited to 'src') diff --git a/src/python/doc/wasserstein_distance_user.rst b/src/python/doc/wasserstein_distance_user.rst index 8862a5ce..32999a0c 100644 --- a/src/python/doc/wasserstein_distance_user.rst +++ b/src/python/doc/wasserstein_distance_user.rst @@ -30,7 +30,7 @@ Note that persistence diagrams must be submitted as (n x 2) numpy arrays and mus diag1 = np.array([[2.7, 3.7],[9.6, 14.],[34.2, 34.974]]) diag2 = np.array([[2.8, 4.45],[9.5, 14.1]]) - message = "Wasserstein distance value = " + '%.2f' % gudhi.wasserstein.wasserstein_distance(diag1, diag2, internal_p=2., q=1.) + message = "Wasserstein distance value = " + '%.2f' % gudhi.wasserstein.wasserstein_distance(diag1, diag2, order=1., internal_p=2.) print(message) The output is: diff --git a/src/python/gudhi/wasserstein.py b/src/python/gudhi/wasserstein.py index 2acf93d6..aef54f64 100644 --- a/src/python/gudhi/wasserstein.py +++ b/src/python/gudhi/wasserstein.py @@ -23,12 +23,12 @@ def _proj_on_diag(X): return np.array([Z , Z]).T -def _build_dist_matrix(X, Y, q=2., internal_p=2.): +def _build_dist_matrix(X, Y, order=2., internal_p=2.): ''' :param X: (n x 2) numpy.array encoding the (points of the) first diagram. :param Y: (m x 2) numpy.array encoding the second diagram. :param internal_p: Ground metric (i.e. norm l_q). - :param q: exponent for the Wasserstein metric. + :param order: exponent for the Wasserstein metric. :returns: (n+1) x (m+1) np.array encoding the cost matrix C. For 1 <= i <= n, 1 <= j <= m, C[i,j] encodes the distance between X[i] and Y[j], while C[i, m+1] (resp. C[n+1, j]) encodes the distance (to the p) between X[i] (resp Y[j]) and its orthogonal proj onto the diagonal. note also that C[n+1, m+1] = 0 (it costs nothing to move from the diagonal to the diagonal). @@ -36,13 +36,13 @@ def _build_dist_matrix(X, Y, q=2., internal_p=2.): Xdiag = _proj_on_diag(X) Ydiag = _proj_on_diag(Y) if np.isinf(internal_p): - C = sc.cdist(X,Y, metric='chebyshev')**q - Cxd = np.linalg.norm(X - Xdiag, ord=internal_p, axis=1)**q - Cdy = np.linalg.norm(Y - Ydiag, ord=internal_p, axis=1)**q + C = sc.cdist(X,Y, metric='chebyshev')**order + Cxd = np.linalg.norm(X - Xdiag, ord=internal_p, axis=1)**order + Cdy = np.linalg.norm(Y - Ydiag, ord=internal_p, axis=1)**order else: - C = sc.cdist(X,Y, metric='minkowski', p=internal_p)**q - Cxd = np.linalg.norm(X - Xdiag, ord=internal_p, axis=1)**q - Cdy = np.linalg.norm(Y - Ydiag, ord=internal_p, axis=1)**q + C = sc.cdist(X,Y, metric='minkowski', p=internal_p)**order + Cxd = np.linalg.norm(X - Xdiag, ord=internal_p, axis=1)**order + Cdy = np.linalg.norm(Y - Ydiag, ord=internal_p, axis=1)**order Cf = np.hstack((C, Cxd[:,None])) Cdy = np.append(Cdy, 0) @@ -51,23 +51,23 @@ def _build_dist_matrix(X, Y, q=2., internal_p=2.): return Cf -def _perstot(X, q, internal_p): +def _perstot(X, order, internal_p): ''' :param X: (n x 2) numpy.array (points of a given diagram). :param internal_p: Ground metric on the (upper-half) plane (i.e. norm l_p in R^2); Default value is 2 (Euclidean norm). - :param q: exponent for Wasserstein; Default value is 2. + :param order: exponent for Wasserstein; Default value is 2. :returns: float, the total persistence of the diagram (that is, its distance to the empty diagram). ''' Xdiag = _proj_on_diag(X) - return (np.sum(np.linalg.norm(X - Xdiag, ord=internal_p, axis=1)**q))**(1./q) + return (np.sum(np.linalg.norm(X - Xdiag, ord=internal_p, axis=1)**order))**(1./order) -def wasserstein_distance(X, Y, q=2., internal_p=2.): +def wasserstein_distance(X, Y, order=2., internal_p=2.): ''' :param X: (n x 2) numpy.array encoding the (finite points of the) first diagram. Must not contain essential points (i.e. with infinite coordinate). :param Y: (m x 2) numpy.array encoding the second diagram. :param internal_p: Ground metric on the (upper-half) plane (i.e. norm l_p in R^2); Default value is 2 (euclidean norm). - :param q: exponent for Wasserstein; Default value is 2. + :param order: exponent for Wasserstein; Default value is 2. :returns: the q-Wasserstein distance (1 <= q < infinity) with respect to the internal_p-norm as ground metric. :rtype: float ''' @@ -79,11 +79,11 @@ def wasserstein_distance(X, Y, q=2., internal_p=2.): if Y.size == 0: return 0. else: - return _perstot(Y, q, internal_p) + return _perstot(Y, order, internal_p) elif Y.size == 0: - return _perstot(X, q, internal_p) + return _perstot(X, order, internal_p) - M = _build_dist_matrix(X, Y, q=q, internal_p=internal_p) + M = _build_dist_matrix(X, Y, order=order, internal_p=internal_p) a = np.full(n+1, 1. / (n + m) ) # weight vector of the input diagram. Uniform here. a[-1] = a[-1] * m # normalized so that we have a probability measure, required by POT b = np.full(m+1, 1. / (n + m) ) # weight vector of the input diagram. Uniform here. @@ -94,5 +94,5 @@ def wasserstein_distance(X, Y, q=2., internal_p=2.): # The default numItermax=100000 is not sufficient for some examples with 5000 points, what is a good value? ot_cost = (n+m) * ot.emd2(a, b, M, numItermax=2000000) - return ot_cost ** (1./q) + return ot_cost ** (1./order) diff --git a/src/python/test/test_wasserstein_distance.py b/src/python/test/test_wasserstein_distance.py index 40112c1b..602e4bf1 100755 --- a/src/python/test/test_wasserstein_distance.py +++ b/src/python/test/test_wasserstein_distance.py @@ -23,26 +23,26 @@ def test_basic_wasserstein(): diag4 = np.array([[0, 3], [4, 8]]) emptydiag = np.array([[]]) - assert wasserstein_distance(emptydiag, emptydiag, internal_p=2., q=1.) == 0. - assert wasserstein_distance(emptydiag, emptydiag, internal_p=np.inf, q=1.) == 0. - assert wasserstein_distance(emptydiag, emptydiag, internal_p=np.inf, q=2.) == 0. - assert wasserstein_distance(emptydiag, emptydiag, internal_p=2., q=2.) == 0. + assert wasserstein_distance(emptydiag, emptydiag, internal_p=2., order=1.) == 0. + assert wasserstein_distance(emptydiag, emptydiag, internal_p=np.inf, order=1.) == 0. + assert wasserstein_distance(emptydiag, emptydiag, internal_p=np.inf, order=2.) == 0. + assert wasserstein_distance(emptydiag, emptydiag, internal_p=2., order=2.) == 0. - assert wasserstein_distance(diag3, emptydiag, internal_p=np.inf, q=1.) == 2. - assert wasserstein_distance(diag3, emptydiag, internal_p=1., q=1.) == 4. + assert wasserstein_distance(diag3, emptydiag, internal_p=np.inf, order=1.) == 2. + assert wasserstein_distance(diag3, emptydiag, internal_p=1., order=1.) == 4. - assert wasserstein_distance(diag4, emptydiag, internal_p=1., q=2.) == 5. # thank you Pythagorician triplets - assert wasserstein_distance(diag4, emptydiag, internal_p=np.inf, q=2.) == 2.5 - assert wasserstein_distance(diag4, emptydiag, internal_p=2., q=2.) == 3.5355339059327378 + assert wasserstein_distance(diag4, emptydiag, internal_p=1., order=2.) == 5. # thank you Pythagorician triplets + assert wasserstein_distance(diag4, emptydiag, internal_p=np.inf, order=2.) == 2.5 + assert wasserstein_distance(diag4, emptydiag, internal_p=2., order=2.) == 3.5355339059327378 - assert wasserstein_distance(diag1, diag2, internal_p=2., q=1.) == 1.4453593023967701 - assert wasserstein_distance(diag1, diag2, internal_p=2.35, q=1.74) == 0.9772734057168739 + assert wasserstein_distance(diag1, diag2, internal_p=2., order=1.) == 1.4453593023967701 + assert wasserstein_distance(diag1, diag2, internal_p=2.35, order=1.74) == 0.9772734057168739 - assert wasserstein_distance(diag1, emptydiag, internal_p=2.35, q=1.7863) == 3.141592214572228 + assert wasserstein_distance(diag1, emptydiag, internal_p=2.35, order=1.7863) == 3.141592214572228 - assert wasserstein_distance(diag3, diag4, internal_p=1., q=1.) == 3. - assert wasserstein_distance(diag3, diag4, internal_p=np.inf, q=1.) == 3. # no diag matching here - assert wasserstein_distance(diag3, diag4, internal_p=np.inf, q=2.) == np.sqrt(5) - assert wasserstein_distance(diag3, diag4, internal_p=1., q=2.) == np.sqrt(5) - assert wasserstein_distance(diag3, diag4, internal_p=4.5, q=2.) == np.sqrt(5) + assert wasserstein_distance(diag3, diag4, internal_p=1., order=1.) == 3. + assert wasserstein_distance(diag3, diag4, internal_p=np.inf, order=1.) == 3. # no diag matching here + assert wasserstein_distance(diag3, diag4, internal_p=np.inf, order=2.) == np.sqrt(5) + assert wasserstein_distance(diag3, diag4, internal_p=1., order=2.) == np.sqrt(5) + assert wasserstein_distance(diag3, diag4, internal_p=4.5, order=2.) == np.sqrt(5) -- cgit v1.2.3 From cabafa3852c2d325b83593d34f16dfbc2d9eaefb Mon Sep 17 00:00:00 2001 From: tlacombe Date: Mon, 13 Jan 2020 17:30:38 +0100 Subject: fix typo in doc wasserstein_distance with new variables naming conventions. --- src/python/gudhi/wasserstein.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/python/gudhi/wasserstein.py b/src/python/gudhi/wasserstein.py index aef54f64..b6495c80 100644 --- a/src/python/gudhi/wasserstein.py +++ b/src/python/gudhi/wasserstein.py @@ -55,7 +55,7 @@ def _perstot(X, order, internal_p): ''' :param X: (n x 2) numpy.array (points of a given diagram). :param internal_p: Ground metric on the (upper-half) plane (i.e. norm l_p in R^2); Default value is 2 (Euclidean norm). - :param order: exponent for Wasserstein; Default value is 2. + :param order: exponent for Wasserstein. Default value is 2. :returns: float, the total persistence of the diagram (that is, its distance to the empty diagram). ''' Xdiag = _proj_on_diag(X) @@ -68,7 +68,7 @@ def wasserstein_distance(X, Y, order=2., internal_p=2.): :param Y: (m x 2) numpy.array encoding the second diagram. :param internal_p: Ground metric on the (upper-half) plane (i.e. norm l_p in R^2); Default value is 2 (euclidean norm). :param order: exponent for Wasserstein; Default value is 2. - :returns: the q-Wasserstein distance (1 <= q < infinity) with respect to the internal_p-norm as ground metric. + :returns: the Wasserstein distance of order q (1 <= q < infinity) between persistence diagrams with respect to the internal_p-norm as ground metric. :rtype: float ''' n = len(X) -- cgit v1.2.3 From 9bbbc84ab7208ccd69934445202538e34439b304 Mon Sep 17 00:00:00 2001 From: Théo Lacombe Date: Mon, 13 Jan 2020 17:39:02 +0100 Subject: Update src/python/gudhi/wasserstein.py Co-Authored-By: Marc Glisse --- src/python/gudhi/wasserstein.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) (limited to 'src') diff --git a/src/python/gudhi/wasserstein.py b/src/python/gudhi/wasserstein.py index b6495c80..3eb7faef 100644 --- a/src/python/gudhi/wasserstein.py +++ b/src/python/gudhi/wasserstein.py @@ -27,7 +27,7 @@ def _build_dist_matrix(X, Y, order=2., internal_p=2.): ''' :param X: (n x 2) numpy.array encoding the (points of the) first diagram. :param Y: (m x 2) numpy.array encoding the second diagram. - :param internal_p: Ground metric (i.e. norm l_q). + :param internal_p: Ground metric (i.e. norm l_p). :param order: exponent for the Wasserstein metric. :returns: (n+1) x (m+1) np.array encoding the cost matrix C. For 1 <= i <= n, 1 <= j <= m, C[i,j] encodes the distance between X[i] and Y[j], while C[i, m+1] (resp. C[n+1, j]) encodes the distance (to the p) between X[i] (resp Y[j]) and its orthogonal proj onto the diagonal. @@ -95,4 +95,3 @@ def wasserstein_distance(X, Y, order=2., internal_p=2.): ot_cost = (n+m) * ot.emd2(a, b, M, numItermax=2000000) return ot_cost ** (1./order) - -- cgit v1.2.3 From 95c34035645e788d98a3fa6b059ad48024596906 Mon Sep 17 00:00:00 2001 From: ROUVREAU Vincent Date: Wed, 15 Jan 2020 10:20:22 +0100 Subject: In python2 itertools zip_longest is named izip_longest --- src/python/test/test_alpha_complex.py | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/python/test/test_alpha_complex.py b/src/python/test/test_alpha_complex.py index 712a50b6..0d9e9e45 100755 --- a/src/python/test/test_alpha_complex.py +++ b/src/python/test/test_alpha_complex.py @@ -11,8 +11,13 @@ from gudhi import AlphaComplex, SimplexTree import math import numpy as np -import itertools import pytest +try: + # python3 + from itertools import zip_longest +except ImportError: + # python2 + from itertools import izip_longest as zip_longest __author__ = "Vincent Rouvreau" __copyright__ = "Copyright (C) 2016 Inria" @@ -114,6 +119,6 @@ def test_safe_alpha_persistence_comparison(): diag1 = simplex_tree1.persistence() diag2 = simplex_tree2.persistence() - for (first_p, second_p) in itertools.zip_longest(diag1, diag2): + for (first_p, second_p) in zip_longest(diag1, diag2): assert first_p[0] == pytest.approx(second_p[0]) assert first_p[1] == pytest.approx(second_p[1]) -- cgit v1.2.3 From e1255fe356f1ff97533b33caa6179737a64c4898 Mon Sep 17 00:00:00 2001 From: ROUVREAU Vincent Date: Wed, 15 Jan 2020 10:22:21 +0100 Subject: Fix #96 : set language_level. It does not work when using compiler_directives of cythonize. --- src/python/setup.py.in | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/python/setup.py.in b/src/python/setup.py.in index 24d05025..9c2124f4 100644 --- a/src/python/setup.py.in +++ b/src/python/setup.py.in @@ -11,6 +11,7 @@ from setuptools import setup, Extension from Cython.Build import cythonize from numpy import get_include as numpy_get_include +import sys __author__ = "Vincent Rouvreau" __copyright__ = "Copyright (C) 2016 Inria" @@ -38,7 +39,8 @@ for module in modules: libraries=libraries, library_dirs=library_dirs, include_dirs=include_dirs, - runtime_library_dirs=runtime_library_dirs,)) + runtime_library_dirs=runtime_library_dirs, + cython_directives = {'language_level': str(sys.version_info[0])},)) setup( name = 'gudhi', -- cgit v1.2.3 From d747facccbe835be1384e569cf3d6e4c335c0364 Mon Sep 17 00:00:00 2001 From: ROUVREAU Vincent Date: Wed, 15 Jan 2020 10:23:58 +0100 Subject: In python2, does not work. is ok for Python 2 and 3 --- src/python/gudhi/alpha_complex.pyx | 2 +- src/python/gudhi/cubical_complex.pyx | 2 +- src/python/gudhi/nerve_gic.pyx | 12 ++++++------ src/python/gudhi/off_reader.pyx | 2 +- src/python/gudhi/periodic_cubical_complex.pyx | 2 +- src/python/gudhi/reader_utils.pyx | 8 ++++---- src/python/gudhi/simplex_tree.pyx | 2 +- src/python/gudhi/subsampling.pyx | 8 ++++---- src/python/gudhi/tangential_complex.pyx | 2 +- 9 files changed, 20 insertions(+), 20 deletions(-) (limited to 'src') diff --git a/src/python/gudhi/alpha_complex.pyx b/src/python/gudhi/alpha_complex.pyx index db11416c..f3ca3dd5 100644 --- a/src/python/gudhi/alpha_complex.pyx +++ b/src/python/gudhi/alpha_complex.pyx @@ -69,7 +69,7 @@ cdef class AlphaComplex: def __cinit__(self, points = None, off_file = ''): if off_file: if os.path.isfile(off_file): - self.thisptr = new Alpha_complex_interface(str.encode(off_file), True) + self.thisptr = new Alpha_complex_interface(off_file.encode('utf-8'), True) else: print("file " + off_file + " not found.") else: diff --git a/src/python/gudhi/cubical_complex.pyx b/src/python/gudhi/cubical_complex.pyx index 92ff6411..cbeda014 100644 --- a/src/python/gudhi/cubical_complex.pyx +++ b/src/python/gudhi/cubical_complex.pyx @@ -85,7 +85,7 @@ cdef class CubicalComplex: elif ((dimensions is None) and (top_dimensional_cells is None) and (perseus_file != '')): if os.path.isfile(perseus_file): - self.thisptr = new Bitmap_cubical_complex_base_interface(str.encode(perseus_file)) + self.thisptr = new Bitmap_cubical_complex_base_interface(perseus_file.encode('utf-8')) else: print("file " + perseus_file + " not found.") else: diff --git a/src/python/gudhi/nerve_gic.pyx b/src/python/gudhi/nerve_gic.pyx index 68c06432..382e71c5 100644 --- a/src/python/gudhi/nerve_gic.pyx +++ b/src/python/gudhi/nerve_gic.pyx @@ -180,7 +180,7 @@ cdef class CoverComplex: :returns: Read file status. """ if os.path.isfile(off_file): - return self.thisptr.read_point_cloud(str.encode(off_file)) + return self.thisptr.read_point_cloud(off_file.encode('utf-8')) else: print("file " + off_file + " not found.") return False @@ -212,7 +212,7 @@ cdef class CoverComplex: :type color_file_name: string """ if os.path.isfile(color_file_name): - self.thisptr.set_color_from_file(str.encode(color_file_name)) + self.thisptr.set_color_from_file(color_file_name.encode('utf-8')) else: print("file " + color_file_name + " not found.") @@ -233,7 +233,7 @@ cdef class CoverComplex: :type cover_file_name: string """ if os.path.isfile(cover_file_name): - self.thisptr.set_cover_from_file(str.encode(cover_file_name)) + self.thisptr.set_cover_from_file(cover_file_name.encode('utf-8')) else: print("file " + cover_file_name + " not found.") @@ -266,7 +266,7 @@ cdef class CoverComplex: :type func_file_name: string """ if os.path.isfile(func_file_name): - self.thisptr.set_function_from_file(str.encode(func_file_name)) + self.thisptr.set_function_from_file(func_file_name.encode('utf-8')) else: print("file " + func_file_name + " not found.") @@ -307,7 +307,7 @@ cdef class CoverComplex: :type graph_file_name: string """ if os.path.isfile(graph_file_name): - self.thisptr.set_graph_from_file(str.encode(graph_file_name)) + self.thisptr.set_graph_from_file(graph_file_name.encode('utf-8')) else: print("file " + graph_file_name + " not found.") @@ -368,7 +368,7 @@ cdef class CoverComplex: :param type: either "GIC" or "Nerve". :type type: string """ - self.thisptr.set_type(str.encode(type)) + self.thisptr.set_type(type.encode('utf-8')) def set_verbose(self, verbose): """Specifies whether the program should display information or not. diff --git a/src/python/gudhi/off_reader.pyx b/src/python/gudhi/off_reader.pyx index 58f05db8..a0d5bf25 100644 --- a/src/python/gudhi/off_reader.pyx +++ b/src/python/gudhi/off_reader.pyx @@ -30,7 +30,7 @@ def read_points_from_off_file(off_file=''): """ if off_file: if os.path.isfile(off_file): - return read_points_from_OFF_file(str.encode(off_file)) + return read_points_from_OFF_file(off_file.encode('utf-8')) else: print("file " + off_file + " not found.") return [] diff --git a/src/python/gudhi/periodic_cubical_complex.pyx b/src/python/gudhi/periodic_cubical_complex.pyx index b5dece10..37f76201 100644 --- a/src/python/gudhi/periodic_cubical_complex.pyx +++ b/src/python/gudhi/periodic_cubical_complex.pyx @@ -93,7 +93,7 @@ cdef class PeriodicCubicalComplex: elif ((dimensions is None) and (top_dimensional_cells is None) and (periodic_dimensions is None) and (perseus_file != '')): if os.path.isfile(perseus_file): - self.thisptr = new Periodic_cubical_complex_base_interface(str.encode(perseus_file)) + self.thisptr = new Periodic_cubical_complex_base_interface(perseus_file.encode('utf-8')) else: print("file " + perseus_file + " not found.") else: diff --git a/src/python/gudhi/reader_utils.pyx b/src/python/gudhi/reader_utils.pyx index 345c92f8..d6033b86 100644 --- a/src/python/gudhi/reader_utils.pyx +++ b/src/python/gudhi/reader_utils.pyx @@ -38,7 +38,7 @@ def read_lower_triangular_matrix_from_csv_file(csv_file='', separator=';'): """ if csv_file: if path.isfile(csv_file): - return read_matrix_from_csv_file(str.encode(csv_file), ord(separator[0])) + return read_matrix_from_csv_file(csv_file.encode('utf-8'), ord(separator[0])) print("file " + csv_file + " not set or not found.") return [] @@ -57,7 +57,7 @@ def read_persistence_intervals_grouped_by_dimension(persistence_file=''): """ if persistence_file: if path.isfile(persistence_file): - return read_pers_intervals_grouped_by_dimension(str.encode(persistence_file)) + return read_pers_intervals_grouped_by_dimension(persistence_file.encode('utf-8')) print("file " + persistence_file + " not set or not found.") return [] @@ -80,7 +80,7 @@ def read_persistence_intervals_in_dimension(persistence_file='', only_this_dim=- """ if persistence_file: if path.isfile(persistence_file): - return np_array(read_pers_intervals_in_dimension(str.encode( - persistence_file), only_this_dim)) + return np_array(read_pers_intervals_in_dimension(persistence_file.encode( + 'utf-8'), only_this_dim)) print("file " + persistence_file + " not set or not found.") return [] diff --git a/src/python/gudhi/simplex_tree.pyx b/src/python/gudhi/simplex_tree.pyx index 85d25492..b18627c4 100644 --- a/src/python/gudhi/simplex_tree.pyx +++ b/src/python/gudhi/simplex_tree.pyx @@ -508,7 +508,7 @@ cdef class SimplexTree: """ if self.pcohptr != NULL: if persistence_file != '': - self.pcohptr.write_output_diagram(str.encode(persistence_file)) + self.pcohptr.write_output_diagram(persistence_file.encode('utf-8')) else: print("persistence_file must be specified") else: diff --git a/src/python/gudhi/subsampling.pyx b/src/python/gudhi/subsampling.pyx index b1812087..c501d16b 100644 --- a/src/python/gudhi/subsampling.pyx +++ b/src/python/gudhi/subsampling.pyx @@ -52,10 +52,10 @@ def choose_n_farthest_points(points=None, off_file='', nb_points=0, starting_poi if off_file: if os.path.isfile(off_file): if starting_point == '': - return subsampling_n_farthest_points_from_file(str.encode(off_file), + return subsampling_n_farthest_points_from_file(off_file.encode('utf-8'), nb_points) else: - return subsampling_n_farthest_points_from_file(str.encode(off_file), + return subsampling_n_farthest_points_from_file(off_file.encode('utf-8'), nb_points, starting_point) else: @@ -88,7 +88,7 @@ def pick_n_random_points(points=None, off_file='', nb_points=0): """ if off_file: if os.path.isfile(off_file): - return subsampling_n_random_points_from_file(str.encode(off_file), + return subsampling_n_random_points_from_file(off_file.encode('utf-8'), nb_points) else: print("file " + off_file + " not found.") @@ -118,7 +118,7 @@ def sparsify_point_set(points=None, off_file='', min_squared_dist=0.0): """ if off_file: if os.path.isfile(off_file): - return subsampling_sparsify_points_from_file(str.encode(off_file), + return subsampling_sparsify_points_from_file(off_file.encode('utf-8'), min_squared_dist) else: print("file " + off_file + " not found.") diff --git a/src/python/gudhi/tangential_complex.pyx b/src/python/gudhi/tangential_complex.pyx index 0083033c..6391488c 100644 --- a/src/python/gudhi/tangential_complex.pyx +++ b/src/python/gudhi/tangential_complex.pyx @@ -66,7 +66,7 @@ cdef class TangentialComplex: def __cinit__(self, intrisic_dim, points=None, off_file=''): if off_file: if os.path.isfile(off_file): - self.thisptr = new Tangential_complex_interface(intrisic_dim, str.encode(off_file), True) + self.thisptr = new Tangential_complex_interface(intrisic_dim, off_file.encode('utf-8'), True) else: print("file " + off_file + " not found.") else: -- cgit v1.2.3 From f8a5efa165241b9e27f06431e4919322b359ddb2 Mon Sep 17 00:00:00 2001 From: ROUVREAU Vincent Date: Fri, 17 Jan 2020 09:13:37 +0100 Subject: No need to copy code conventions in user version --- src/cmake/modules/GUDHI_user_version_target.cmake | 2 -- 1 file changed, 2 deletions(-) (limited to 'src') diff --git a/src/cmake/modules/GUDHI_user_version_target.cmake b/src/cmake/modules/GUDHI_user_version_target.cmake index 4fa74330..0b361a0f 100644 --- a/src/cmake/modules/GUDHI_user_version_target.cmake +++ b/src/cmake/modules/GUDHI_user_version_target.cmake @@ -32,8 +32,6 @@ file(COPY "${CMAKE_SOURCE_DIR}/biblio/bibliography.bib" DESTINATION "${CMAKE_CUR add_custom_command(TARGET user_version PRE_BUILD COMMAND ${CMAKE_COMMAND} -E copy_directory ${CMAKE_CURRENT_BINARY_DIR}/biblio ${GUDHI_USER_VERSION_DIR}/biblio) -add_custom_command(TARGET user_version PRE_BUILD COMMAND ${CMAKE_COMMAND} -E - copy ${CMAKE_SOURCE_DIR}/Conventions.txt ${GUDHI_USER_VERSION_DIR}/Conventions.txt) add_custom_command(TARGET user_version PRE_BUILD COMMAND ${CMAKE_COMMAND} -E copy ${CMAKE_SOURCE_DIR}/README.md ${GUDHI_USER_VERSION_DIR}/README.md) add_custom_command(TARGET user_version PRE_BUILD COMMAND ${CMAKE_COMMAND} -E -- cgit v1.2.3 From f5e49792f809b198908a67e674672a676c0877ec Mon Sep 17 00:00:00 2001 From: Marc Glisse Date: Sat, 18 Jan 2020 22:56:22 +0100 Subject: Separate optional arguments from common arguments I copy-pasted what is done in RipsComplex. Before that, sphinx was grouping nb_points with off_file, as if it couldn't be used with points. --- src/python/gudhi/subsampling.pyx | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'src') diff --git a/src/python/gudhi/subsampling.pyx b/src/python/gudhi/subsampling.pyx index 4c84cb03..f77c6f75 100644 --- a/src/python/gudhi/subsampling.pyx +++ b/src/python/gudhi/subsampling.pyx @@ -40,6 +40,8 @@ def choose_n_farthest_points(points=None, off_file='', nb_points=0, starting_poi :param off_file: An OFF file style name. :type off_file: string + And in both cases + :param nb_points: Number of points of the subsample. :type nb_points: unsigned. :param starting_point: The iteration starts with the landmark `starting \ @@ -81,6 +83,8 @@ def pick_n_random_points(points=None, off_file='', nb_points=0): :param off_file: An OFF file style name. :type off_file: string + And in both cases + :param nb_points: Number of points of the subsample. :type nb_points: unsigned. :returns: The subsample point set. @@ -110,6 +114,8 @@ def sparsify_point_set(points=None, off_file='', min_squared_dist=0.0): :param off_file: An OFF file style name. :type off_file: string + And in both cases + :param min_squared_dist: Minimum squared distance separating the output \ points. :type min_squared_dist: float. -- cgit v1.2.3 From b36d27e63a6e60e3b84346aa3b3a95014b30068e Mon Sep 17 00:00:00 2001 From: Marc Glisse Date: Thu, 21 Nov 2019 23:49:07 +0100 Subject: Sprinkle some "except +" in cython files --- src/python/gudhi/alpha_complex.pyx | 11 +++++------ src/python/gudhi/euclidean_strong_witness_complex.pyx | 4 ++-- src/python/gudhi/euclidean_witness_complex.pyx | 4 ++-- src/python/gudhi/rips_complex.pyx | 2 +- src/python/gudhi/simplex_tree.pxd | 2 +- src/python/gudhi/strong_witness_complex.pyx | 4 ++-- src/python/gudhi/witness_complex.pyx | 4 ++-- src/python/include/Alpha_complex_interface.h | 10 +++------- 8 files changed, 18 insertions(+), 23 deletions(-) (limited to 'src') diff --git a/src/python/gudhi/alpha_complex.pyx b/src/python/gudhi/alpha_complex.pyx index f3ca3dd5..fff3e920 100644 --- a/src/python/gudhi/alpha_complex.pyx +++ b/src/python/gudhi/alpha_complex.pyx @@ -24,11 +24,11 @@ __license__ = "GPL v3" cdef extern from "Alpha_complex_interface.h" namespace "Gudhi": cdef cppclass Alpha_complex_interface "Gudhi::alpha_complex::Alpha_complex_interface": - Alpha_complex_interface(vector[vector[double]] points) + Alpha_complex_interface(vector[vector[double]] points) except + # bool from_file is a workaround for cython to find the correct signature - Alpha_complex_interface(string off_file, bool from_file) - vector[double] get_point(int vertex) - void create_simplex_tree(Simplex_tree_interface_full_featured* simplex_tree, double max_alpha_square) + Alpha_complex_interface(string off_file, bool from_file) except + + vector[double] get_point(int vertex) except + + void create_simplex_tree(Simplex_tree_interface_full_featured* simplex_tree, double max_alpha_square) except + # AlphaComplex python interface cdef class AlphaComplex: @@ -96,8 +96,7 @@ cdef class AlphaComplex: :rtype: list of float :returns: the point. """ - cdef vector[double] point = self.thisptr.get_point(vertex) - return point + return self.thisptr.get_point(vertex) def create_simplex_tree(self, max_alpha_square = float('inf')): """ diff --git a/src/python/gudhi/euclidean_strong_witness_complex.pyx b/src/python/gudhi/euclidean_strong_witness_complex.pyx index 9889f92c..aca6084e 100644 --- a/src/python/gudhi/euclidean_strong_witness_complex.pyx +++ b/src/python/gudhi/euclidean_strong_witness_complex.pyx @@ -22,9 +22,9 @@ __license__ = "GPL v3" cdef extern from "Euclidean_strong_witness_complex_interface.h" namespace "Gudhi": cdef cppclass Euclidean_strong_witness_complex_interface "Gudhi::witness_complex::Euclidean_strong_witness_complex_interface": Euclidean_strong_witness_complex_interface(vector[vector[double]] landmarks, vector[vector[double]] witnesses) - void create_simplex_tree(Simplex_tree_interface_full_featured* simplex_tree, double max_alpha_square) + void create_simplex_tree(Simplex_tree_interface_full_featured* simplex_tree, double max_alpha_square) except + void create_simplex_tree(Simplex_tree_interface_full_featured* simplex_tree, double max_alpha_square, - unsigned limit_dimension) + unsigned limit_dimension) except + vector[double] get_point(unsigned vertex) # EuclideanStrongWitnessComplex python interface diff --git a/src/python/gudhi/euclidean_witness_complex.pyx b/src/python/gudhi/euclidean_witness_complex.pyx index e3ce0e82..fb0c2201 100644 --- a/src/python/gudhi/euclidean_witness_complex.pyx +++ b/src/python/gudhi/euclidean_witness_complex.pyx @@ -22,9 +22,9 @@ __license__ = "GPL v3" cdef extern from "Euclidean_witness_complex_interface.h" namespace "Gudhi": cdef cppclass Euclidean_witness_complex_interface "Gudhi::witness_complex::Euclidean_witness_complex_interface": Euclidean_witness_complex_interface(vector[vector[double]] landmarks, vector[vector[double]] witnesses) - void create_simplex_tree(Simplex_tree_interface_full_featured* simplex_tree, double max_alpha_square) + void create_simplex_tree(Simplex_tree_interface_full_featured* simplex_tree, double max_alpha_square) except + void create_simplex_tree(Simplex_tree_interface_full_featured* simplex_tree, double max_alpha_square, - unsigned limit_dimension) + unsigned limit_dimension) except + vector[double] get_point(unsigned vertex) # EuclideanWitnessComplex python interface diff --git a/src/python/gudhi/rips_complex.pyx b/src/python/gudhi/rips_complex.pyx index 722cdcdc..deb8057a 100644 --- a/src/python/gudhi/rips_complex.pyx +++ b/src/python/gudhi/rips_complex.pyx @@ -28,7 +28,7 @@ cdef extern from "Rips_complex_interface.h" namespace "Gudhi": void init_matrix(vector[vector[double]] values, double threshold) void init_points_sparse(vector[vector[double]] values, double threshold, double sparse) void init_matrix_sparse(vector[vector[double]] values, double threshold, double sparse) - void create_simplex_tree(Simplex_tree_interface_full_featured* simplex_tree, int dim_max) + void create_simplex_tree(Simplex_tree_interface_full_featured* simplex_tree, int dim_max) except + # RipsComplex python interface cdef class RipsComplex: diff --git a/src/python/gudhi/simplex_tree.pxd b/src/python/gudhi/simplex_tree.pxd index 1066d44b..96d14079 100644 --- a/src/python/gudhi/simplex_tree.pxd +++ b/src/python/gudhi/simplex_tree.pxd @@ -39,7 +39,7 @@ cdef extern from "Simplex_tree_interface.h" namespace "Gudhi": vector[pair[vector[int], double]] get_star(vector[int] simplex) vector[pair[vector[int], double]] get_cofaces(vector[int] simplex, int dimension) - void expansion(int max_dim) + void expansion(int max_dim) except + void remove_maximal_simplex(vector[int] simplex) bool prune_above_filtration(double filtration) bool make_filtration_non_decreasing() diff --git a/src/python/gudhi/strong_witness_complex.pyx b/src/python/gudhi/strong_witness_complex.pyx index 2c33c3f2..9f89d3ae 100644 --- a/src/python/gudhi/strong_witness_complex.pyx +++ b/src/python/gudhi/strong_witness_complex.pyx @@ -22,9 +22,9 @@ __license__ = "MIT" cdef extern from "Strong_witness_complex_interface.h" namespace "Gudhi": cdef cppclass Strong_witness_complex_interface "Gudhi::witness_complex::Strong_witness_complex_interface": Strong_witness_complex_interface(vector[vector[pair[size_t, double]]] nearest_landmark_table) - void create_simplex_tree(Simplex_tree_interface_full_featured* simplex_tree, double max_alpha_square) + void create_simplex_tree(Simplex_tree_interface_full_featured* simplex_tree, double max_alpha_square) except + void create_simplex_tree(Simplex_tree_interface_full_featured* simplex_tree, double max_alpha_square, - unsigned limit_dimension) + unsigned limit_dimension) except + # StrongWitnessComplex python interface cdef class StrongWitnessComplex: diff --git a/src/python/gudhi/witness_complex.pyx b/src/python/gudhi/witness_complex.pyx index b032a5a1..e589d006 100644 --- a/src/python/gudhi/witness_complex.pyx +++ b/src/python/gudhi/witness_complex.pyx @@ -22,9 +22,9 @@ __license__ = "MIT" cdef extern from "Witness_complex_interface.h" namespace "Gudhi": cdef cppclass Witness_complex_interface "Gudhi::witness_complex::Witness_complex_interface": Witness_complex_interface(vector[vector[pair[size_t, double]]] nearest_landmark_table) - void create_simplex_tree(Simplex_tree_interface_full_featured* simplex_tree, double max_alpha_square) + void create_simplex_tree(Simplex_tree_interface_full_featured* simplex_tree, double max_alpha_square) except + void create_simplex_tree(Simplex_tree_interface_full_featured* simplex_tree, double max_alpha_square, - unsigned limit_dimension) + unsigned limit_dimension) except + # WitnessComplex python interface cdef class WitnessComplex: diff --git a/src/python/include/Alpha_complex_interface.h b/src/python/include/Alpha_complex_interface.h index e9bbadb0..8614eee3 100644 --- a/src/python/include/Alpha_complex_interface.h +++ b/src/python/include/Alpha_complex_interface.h @@ -50,13 +50,9 @@ class Alpha_complex_interface { std::vector get_point(int vh) { std::vector vd; - try { - Point_d const& ph = alpha_complex_->get_point(vh); - for (auto coord = ph.cartesian_begin(); coord != ph.cartesian_end(); coord++) - vd.push_back(CGAL::to_double(*coord)); - } catch (std::out_of_range const&) { - // std::out_of_range is thrown in case not found. Other exceptions must be re-thrown - } + Point_d const& ph = alpha_complex_->get_point(vh); + for (auto coord = ph.cartesian_begin(); coord != ph.cartesian_end(); coord++) + vd.push_back(CGAL::to_double(*coord)); return vd; } -- cgit v1.2.3 From d9bdb64a5bc016c5bc34f95f29773050e90aa7ed Mon Sep 17 00:00:00 2001 From: Marc Glisse Date: Fri, 22 Nov 2019 00:14:08 +0100 Subject: Adapt tests It is still failing by default, until I touch alpha_complex.pyx and rebuild it, after which it works ?! --- .../example/alpha_complex_from_points_example.py | 7 +++++- src/python/test/test_alpha_complex.py | 28 ++++++++++++++++++---- 2 files changed, 30 insertions(+), 5 deletions(-) (limited to 'src') diff --git a/src/python/example/alpha_complex_from_points_example.py b/src/python/example/alpha_complex_from_points_example.py index a746998c..844d7a82 100755 --- a/src/python/example/alpha_complex_from_points_example.py +++ b/src/python/example/alpha_complex_from_points_example.py @@ -52,4 +52,9 @@ print("star([0])=", simplex_tree.get_star([0])) print("coface([0], 1)=", simplex_tree.get_cofaces([0], 1)) print("point[0]=", alpha_complex.get_point(0)) -print("point[5]=", alpha_complex.get_point(5)) +try: + print("point[5]=", alpha_complex.get_point(5)) +except IndexError: + pass +else: + assert False diff --git a/src/python/test/test_alpha_complex.py b/src/python/test/test_alpha_complex.py index 0d9e9e45..3761fe16 100755 --- a/src/python/test/test_alpha_complex.py +++ b/src/python/test/test_alpha_complex.py @@ -65,8 +65,18 @@ def test_infinite_alpha(): assert point_list[1] == alpha_complex.get_point(1) assert point_list[2] == alpha_complex.get_point(2) assert point_list[3] == alpha_complex.get_point(3) - assert alpha_complex.get_point(4) == [] - assert alpha_complex.get_point(125) == [] + try: + alpha_complex.get_point(4) == [] + except IndexError: + pass + else: + assert False + try: + alpha_complex.get_point(125) == [] + except IndexError: + pass + else: + assert False def test_filtered_alpha(): @@ -82,8 +92,18 @@ def test_filtered_alpha(): assert point_list[1] == filtered_alpha.get_point(1) assert point_list[2] == filtered_alpha.get_point(2) assert point_list[3] == filtered_alpha.get_point(3) - assert filtered_alpha.get_point(4) == [] - assert filtered_alpha.get_point(125) == [] + try: + filtered_alpha.get_point(4) == [] + except IndexError: + pass + else: + assert False + try: + filtered_alpha.get_point(125) == [] + except IndexError: + pass + else: + assert False assert simplex_tree.get_filtration() == [ ([0], 0.0), -- cgit v1.2.3 From 6ee77c3da821256459406e87024077c48419a493 Mon Sep 17 00:00:00 2001 From: Marc Glisse Date: Mon, 20 Jan 2020 20:03:56 +0100 Subject: Shuffle the modules on the main page --- src/common/doc/main_page.md | 253 +++++++++++++++++++++----------------------- 1 file changed, 123 insertions(+), 130 deletions(-) (limited to 'src') diff --git a/src/common/doc/main_page.md b/src/common/doc/main_page.md index 0b4bfb7a..768c5794 100644 --- a/src/common/doc/main_page.md +++ b/src/common/doc/main_page.md @@ -4,8 +4,8 @@ \image html "Gudhi_banner.png"



-## Complexes {#Complexes} -### Cubical complex +## Data structures for cell complexes {#Complexes} +### Cubical complexes @@ -29,246 +29,269 @@
-### Simplicial complex - -#### Alpha complex +### Simplicial complexes +#### Simplex tree
- \image html "alpha_complex_representation.png" + \image html "Simplex_tree_representation.png" - Alpha complex is a simplicial complex constructed from the finite cells of a Delaunay Triangulation.
- The filtration value of each simplex is computed as the square of the circumradius of the simplex if the - circumsphere is empty (the simplex is then said to be Gabriel), and as the minimum of the filtration - values of the codimension 1 cofaces that make it not Gabriel otherwise. - All simplices that have a filtration value \f$ > \alpha^2 \f$ are removed from the Delaunay complex - when creating the simplicial complex if it is specified.
- For performances reasons, it is advised to use \ref cgal ≥ 5.0.0. + The simplex tree is an efficient and flexible + data structure for representing general (filtered) simplicial complexes. The data structure + is described in \cite boissonnatmariasimplextreealgorithmica .
- Author: Vincent Rouvreau
- Introduced in: GUDHI 1.3.0
- Copyright: MIT [(GPL v3)](../../licensing/)
- Requires: \ref eigen ≥ 3.1.0 and \ref cgal ≥ 4.11.0 + Author: Clément Maria
+ Introduced in: GUDHI 1.0.0
+ Copyright: MIT
- User manual: \ref alpha_complex + User manual: \ref simplex_tree
-#### Čech complex +#### Skeleton blocker - +
- \image html "cech_complex_representation.png" + \image html "ds_representation.png" - The Čech complex is a simplicial complex constructed from a proximity graph. - The set of all simplices is filtered by the radius of their minimal enclosing ball. + The Skeleton-Blocker data-structure proposes a light encoding for simplicial complexes by storing only an *implicit* + representation of its simplices \cite socg_blockers_2011,\cite blockers2012. Intuitively, it just stores the + 1-skeleton of a simplicial complex with a graph and the set of its "missing faces" that is very small in practice. + This data-structure handles all simplicial complexes operations such as simplex enumeration or simplex removal but + operations that are particularly efficient are operations that do not require simplex enumeration such as edge + iteration, link computation or simplex contraction. - Author: Vincent Rouvreau
- Introduced in: GUDHI 2.2.0
- Copyright: MIT [(GPL v3)](../../licensing/)
- Includes: [Miniball](https://people.inf.ethz.ch/gaertner/subdir/software/miniball.html)
+ Author: David Salinas
+ Introduced in: GUDHI 1.1.0
+ Copyright: MIT
- User manual: \ref cech_complex + User manual: \ref skbl
-#### Rips complex +#### Toplex Map
- \image html "rips_complex_representation.png" + \image html "map.png" - Rips complex is a simplicial complex constructed from a one skeleton graph.
- The filtration value of each edge is computed from a user-given distance function and is inserted until a - user-given threshold value.
- This complex can be built from a point cloud and a distance function, or from a distance matrix. + The Toplex map data structure is composed firstly of a raw storage of toplices (the maximal simplices) + and secondly of a map which associate any vertex to a set of pointers toward all toplices + containing this vertex.
- Author: Clément Maria, Pawel Dlotko, Vincent Rouvreau, Marc Glisse
- Introduced in: GUDHI 2.0.0
+ Author: François Godi
+ Introduced in: GUDHI 2.1.0
Copyright: MIT
- User manual: \ref rips_complex + User manual: \ref toplex_map
-#### Witness complex +#### Basic operation: contraction
- \image html "Witness_complex_representation.png" + \image html "sphere_contraction_representation.png" - Witness complex \f$ Wit(W,L) \f$ is a simplicial complex defined on two sets of points in \f$\mathbb{R}^D\f$. - The data structure is described in \cite boissonnatmariasimplextreealgorithmica . + The purpose of this package is to offer a user-friendly interface for edge contraction simplification of huge + simplicial complexes. It uses the \ref skbl data-structure whose size remains small during simplification of most + used geometrical complexes of topological data analysis such as the Rips or the Delaunay complexes. In practice, + the size of this data-structure is even much lower than the total number of simplices. - Author: Siargey Kachanovich
- Introduced in: GUDHI 1.3.0
- Copyright: MIT ([GPL v3](../../licensing/) for Euclidean version)
- Euclidean version requires: \ref eigen ≥ 3.1.0 and \ref cgal ≥ 4.11.0 + Author: David Salinas
+ Introduced in: GUDHI 1.1.0
+ Copyright: MIT [(LGPL v3)](../../licensing/)
+ Requires: \ref cgal ≥ 4.11.0
- User manual: \ref witness_complex + User manual: \ref contr
-### Cover Complexes +## Filtrations and reconstructions +### Alpha complex +
- \image html "gicvisu.jpg" + \image html "alpha_complex_representation.png" - Nerves and Graph Induced Complexes are cover complexes, i.e. simplicial complexes that provably contain - topological information about the input data. They can be computed with a cover of the - data, that comes i.e. from the preimage of a family of intervals covering the image - of a scalar-valued function defined on the data.
+ Alpha complex is a simplicial complex constructed from the finite cells of a Delaunay Triangulation.
+ The filtration value of each simplex is computed as the square of the circumradius of the simplex if the + circumsphere is empty (the simplex is then said to be Gabriel), and as the minimum of the filtration + values of the codimension 1 cofaces that make it not Gabriel otherwise. + All simplices that have a filtration value \f$ > \alpha^2 \f$ are removed from the Delaunay complex + when creating the simplicial complex if it is specified.
+ For performances reasons, it is advised to use \ref cgal ≥ 5.0.0.
- Author: Mathieu Carrière
- Introduced in: GUDHI 2.1.0
+ Author: Vincent Rouvreau
+ Introduced in: GUDHI 1.3.0
Copyright: MIT [(GPL v3)](../../licensing/)
- Requires: \ref cgal ≥ 4.11.0 + Requires: \ref eigen ≥ 3.1.0 and \ref cgal ≥ 4.11.0
- User manual: \ref cover_complex + User manual: \ref alpha_complex
-## Data structures and basic operations {#DataStructuresAndBasicOperations} +### Čech complex + + + + + + + + + + +
+ \image html "cech_complex_representation.png" + + The Čech complex is a simplicial complex constructed from a proximity graph. + The set of all simplices is filtered by the radius of their minimal enclosing ball. + + Author: Vincent Rouvreau
+ Introduced in: GUDHI 2.2.0
+ Copyright: MIT [(GPL v3)](../../licensing/)
+ Includes: [Miniball](https://people.inf.ethz.ch/gaertner/subdir/software/miniball.html)
+
+ User manual: \ref cech_complex +
-### Data structures +### Rips complex -#### Simplex tree
- \image html "Simplex_tree_representation.png" + \image html "rips_complex_representation.png" - The simplex tree is an efficient and flexible - data structure for representing general (filtered) simplicial complexes. The data structure - is described in \cite boissonnatmariasimplextreealgorithmica . + Rips complex is a simplicial complex constructed from a one skeleton graph.
+ The filtration value of each edge is computed from a user-given distance function and is inserted until a + user-given threshold value.
+ This complex can be built from a point cloud and a distance function, or from a distance matrix.
- Author: Clément Maria
- Introduced in: GUDHI 1.0.0
+ Author: Clément Maria, Pawel Dlotko, Vincent Rouvreau, Marc Glisse
+ Introduced in: GUDHI 2.0.0
Copyright: MIT
- User manual: \ref simplex_tree + User manual: \ref rips_complex
-#### Skeleton blocker +### Witness complex
- \image html "ds_representation.png" + \image html "Witness_complex_representation.png" - The Skeleton-Blocker data-structure proposes a light encoding for simplicial complexes by storing only an *implicit* - representation of its simplices \cite socg_blockers_2011,\cite blockers2012. Intuitively, it just stores the - 1-skeleton of a simplicial complex with a graph and the set of its "missing faces" that is very small in practice. - This data-structure handles all simplicial complexes operations such as simplex enumeration or simplex removal but - operations that are particularly efficient are operations that do not require simplex enumeration such as edge - iteration, link computation or simplex contraction. + Witness complex \f$ Wit(W,L) \f$ is a simplicial complex defined on two sets of points in \f$\mathbb{R}^D\f$. + The data structure is described in \cite boissonnatmariasimplextreealgorithmica . - Author: David Salinas
- Introduced in: GUDHI 1.1.0
- Copyright: MIT
+ Author: Siargey Kachanovich
+ Introduced in: GUDHI 1.3.0
+ Copyright: MIT ([GPL v3](../../licensing/) for Euclidean version)
+ Euclidean version requires: \ref eigen ≥ 3.1.0 and \ref cgal ≥ 4.11.0
- User manual: \ref skbl + User manual: \ref witness_complex
-#### Toplex Map - +### Cover Complexes
- \image html "map.png" + \image html "gicvisu.jpg" - The Toplex map data structure is composed firstly of a raw storage of toplices (the maximal simplices) - and secondly of a map which associate any vertex to a set of pointers toward all toplices - containing this vertex. + Nerves and Graph Induced Complexes are cover complexes, i.e. simplicial complexes that provably contain + topological information about the input data. They can be computed with a cover of the + data, that comes i.e. from the preimage of a family of intervals covering the image + of a scalar-valued function defined on the data.
- Author: François Godi
+ Author: Mathieu Carrière
Introduced in: GUDHI 2.1.0
- Copyright: MIT
+ Copyright: MIT [(GPL v3)](../../licensing/)
+ Requires: \ref cgal ≥ 4.11.0
- User manual: \ref toplex_map + User manual: \ref cover_complex
-### Basic operations - -#### Contraction +### Tangential complex
- \image html "sphere_contraction_representation.png" + \image html "tc_examples.png" - The purpose of this package is to offer a user-friendly interface for edge contraction simplification of huge - simplicial complexes. It uses the \ref skbl data-structure whose size remains small during simplification of most - used geometrical complexes of topological data analysis such as the Rips or the Delaunay complexes. In practice, - the size of this data-structure is even much lower than the total number of simplices. + A Tangential Delaunay complex is a simplicial complex + designed to reconstruct a \f$ k \f$-dimensional manifold embedded in \f$ d \f$-dimensional Euclidean space. + The input is a point sample coming from an unknown manifold. + The running time depends only linearly on the extrinsic dimension \f$ d \f$ + and exponentially on the intrinsic dimension \f$ k \f$. - Author: David Salinas
- Introduced in: GUDHI 1.1.0
- Copyright: MIT [(LGPL v3)](../../licensing/)
- Requires: \ref cgal ≥ 4.11.0 + Author: Clément Jamin
+ Introduced in: GUDHI 2.0.0
+ Copyright: MIT [(GPL v3)](../../licensing/)
+ Requires: \ref eigen ≥ 3.1.0 and \ref cgal ≥ 4.11.0
- User manual: \ref contr + User manual: \ref tangential_complex
@@ -305,36 +328,6 @@ -## Manifold reconstruction {#ManifoldReconstruction} - -### Tangential complex - - - - - - - - - - -
- \image html "tc_examples.png" - - A Tangential Delaunay complex is a simplicial complex - designed to reconstruct a \f$ k \f$-dimensional manifold embedded in \f$ d \f$-dimensional Euclidean space. - The input is a point sample coming from an unknown manifold. - The running time depends only linearly on the extrinsic dimension \f$ d \f$ - and exponentially on the intrinsic dimension \f$ k \f$. - - Author: Clément Jamin
- Introduced in: GUDHI 2.0.0
- Copyright: MIT [(GPL v3)](../../licensing/)
- Requires: \ref eigen ≥ 3.1.0 and \ref cgal ≥ 4.11.0 -
- User manual: \ref tangential_complex -
- ## Topological descriptors tools {#TopologicalDescriptorsTools} ### Bottleneck distance -- cgit v1.2.3 From 82b4a1e765adc6ec9d37b1bfb09ce443f642cb08 Mon Sep 17 00:00:00 2001 From: Marc Glisse Date: Mon, 20 Jan 2020 20:11:28 +0100 Subject: Missing entry in TOC --- src/common/doc/main_page.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src') diff --git a/src/common/doc/main_page.md b/src/common/doc/main_page.md index 768c5794..90afb05d 100644 --- a/src/common/doc/main_page.md +++ b/src/common/doc/main_page.md @@ -135,7 +135,7 @@ -## Filtrations and reconstructions +## Filtrations and reconstructions {#FiltrationsReconstructions} ### Alpha complex -- cgit v1.2.3 From 8c85fa3f6dcb47346f3070adc46d44c9afca2f2c Mon Sep 17 00:00:00 2001 From: Marc Glisse Date: Mon, 20 Jan 2020 20:26:18 +0100 Subject: Reorder skbl and toplexmap so that skbl is next to contractions --- src/common/doc/main_page.md | 38 +++++++++++++++++++------------------- 1 file changed, 19 insertions(+), 19 deletions(-) (limited to 'src') diff --git a/src/common/doc/main_page.md b/src/common/doc/main_page.md index 90afb05d..23dd3fde 100644 --- a/src/common/doc/main_page.md +++ b/src/common/doc/main_page.md @@ -55,55 +55,55 @@
-#### Skeleton blocker +#### Toplex Map
- \image html "ds_representation.png" + \image html "map.png" - The Skeleton-Blocker data-structure proposes a light encoding for simplicial complexes by storing only an *implicit* - representation of its simplices \cite socg_blockers_2011,\cite blockers2012. Intuitively, it just stores the - 1-skeleton of a simplicial complex with a graph and the set of its "missing faces" that is very small in practice. - This data-structure handles all simplicial complexes operations such as simplex enumeration or simplex removal but - operations that are particularly efficient are operations that do not require simplex enumeration such as edge - iteration, link computation or simplex contraction. + The Toplex map data structure is composed firstly of a raw storage of toplices (the maximal simplices) + and secondly of a map which associate any vertex to a set of pointers toward all toplices + containing this vertex. - Author: David Salinas
- Introduced in: GUDHI 1.1.0
+ Author: François Godi
+ Introduced in: GUDHI 2.1.0
Copyright: MIT
- User manual: \ref skbl + User manual: \ref toplex_map
-#### Toplex Map +#### Skeleton blocker
- \image html "map.png" + \image html "ds_representation.png" - The Toplex map data structure is composed firstly of a raw storage of toplices (the maximal simplices) - and secondly of a map which associate any vertex to a set of pointers toward all toplices - containing this vertex. + The Skeleton-Blocker data-structure proposes a light encoding for simplicial complexes by storing only an *implicit* + representation of its simplices \cite socg_blockers_2011,\cite blockers2012. Intuitively, it just stores the + 1-skeleton of a simplicial complex with a graph and the set of its "missing faces" that is very small in practice. + This data-structure handles all simplicial complexes operations such as simplex enumeration or simplex removal but + operations that are particularly efficient are operations that do not require simplex enumeration such as edge + iteration, link computation or simplex contraction. - Author: François Godi
- Introduced in: GUDHI 2.1.0
+ Author: David Salinas
+ Introduced in: GUDHI 1.1.0
Copyright: MIT
- User manual: \ref toplex_map + User manual: \ref skbl
-- cgit v1.2.3 From dc3d21f55d3e0de311f56b2706629483f50b0258 Mon Sep 17 00:00:00 2001 From: Marc Glisse Date: Mon, 20 Jan 2020 20:36:58 +0100 Subject: Link kd-tree and subsampling from the main doc --- src/common/doc/main_page.md | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) (limited to 'src') diff --git a/src/common/doc/main_page.md b/src/common/doc/main_page.md index 23dd3fde..72bf1cef 100644 --- a/src/common/doc/main_page.md +++ b/src/common/doc/main_page.md @@ -383,3 +383,26 @@ + +## Point cloud utilities {#PointCloudUtils} + + + + + + + + + + +
+ \f$(x_1,\ldots\x_d)\f$ + + This contains various tools to handle point clouds: spatial searching, subsampling, etc. + + Author: Clément Jamin
+ Introduced in: GUDHI 1.3.0
+ Copyright: MIT [(GPL v3)](../../licensing/)
+
+ Manuals: \ref spatial_searching, \ref subsampling +
-- cgit v1.2.3 From 43b6452cf36e92595e4fd05bdeca6c5eeaf95e86 Mon Sep 17 00:00:00 2001 From: Marc Glisse Date: Mon, 20 Jan 2020 20:55:33 +0100 Subject: Typo --- src/common/doc/main_page.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src') diff --git a/src/common/doc/main_page.md b/src/common/doc/main_page.md index 72bf1cef..6ea10b88 100644 --- a/src/common/doc/main_page.md +++ b/src/common/doc/main_page.md @@ -389,7 +389,7 @@
- \f$(x_1,\ldots\x_d)\f$ + \f$(x_1,\ldots,x_d)\f$ This contains various tools to handle point clouds: spatial searching, subsampling, etc. -- cgit v1.2.3