From 85eec1ba750d56b66e3739dc486c6205f49fb31e Mon Sep 17 00:00:00 2001 From: ROUVREAU Vincent Date: Fri, 3 Jul 2020 16:04:45 +0200 Subject: A proposal for simplex_tree reset_filtration (python & C++) --- src/Simplex_tree/include/gudhi/Simplex_tree.h | 30 +++++++++++++++ src/Simplex_tree/test/simplex_tree_unit_test.cpp | 47 ++++++++++++++++++++++++ src/python/gudhi/simplex_tree.pxd | 1 + src/python/gudhi/simplex_tree.pyx | 10 +++++ src/python/test/test_simplex_tree.py | 22 +++++++++++ 5 files changed, 110 insertions(+) diff --git a/src/Simplex_tree/include/gudhi/Simplex_tree.h b/src/Simplex_tree/include/gudhi/Simplex_tree.h index 889dbd00..adc8e801 100644 --- a/src/Simplex_tree/include/gudhi/Simplex_tree.h +++ b/src/Simplex_tree/include/gudhi/Simplex_tree.h @@ -1667,6 +1667,36 @@ class Simplex_tree { return sh; // None of its faces has the same filtration. } + public: + /** \brief This function resets filtration value until a given dimension. + * @param[in] filt_value The new filtration value. + * @param[in] max_dim The maximal dimension. + */ + void reset_filtration(Filtration_value filt_value, int max_dim) { + for (auto& simplex : root_.members()) { + simplex.second.assign_filtration(filt_value); + if (has_children(&simplex) && max_dim > 0) { + rec_reset_filtration(simplex.second.children(), filt_value, (max_dim - 1)); + } + } + clear_filtration(); // Drop the cache. + } + + private: + /** \brief Recursively resets filtration value until a given dimension. + * @param[in] sib Siblings to be parsed. + * @param[in] filt_value The new filtration value. + * @param[in] max_dim The maximal dimension. + */ + void rec_reset_filtration(Siblings * sib, Filtration_value filt_value, int max_dim) { + for (auto& simplex : sib->members()) { + simplex.second.assign_filtration(filt_value); + if (has_children(&simplex) && max_dim > 0) { + rec_reset_filtration(simplex.second.children(), filt_value, (max_dim - 1)); + } + } + } + private: Vertex_handle null_vertex_; /** \brief Total number of simplices in the complex, without the empty simplex.*/ diff --git a/src/Simplex_tree/test/simplex_tree_unit_test.cpp b/src/Simplex_tree/test/simplex_tree_unit_test.cpp index 9b5fa8fe..9780f5b0 100644 --- a/src/Simplex_tree/test/simplex_tree_unit_test.cpp +++ b/src/Simplex_tree/test/simplex_tree_unit_test.cpp @@ -940,3 +940,50 @@ BOOST_AUTO_TEST_CASE_TEMPLATE(generators, typeST, list_of_tested_variants) { BOOST_CHECK(st.edge_with_same_filtration(st.find({1,5}))==st.find({1,5})); } } + +BOOST_AUTO_TEST_CASE_TEMPLATE(simplex_tree_reset_filtration, typeST, list_of_tested_variants) { + std::clog << "********************************************************************" << std::endl; + std::clog << "TEST RESET FILTRATION" << std::endl; + typeST st; + + st.insert_simplex_and_subfaces({2, 1, 0}, 3.); + st.insert_simplex_and_subfaces({3, 0}, 2.); + st.insert_simplex_and_subfaces({3, 4, 5}, 3.); + st.insert_simplex_and_subfaces({0, 1, 6, 7}, 4.); + + /* Inserted simplex: */ + /* 1 6 */ + /* o---o */ + /* /X\7/ */ + /* o---o---o---o */ + /* 2 0 3\X/4 */ + /* o */ + /* 5 */ + + for (auto f_simplex : st.skeleton_simplex_range(3)) { + std::clog << "vertex = ("; + for (auto vertex : st.simplex_vertex_range(f_simplex)) { + std::clog << vertex << ","; + } + std::clog << ") - filtration =" << st.filtration(f_simplex) << std::endl; + BOOST_CHECK(st.filtration(f_simplex) >= 2.); + } + + // dimension until 5 even if simplex tree is of dimension 3 to test the limits + for(int dimension = 0; dimension < 6; dimension ++) { + st.reset_filtration(0., dimension); + for (auto f_simplex : st.skeleton_simplex_range(3)) { + std::clog << "vertex = ("; + for (auto vertex : st.simplex_vertex_range(f_simplex)) { + std::clog << vertex << ","; + } + std::clog << ") - filtration =" << st.filtration(f_simplex) << std::endl; + if (st.dimension(f_simplex) > dimension) + BOOST_CHECK(st.filtration(f_simplex) >= 1.); + else + BOOST_CHECK(st.filtration(f_simplex) == 0.); + } + } + +} + diff --git a/src/python/gudhi/simplex_tree.pxd b/src/python/gudhi/simplex_tree.pxd index e748ac40..12c2065e 100644 --- a/src/python/gudhi/simplex_tree.pxd +++ b/src/python/gudhi/simplex_tree.pxd @@ -57,6 +57,7 @@ cdef extern from "Simplex_tree_interface.h" namespace "Gudhi": bool make_filtration_non_decreasing() nogil void compute_extended_filtration() nogil vector[vector[pair[int, pair[double, double]]]] compute_extended_persistence_subdiagrams(vector[pair[int, pair[double, double]]] dgm, double min_persistence) nogil + void reset_filtration(double filtration, int dimension) nogil # Iterators over Simplex tree pair[vector[int], double] get_simplex_and_filtration(Simplex_tree_simplex_handle f_simplex) nogil Simplex_tree_simplices_iterator get_simplices_iterator_begin() nogil diff --git a/src/python/gudhi/simplex_tree.pyx b/src/python/gudhi/simplex_tree.pyx index 20e66d9f..41b06116 100644 --- a/src/python/gudhi/simplex_tree.pyx +++ b/src/python/gudhi/simplex_tree.pyx @@ -358,6 +358,16 @@ cdef class SimplexTree: """ return self.get_ptr().make_filtration_non_decreasing() + def reset_filtration(self, filtration, max_dim): + """This function resets filtration value until a given dimension. + + :param filtration: New threshold value. + :type filtration: float. + :param max_dim: The maximal dimension. + :type max_dim: int. + """ + self.get_ptr().reset_filtration(filtration, max_dim) + def extend_filtration(self): """ Extend filtration for computing extended persistence. This function only uses the filtration values at the 0-dimensional simplices, and computes the extended persistence diff --git a/src/python/test/test_simplex_tree.py b/src/python/test/test_simplex_tree.py index 2137d822..1ca84c10 100755 --- a/src/python/test/test_simplex_tree.py +++ b/src/python/test/test_simplex_tree.py @@ -340,3 +340,25 @@ def test_simplices_iterator(): assert st.find(simplex[0]) == True print("filtration is: ", simplex[1]) assert st.filtration(simplex[0]) == simplex[1] + +def test_reset_filtration(): + st = SimplexTree() + + assert st.insert([0, 1, 2], 3.) == True + assert st.insert([0, 3], 2.) == True + assert st.insert([3, 4, 5], 3.) == True + assert st.insert([0, 1, 6, 7], 4.) == True + + for simplex in st.get_simplices(): + assert st.filtration(simplex[0]) >= 0. + + # dimension until 5 even if simplex tree is of dimension 3 to test the limits + for dimension in range(0, 6): + st.reset_filtration(0., dimension) + for simplex in st.get_skeleton(3): + print(simplex) + if len(simplex[0]) > (dimension + 1): + assert st.filtration(simplex[0]) >= 1. + else: + assert st.filtration(simplex[0]) == 0. + -- cgit v1.2.3 From c2aa4a3416bbdc09840217a8dcd89da7d9647513 Mon Sep 17 00:00:00 2001 From: ROUVREAU Vincent Date: Tue, 28 Jul 2020 09:37:06 +0200 Subject: Remove Eigen compilation error for Alpha complex 3d --- src/Alpha_complex/include/gudhi/Alpha_complex_3d.h | 4 ---- 1 file changed, 4 deletions(-) diff --git a/src/Alpha_complex/include/gudhi/Alpha_complex_3d.h b/src/Alpha_complex/include/gudhi/Alpha_complex_3d.h index f56e12d0..2c1b97a4 100644 --- a/src/Alpha_complex/include/gudhi/Alpha_complex_3d.h +++ b/src/Alpha_complex/include/gudhi/Alpha_complex_3d.h @@ -56,10 +56,6 @@ # error Alpha_complex_3d is only available for CGAL >= 4.11 #endif -#if !EIGEN_VERSION_AT_LEAST(3,1,0) -# error Alpha_complex_3d is only available for Eigen3 >= 3.1.0 installed with CGAL -#endif - namespace Gudhi { namespace alpha_complex { -- cgit v1.2.3 From 59e819dd9485bd55b2b3ec6440cb3e3200d96fcb Mon Sep 17 00:00:00 2001 From: ROUVREAU Vincent Date: Tue, 11 Aug 2020 09:43:36 +0200 Subject: Add build pip CI --- .github/workflows/pip-build-linux.yml | 45 +++++++++++++++++++++++++++++++++ .github/workflows/pip-build-osx.yml | 34 +++++++++++++++++++++++++ .github/workflows/pip-build-windows.yml | 42 ++++++++++++++++++++++++++++++ 3 files changed, 121 insertions(+) create mode 100644 .github/workflows/pip-build-linux.yml create mode 100644 .github/workflows/pip-build-osx.yml create mode 100644 .github/workflows/pip-build-windows.yml diff --git a/.github/workflows/pip-build-linux.yml b/.github/workflows/pip-build-linux.yml new file mode 100644 index 00000000..cf41d224 --- /dev/null +++ b/.github/workflows/pip-build-linux.yml @@ -0,0 +1,45 @@ +name: pip build linux + +on: [push, pull_request] + +jobs: + build: + name: build pip wheels + runs-on: ubuntu-latest + container: gudhi/pip_for_gudhi + steps: + - uses: actions/checkout@v1 + with: + submodules: true + - name: Build wheels for Python 3.5 + run: | + mkdir build_35 + cd build_35 + cmake -DCMAKE_BUILD_TYPE=Release -DPYTHON_EXECUTABLE=$PYTHON35/bin/python .. + cd src/python + $PYTHON35/bin/python setup.py bdist_wheel + auditwheel repair dist/*.whl + - name: Build wheels for Python 3.6 + run: | + mkdir build_36 + cd build_36 + cmake -DCMAKE_BUILD_TYPE=Release -DPYTHON_EXECUTABLE=$PYTHON36/bin/python .. + cd src/python + $PYTHON36/bin/python setup.py bdist_wheel + auditwheel repair dist/*.whl + - name: Build wheels for Python 3.7 + run: | + mkdir build_37 + cd build_37 + cmake -DCMAKE_BUILD_TYPE=Release -DPYTHON_EXECUTABLE=$PYTHON37/bin/python .. + cd src/python + $PYTHON37/bin/python setup.py bdist_wheel + auditwheel repair dist/*.whl + - name: Build wheels for Python 3.8 + run: | + mkdir build_38 + cd build_38 + cmake -DCMAKE_BUILD_TYPE=Release -DPYTHON_EXECUTABLE=$PYTHON38/bin/python .. + cd src/python + $PYTHON38/bin/python setup.py bdist_wheel + auditwheel repair dist/*.whl \ No newline at end of file diff --git a/.github/workflows/pip-build-osx.yml b/.github/workflows/pip-build-osx.yml new file mode 100644 index 00000000..4af7cd84 --- /dev/null +++ b/.github/workflows/pip-build-osx.yml @@ -0,0 +1,34 @@ +name: pip build osx + +on: [push, pull_request] + +jobs: + build: + runs-on: macos-latest + strategy: + max-parallel: 4 + matrix: + python-version: ['3.5', '3.6', '3.7', '3.8'] + name: Build wheels for Python ${{ matrix.python-version }} + steps: + - uses: actions/checkout@v1 + with: + submodules: true + - uses: actions/setup-python@v1 + with: + python-version: ${{ matrix.python-version }} + architecture: x64 + - name: Install dependencies + run: | + brew update || true + brew install boost eigen gmp mpfr cgal || true + python -m pip install --user -r .github/build-requirements.txt + python -m pip install --user twine delocate + - name: Build python wheel + run: | + python --version + mkdir build + cd build + cmake -DCMAKE_BUILD_TYPE=Release -DPython_ADDITIONAL_VERSIONS=3 .. + cd src/python + python setup.py bdist_wheel diff --git a/.github/workflows/pip-build-windows.yml b/.github/workflows/pip-build-windows.yml new file mode 100644 index 00000000..5119ac0c --- /dev/null +++ b/.github/workflows/pip-build-windows.yml @@ -0,0 +1,42 @@ +name: pip build windows + +on: [push, pull_request] + +jobs: + build: + runs-on: windows-latest + strategy: + max-parallel: 4 + matrix: + python-version: ['3.5', '3.6', '3.7', '3.8'] + name: Build wheels for Python ${{ matrix.python-version }} + steps: + - uses: actions/checkout@v1 + with: + submodules: true + - uses: actions/setup-python@v1 + with: + python-version: ${{ matrix.python-version }} + architecture: x64 + - name: Patch + run: | + (new-object System.Net.WebClient).DownloadFile('https://github.com/microsoft/vcpkg/files/4978792/vcpkg_fixup_pkgconfig.cmake.txt','c:\vcpkg\scripts\cmake\vcpkg_fixup_pkgconfig.cmake') + (new-object System.Net.WebClient).DownloadFile('https://github.com/microsoft/vcpkg/files/4978796/vcpkg_acquire_msys.cmake.txt','c:\vcpkg\scripts\cmake\vcpkg_acquire_msys.cmake') + shell: powershell + - name: Install dependencies + run: | + vcpkg update + vcpkg upgrade --no-dry-run + vcpkg install boost-graph boost-serialization boost-date-time boost-system boost-filesystem boost-units boost-thread boost-program-options eigen3 mpfr mpir cgal --triplet x64-windows + python -m pip install --user -r .github/build-requirements.txt + python -m pip install --user twine + python -m pip list + - name: Build python wheel + run: | + mkdir build + cd build + cmake -DCMAKE_BUILD_TYPE=Release -DGMP_INCLUDE_DIR="c:/vcpkg/installed/x64-windows/include" -DGMP_LIBRARIES="c:/vcpkg/installed/x64-windows/lib/mpir.lib" -DGMP_LIBRARIES_DIR="c:/vcpkg/installed/x64-windows/lib" -DCMAKE_TOOLCHAIN_FILE=C:/vcpkg/scripts/buildsystems/vcpkg.cmake -DVCPKG_TARGET_TRIPLET=x64-windows -DPython_ADDITIONAL_VERSIONS=3 .. + cd src/python + cp c:/vcpkg/installed/x64-windows/bin/mpfr.dll gudhi/ + cp c:/vcpkg/installed/x64-windows/bin/mpir.dll gudhi/ + python setup.py bdist_wheel \ No newline at end of file -- cgit v1.2.3 From 3a0a4fc525c84dbb64e41e73e4d138c2b873edbe Mon Sep 17 00:00:00 2001 From: ROUVREAU Vincent Date: Tue, 18 Aug 2020 09:32:35 +0200 Subject: Only python 3.8 should be enough to detect issues --- .github/workflows/pip-build-linux.yml | 24 ------------------------ .github/workflows/pip-build-osx.yml | 2 +- .github/workflows/pip-build-windows.yml | 2 +- 3 files changed, 2 insertions(+), 26 deletions(-) diff --git a/.github/workflows/pip-build-linux.yml b/.github/workflows/pip-build-linux.yml index cf41d224..14fdc8d2 100644 --- a/.github/workflows/pip-build-linux.yml +++ b/.github/workflows/pip-build-linux.yml @@ -11,30 +11,6 @@ jobs: - uses: actions/checkout@v1 with: submodules: true - - name: Build wheels for Python 3.5 - run: | - mkdir build_35 - cd build_35 - cmake -DCMAKE_BUILD_TYPE=Release -DPYTHON_EXECUTABLE=$PYTHON35/bin/python .. - cd src/python - $PYTHON35/bin/python setup.py bdist_wheel - auditwheel repair dist/*.whl - - name: Build wheels for Python 3.6 - run: | - mkdir build_36 - cd build_36 - cmake -DCMAKE_BUILD_TYPE=Release -DPYTHON_EXECUTABLE=$PYTHON36/bin/python .. - cd src/python - $PYTHON36/bin/python setup.py bdist_wheel - auditwheel repair dist/*.whl - - name: Build wheels for Python 3.7 - run: | - mkdir build_37 - cd build_37 - cmake -DCMAKE_BUILD_TYPE=Release -DPYTHON_EXECUTABLE=$PYTHON37/bin/python .. - cd src/python - $PYTHON37/bin/python setup.py bdist_wheel - auditwheel repair dist/*.whl - name: Build wheels for Python 3.8 run: | mkdir build_38 diff --git a/.github/workflows/pip-build-osx.yml b/.github/workflows/pip-build-osx.yml index 4af7cd84..15b8880a 100644 --- a/.github/workflows/pip-build-osx.yml +++ b/.github/workflows/pip-build-osx.yml @@ -8,7 +8,7 @@ jobs: strategy: max-parallel: 4 matrix: - python-version: ['3.5', '3.6', '3.7', '3.8'] + python-version: ['3.8'] name: Build wheels for Python ${{ matrix.python-version }} steps: - uses: actions/checkout@v1 diff --git a/.github/workflows/pip-build-windows.yml b/.github/workflows/pip-build-windows.yml index 5119ac0c..11f1ace9 100644 --- a/.github/workflows/pip-build-windows.yml +++ b/.github/workflows/pip-build-windows.yml @@ -8,7 +8,7 @@ jobs: strategy: max-parallel: 4 matrix: - python-version: ['3.5', '3.6', '3.7', '3.8'] + python-version: ['3.8'] name: Build wheels for Python ${{ matrix.python-version }} steps: - uses: actions/checkout@v1 -- cgit v1.2.3 From ddb2118f0af865588d7c14b88171dc04bb27c529 Mon Sep 17 00:00:00 2001 From: ROUVREAU Vincent Date: Tue, 18 Aug 2020 14:38:31 +0200 Subject: reset_filtration from a dimension (instead of 'until') --- src/Simplex_tree/include/gudhi/Simplex_tree.h | 31 ++++++++++++++---------- src/Simplex_tree/test/simplex_tree_unit_test.cpp | 14 +++++++---- src/python/gudhi/simplex_tree.pyx | 17 +++++++------ src/python/test/test_simplex_tree.py | 9 ++++--- 4 files changed, 41 insertions(+), 30 deletions(-) diff --git a/src/Simplex_tree/include/gudhi/Simplex_tree.h b/src/Simplex_tree/include/gudhi/Simplex_tree.h index adc8e801..89b4a5df 100644 --- a/src/Simplex_tree/include/gudhi/Simplex_tree.h +++ b/src/Simplex_tree/include/gudhi/Simplex_tree.h @@ -1668,31 +1668,36 @@ class Simplex_tree { } public: - /** \brief This function resets filtration value until a given dimension. + /** \brief This function resets filtration value from a given dimension. Resets all the Simplex_tree when + * `min_dim = 0`. * @param[in] filt_value The new filtration value. - * @param[in] max_dim The maximal dimension. + * @param[in] min_dim The minimal dimension. */ - void reset_filtration(Filtration_value filt_value, int max_dim) { + void reset_filtration(Filtration_value filt_value, int min_dim) { for (auto& simplex : root_.members()) { - simplex.second.assign_filtration(filt_value); - if (has_children(&simplex) && max_dim > 0) { - rec_reset_filtration(simplex.second.children(), filt_value, (max_dim - 1)); + if (min_dim <= 0) { + simplex.second.assign_filtration(filt_value); + } + if (has_children(&simplex)) { + rec_reset_filtration(simplex.second.children(), filt_value, min_dim); } } clear_filtration(); // Drop the cache. } private: - /** \brief Recursively resets filtration value until a given dimension. + /** \brief Recursively resets filtration value from a given dimension. * @param[in] sib Siblings to be parsed. * @param[in] filt_value The new filtration value. - * @param[in] max_dim The maximal dimension. + * @param[in] min_dim The maximal dimension. */ - void rec_reset_filtration(Siblings * sib, Filtration_value filt_value, int max_dim) { - for (auto& simplex : sib->members()) { - simplex.second.assign_filtration(filt_value); - if (has_children(&simplex) && max_dim > 0) { - rec_reset_filtration(simplex.second.children(), filt_value, (max_dim - 1)); + void rec_reset_filtration(Siblings * sib, Filtration_value filt_value, int min_dim) { + for (auto sh = sib->members().begin(); sh != sib->members().end(); ++sh) { + if (min_dim <= dimension(sh)) { + sh->second.assign_filtration(filt_value); + } + if (has_children(sh)) { + rec_reset_filtration(sh->second.children(), filt_value, min_dim); } } } diff --git a/src/Simplex_tree/test/simplex_tree_unit_test.cpp b/src/Simplex_tree/test/simplex_tree_unit_test.cpp index 9780f5b0..bdd41d34 100644 --- a/src/Simplex_tree/test/simplex_tree_unit_test.cpp +++ b/src/Simplex_tree/test/simplex_tree_unit_test.cpp @@ -965,21 +965,25 @@ BOOST_AUTO_TEST_CASE_TEMPLATE(simplex_tree_reset_filtration, typeST, list_of_tes for (auto vertex : st.simplex_vertex_range(f_simplex)) { std::clog << vertex << ","; } - std::clog << ") - filtration =" << st.filtration(f_simplex) << std::endl; + std::clog << ") - filtration = " << st.filtration(f_simplex); + std::clog << " - dimension = " << st.dimension(f_simplex) << std::endl; + // Guaranteed by construction BOOST_CHECK(st.filtration(f_simplex) >= 2.); } // dimension until 5 even if simplex tree is of dimension 3 to test the limits - for(int dimension = 0; dimension < 6; dimension ++) { + for(int dimension = 5; dimension >= 0; dimension --) { + std::clog << "### reset_filtration - dimension = " << dimension << "\n"; st.reset_filtration(0., dimension); for (auto f_simplex : st.skeleton_simplex_range(3)) { std::clog << "vertex = ("; for (auto vertex : st.simplex_vertex_range(f_simplex)) { std::clog << vertex << ","; } - std::clog << ") - filtration =" << st.filtration(f_simplex) << std::endl; - if (st.dimension(f_simplex) > dimension) - BOOST_CHECK(st.filtration(f_simplex) >= 1.); + std::clog << ") - filtration = " << st.filtration(f_simplex); + std::clog << " - dimension = " << st.dimension(f_simplex) << std::endl; + if (st.dimension(f_simplex) < dimension) + BOOST_CHECK(st.filtration(f_simplex) >= 2.); else BOOST_CHECK(st.filtration(f_simplex) == 0.); } diff --git a/src/python/gudhi/simplex_tree.pyx b/src/python/gudhi/simplex_tree.pyx index b7682693..657d55be 100644 --- a/src/python/gudhi/simplex_tree.pyx +++ b/src/python/gudhi/simplex_tree.pyx @@ -328,7 +328,7 @@ cdef class SimplexTree: return self.get_ptr().prune_above_filtration(filtration) def expansion(self, max_dim): - """Expands the Simplex_tree containing only its one skeleton + """Expands the simplex tree containing only its one skeleton until dimension max_dim. The expanded simplicial complex until dimension :math:`d` @@ -338,7 +338,7 @@ cdef class SimplexTree: The filtration value assigned to a simplex is the maximal filtration value of one of its edges. - The Simplex_tree must contain no simplex of dimension bigger than + The simplex tree must contain no simplex of dimension bigger than 1 when calling the method. :param max_dim: The maximal dimension. @@ -358,15 +358,16 @@ cdef class SimplexTree: """ return self.get_ptr().make_filtration_non_decreasing() - def reset_filtration(self, filtration, max_dim): - """This function resets filtration value until a given dimension. + def reset_filtration(self, filtration, min_dim): + """This function resets filtration value from a given dimension. + Resets all the simplex tree when `min_dim = 0`. :param filtration: New threshold value. :type filtration: float. - :param max_dim: The maximal dimension. + :param max_dim: The minimal dimension. :type max_dim: int. """ - self.get_ptr().reset_filtration(filtration, max_dim) + self.get_ptr().reset_filtration(filtration, min_dim) def extend_filtration(self): """ Extend filtration for computing extended persistence. This function only uses the @@ -376,14 +377,14 @@ cdef class SimplexTree: .. note:: Note that after calling this function, the filtration - values are actually modified within the Simplex_tree. + values are actually modified within the simplex tree. The function :func:`extended_persistence` retrieves the original values. .. note:: Note that this code creates an extra vertex internally, so you should make sure that - the Simplex_tree does not contain a vertex with the largest possible value (i.e., 4294967295). + the simplex tree does not contain a vertex with the largest possible value (i.e., 4294967295). """ self.get_ptr().compute_extended_filtration() diff --git a/src/python/test/test_simplex_tree.py b/src/python/test/test_simplex_tree.py index 6f1d01cc..ac2b59c7 100755 --- a/src/python/test/test_simplex_tree.py +++ b/src/python/test/test_simplex_tree.py @@ -367,15 +367,16 @@ def test_reset_filtration(): assert st.insert([3, 4, 5], 3.) == True assert st.insert([0, 1, 6, 7], 4.) == True + # Guaranteed by construction for simplex in st.get_simplices(): - assert st.filtration(simplex[0]) >= 0. + assert st.filtration(simplex[0]) >= 2. # dimension until 5 even if simplex tree is of dimension 3 to test the limits - for dimension in range(0, 6): + for dimension in range(5, -1, -1): st.reset_filtration(0., dimension) for simplex in st.get_skeleton(3): print(simplex) - if len(simplex[0]) > (dimension + 1): - assert st.filtration(simplex[0]) >= 1. + if len(simplex[0]) < (dimension) + 1: + assert st.filtration(simplex[0]) >= 2. else: assert st.filtration(simplex[0]) == 0. -- cgit v1.2.3 From ad7e537f37c93cba6e2b391bf68783359362afa4 Mon Sep 17 00:00:00 2001 From: yuichi-ike Date: Wed, 19 Aug 2020 13:49:27 +0900 Subject: docs modified --- src/python/doc/rips_complex_sum.inc | 22 +++++++++++----------- src/python/doc/rips_complex_user.rst | 6 +++--- 2 files changed, 14 insertions(+), 14 deletions(-) diff --git a/src/python/doc/rips_complex_sum.inc b/src/python/doc/rips_complex_sum.inc index c123ea2a..2cb24990 100644 --- a/src/python/doc/rips_complex_sum.inc +++ b/src/python/doc/rips_complex_sum.inc @@ -1,14 +1,14 @@ .. table:: :widths: 30 40 30 - +----------------------------------------------------------------+------------------------------------------------------------------------+----------------------------------------------------------------------+ - | .. figure:: | The Vietoris-Rips complex is a simplicial complex built as the | :Authors: Clément Maria, Pawel Dlotko, Vincent Rouvreau, Marc Glisse | - | ../../doc/Rips_complex/rips_complex_representation.png | clique-complex of a proximity graph. | | - | :figclass: align-center | | :Since: GUDHI 2.0.0 | - | | We also provide sparse approximations, to speed-up the computation | | - | | of persistent homology, and weighted versions, which are more robust | :License: MIT | - | | to outliers. | | - | | | | - +----------------------------------------------------------------+------------------------------------------------------------------------+----------------------------------------------------------------------+ - | * :doc:`rips_complex_user` | * :doc:`rips_complex_ref` | - +----------------------------------------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------+ + +----------------------------------------------------------------+------------------------------------------------------------------------+----------------------------------------------------------------------------------+ + | .. figure:: | The Vietoris-Rips complex is a simplicial complex built as the | :Authors: Clément Maria, Pawel Dlotko, Vincent Rouvreau, Marc Glisse, Yuichi Ike | + | ../../doc/Rips_complex/rips_complex_representation.png | clique-complex of a proximity graph. | | + | :figclass: align-center | | :Since: GUDHI 2.0.0 | + | | We also provide sparse approximations, to speed-up the computation | | + | | of persistent homology, and weighted versions, which are more robust | :License: MIT | + | | to outliers. | | + | | | | + +----------------------------------------------------------------+------------------------------------------------------------------------+----------------------------------------------------------------------------------+ + | * :doc:`rips_complex_user` | * :doc:`rips_complex_ref` | + +----------------------------------------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------+ diff --git a/src/python/doc/rips_complex_user.rst b/src/python/doc/rips_complex_user.rst index 6048cc4e..27d218d4 100644 --- a/src/python/doc/rips_complex_user.rst +++ b/src/python/doc/rips_complex_user.rst @@ -7,9 +7,9 @@ Rips complex user manual Definition ---------- -==================================================================== ================================ ====================== -:Authors: Clément Maria, Pawel Dlotko, Vincent Rouvreau, Marc Glisse :Since: GUDHI 2.0.0 :License: GPL v3 -==================================================================== ================================ ====================== +================================================================================ ================================ ====================== +:Authors: Clément Maria, Pawel Dlotko, Vincent Rouvreau, Marc Glisse, Yuichi Ike :Since: GUDHI 2.0.0 :License: GPL v3 +================================================================================ ================================ ====================== +-------------------------------------------+----------------------------------------------------------------------+ | :doc:`rips_complex_user` | :doc:`rips_complex_ref` | -- cgit v1.2.3 From 6128a88a6780af29825c73af0e32100e93c2f0b5 Mon Sep 17 00:00:00 2001 From: ROUVREAU Vincent Date: Wed, 19 Aug 2020 11:34:06 +0200 Subject: python code coverage on python circleci target. Fix language_level cython warning --- .circleci/config.yml | 10 ++++++---- src/python/setup.py.in | 6 +++--- 2 files changed, 9 insertions(+), 7 deletions(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index b04efd52..f8dae062 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -57,20 +57,22 @@ jobs: cmake -DUSER_VERSION_DIR=version ..; make user_version; cd version; - mkdir build; - cd build; - cmake -DCMAKE_BUILD_TYPE=Release -DWITH_GUDHI_EXAMPLE=OFF -DWITH_GUDHI_UTILITIES=OFF -DWITH_GUDHI_PYTHON=ON -DPython_ADDITIONAL_VERSIONS=3 ..; + cmake -DCMAKE_BUILD_TYPE=Release -DWITH_GUDHI_EXAMPLE=OFF -DWITH_GUDHI_UTILITIES=OFF -DWITH_GUDHI_PYTHON=ON -DPython_ADDITIONAL_VERSIONS=3 .; cd python; python3 setup.py build_ext --inplace; make sphinx; cp -R sphinx /tmp/sphinx; python3 setup.py install; python3 setup.py clean --all; - ctest -j 2 --output-on-failure; + python3 -B -m pytest test/*.py --cov-report html --cov=gudhi; + cp -R htmlcov /tmp/htmlcov; - store_artifacts: path: /tmp/sphinx + - store_artifacts: + path: /tmp/htmlcov + doxygen: docker: - image: gudhi/ci_for_gudhi:latest diff --git a/src/python/setup.py.in b/src/python/setup.py.in index 98d058fc..3602fa42 100644 --- a/src/python/setup.py.in +++ b/src/python/setup.py.in @@ -32,7 +32,7 @@ runtime_library_dirs=[@GUDHI_PYTHON_RUNTIME_LIBRARY_DIRS@] # Create ext_modules list from module list ext_modules = [] for module in cython_modules: - ext_modules.append(Extension( + extension = Extension( 'gudhi.' + module, sources = [source_dir + module + '.pyx',], language = 'c++', @@ -41,8 +41,8 @@ for module in cython_modules: libraries=libraries, library_dirs=library_dirs, include_dirs=include_dirs, - runtime_library_dirs=runtime_library_dirs, - cython_directives = {'language_level': str(sys.version_info[0])},)) + runtime_library_dirs=runtime_library_dirs,) + extension.cython_directives = {'language_level': str(sys.version_info[0])} ext_modules = cythonize(ext_modules) -- cgit v1.2.3 From bcad92a18c40b9926b3b25688ab5435c301990df Mon Sep 17 00:00:00 2001 From: ROUVREAU Vincent Date: Wed, 19 Aug 2020 11:40:40 +0200 Subject: need to append --- src/python/setup.py.in | 1 + 1 file changed, 1 insertion(+) diff --git a/src/python/setup.py.in b/src/python/setup.py.in index 3602fa42..f211f5d2 100644 --- a/src/python/setup.py.in +++ b/src/python/setup.py.in @@ -43,6 +43,7 @@ for module in cython_modules: include_dirs=include_dirs, runtime_library_dirs=runtime_library_dirs,) extension.cython_directives = {'language_level': str(sys.version_info[0])} + ext_modules.append(extension) ext_modules = cythonize(ext_modules) -- cgit v1.2.3 From 52cb44a02ad8ce9884db63724ea0a5f1e35c6172 Mon Sep 17 00:00:00 2001 From: ROUVREAU Vincent Date: Wed, 19 Aug 2020 12:00:27 +0200 Subject: Try to setup.py clean failure --- .circleci/config.yml | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index f8dae062..77fad2ee 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -57,14 +57,16 @@ jobs: cmake -DUSER_VERSION_DIR=version ..; make user_version; cd version; - cmake -DCMAKE_BUILD_TYPE=Release -DWITH_GUDHI_EXAMPLE=OFF -DWITH_GUDHI_UTILITIES=OFF -DWITH_GUDHI_PYTHON=ON -DPython_ADDITIONAL_VERSIONS=3 .; + mkdir build; + cd build; + cmake -DCMAKE_BUILD_TYPE=Release -DWITH_GUDHI_EXAMPLE=OFF -DWITH_GUDHI_UTILITIES=OFF -DWITH_GUDHI_PYTHON=ON -DPython_ADDITIONAL_VERSIONS=3 ..; cd python; python3 setup.py build_ext --inplace; make sphinx; cp -R sphinx /tmp/sphinx; python3 setup.py install; python3 setup.py clean --all; - python3 -B -m pytest test/*.py --cov-report html --cov=gudhi; + python3 -B -m pytest ../../python/test/*.py --cov-report html --cov=gudhi; cp -R htmlcov /tmp/htmlcov; - store_artifacts: -- cgit v1.2.3 From 4a572af654afc22e2f5c26766f611b1918313509 Mon Sep 17 00:00:00 2001 From: ROUVREAU Vincent Date: Thu, 20 Aug 2020 08:15:19 +0200 Subject: Roll back - why cannot clean ? --- .circleci/config.yml | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index 77fad2ee..eca9f91e 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -66,15 +66,11 @@ jobs: cp -R sphinx /tmp/sphinx; python3 setup.py install; python3 setup.py clean --all; - python3 -B -m pytest ../../python/test/*.py --cov-report html --cov=gudhi; - cp -R htmlcov /tmp/htmlcov; + ctest -j 2 --output-on-failure; - store_artifacts: path: /tmp/sphinx - - store_artifacts: - path: /tmp/htmlcov - doxygen: docker: - image: gudhi/ci_for_gudhi:latest -- cgit v1.2.3 From 37786db094d0251bf070215e89e4446384dbe871 Mon Sep 17 00:00:00 2001 From: ROUVREAU Vincent Date: Thu, 20 Aug 2020 09:35:31 +0200 Subject: Let's clean fail --- .circleci/config.yml | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index eca9f91e..129fdc23 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -57,19 +57,19 @@ jobs: cmake -DUSER_VERSION_DIR=version ..; make user_version; cd version; - mkdir build; - cd build; - cmake -DCMAKE_BUILD_TYPE=Release -DWITH_GUDHI_EXAMPLE=OFF -DWITH_GUDHI_UTILITIES=OFF -DWITH_GUDHI_PYTHON=ON -DPython_ADDITIONAL_VERSIONS=3 ..; + cmake -DCMAKE_BUILD_TYPE=Release -DWITH_GUDHI_EXAMPLE=OFF -DWITH_GUDHI_UTILITIES=OFF -DWITH_GUDHI_PYTHON=ON -DPython_ADDITIONAL_VERSIONS=3 .; cd python; python3 setup.py build_ext --inplace; make sphinx; cp -R sphinx /tmp/sphinx; python3 setup.py install; - python3 setup.py clean --all; - ctest -j 2 --output-on-failure; - + python3 setup.py clean --all || true; + python3 -B -m pytest test/*.py --cov-report html --cov=gudhi; + cp -R htmlcov /tmp/htmlcov; - store_artifacts: path: /tmp/sphinx + - store_artifacts: + path: /tmp/htmlcov doxygen: docker: -- cgit v1.2.3 From 151350f85c2799bcb2fde04c6746db7ab7e1ac95 Mon Sep 17 00:00:00 2001 From: ROUVREAU Vincent Date: Thu, 20 Aug 2020 10:28:48 +0200 Subject: Add some debug traces and install pytest-cov for code coverage --- .circleci/config.yml | 1 + .github/test-requirements.txt | 1 + 2 files changed, 2 insertions(+) diff --git a/.circleci/config.yml b/.circleci/config.yml index 129fdc23..167cb4db 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -64,6 +64,7 @@ jobs: cp -R sphinx /tmp/sphinx; python3 setup.py install; python3 setup.py clean --all || true; + python3 -m pip list python3 -B -m pytest test/*.py --cov-report html --cov=gudhi; cp -R htmlcov /tmp/htmlcov; - store_artifacts: diff --git a/.github/test-requirements.txt b/.github/test-requirements.txt index 98f1007e..7d69c0b9 100644 --- a/.github/test-requirements.txt +++ b/.github/test-requirements.txt @@ -1,4 +1,5 @@ pytest +pytest-cov sphinx sphinxcontrib-bibtex sphinx-paramlinks -- cgit v1.2.3 From 129e85610cfd5a1e3db7f7d656e99915b96a3be5 Mon Sep 17 00:00:00 2001 From: ROUVREAU Vincent Date: Thu, 20 Aug 2020 14:17:31 +0200 Subject: Some cleanup. CircleCI docker image build requires update --- .circleci/config.yml | 76 ++++++++++++++++++++++--------------------- Dockerfile_for_circleci_image | 3 ++ 2 files changed, 42 insertions(+), 37 deletions(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index 167cb4db..285a66a5 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -8,11 +8,11 @@ jobs: - run: name: Build and test examples command: | - mkdir build; - cd build; - cmake -DCMAKE_BUILD_TYPE=Release -DWITH_GUDHI_EXAMPLE=ON -DWITH_GUDHI_TEST=OFF -DWITH_GUDHI_UTILITIES=OFF -DWITH_GUDHI_PYTHON=OFF ..; - make all; - ctest --output-on-failure; + mkdir build + cd build + cmake -DCMAKE_BUILD_TYPE=Release -DWITH_GUDHI_EXAMPLE=ON -DWITH_GUDHI_TEST=OFF -DWITH_GUDHI_UTILITIES=OFF -DWITH_GUDHI_PYTHON=OFF .. + make all + ctest --output-on-failure tests: docker: @@ -22,11 +22,11 @@ jobs: - run: name: Build and test unitary tests command: | - mkdir build; - cd build; - cmake -DCMAKE_BUILD_TYPE=Release -DWITH_GUDHI_EXAMPLE=OFF -DWITH_GUDHI_TEST=ON -DWITH_GUDHI_UTILITIES=OFF -DWITH_GUDHI_PYTHON=OFF ..; - make all; - ctest --output-on-failure; + mkdir build + cd build + cmake -DCMAKE_BUILD_TYPE=Release -DWITH_GUDHI_EXAMPLE=OFF -DWITH_GUDHI_TEST=ON -DWITH_GUDHI_UTILITIES=OFF -DWITH_GUDHI_PYTHON=OFF .. + make all + ctest --output-on-failure utils: docker: @@ -36,11 +36,11 @@ jobs: - run: name: Build and test utilities command: | - mkdir build; - cd build; - cmake -DCMAKE_BUILD_TYPE=Release -DWITH_GUDHI_EXAMPLE=OFF -DWITH_GUDHI_TEST=OFF -DWITH_GUDHI_UTILITIES=ON -DWITH_GUDHI_PYTHON=OFF ..; - make all; - ctest --output-on-failure; + mkdir build + cd build + cmake -DCMAKE_BUILD_TYPE=Release -DWITH_GUDHI_EXAMPLE=OFF -DWITH_GUDHI_TEST=OFF -DWITH_GUDHI_UTILITIES=ON -DWITH_GUDHI_PYTHON=OFF .. + make all + ctest --output-on-failure python: docker: @@ -52,25 +52,26 @@ jobs: command: | git submodule init git submodule update - mkdir build; - cd build; - cmake -DUSER_VERSION_DIR=version ..; - make user_version; - cd version; - cmake -DCMAKE_BUILD_TYPE=Release -DWITH_GUDHI_EXAMPLE=OFF -DWITH_GUDHI_UTILITIES=OFF -DWITH_GUDHI_PYTHON=ON -DPython_ADDITIONAL_VERSIONS=3 .; - cd python; - python3 setup.py build_ext --inplace; - make sphinx; - cp -R sphinx /tmp/sphinx; - python3 setup.py install; - python3 setup.py clean --all || true; - python3 -m pip list - python3 -B -m pytest test/*.py --cov-report html --cov=gudhi; - cp -R htmlcov /tmp/htmlcov; + mkdir build + cd build + cmake -DUSER_VERSION_DIR=version .. + make user_version + cd version + cmake -DCMAKE_BUILD_TYPE=Release -DWITH_GUDHI_EXAMPLE=OFF -DWITH_GUDHI_UTILITIES=OFF -DWITH_GUDHI_PYTHON=ON -DPython_ADDITIONAL_VERSIONS=3 . + cd python + python3 setup.py build_ext --inplace + make sphinx + cp -R sphinx /tmp/sphinx + python3 setup.py install + python3 setup.py clean --all + python3 -B -m pytest test/*.py --cov-report html --cov=gudhi + cp -R htmlcov /tmp/htmlcov - store_artifacts: path: /tmp/sphinx + destination: sphinx - store_artifacts: path: /tmp/htmlcov + destination: htmlcov doxygen: docker: @@ -82,16 +83,17 @@ jobs: command: | git submodule init git submodule update - mkdir build; - cd build; - cmake -DCMAKE_BUILD_TYPE=Release -DWITH_GUDHI_EXAMPLE=OFF -DWITH_GUDHI_TEST=OFF -DWITH_GUDHI_UTILITIES=OFF -DWITH_GUDHI_PYTHON=OFF -DUSER_VERSION_DIR=version ..; - make doxygen 2>&1 | tee dox.log; - grep warning dox.log; - cp dox.log version/doc/html/; - cp -R version/doc/html /tmp/doxygen; + mkdir build + cd build + cmake -DCMAKE_BUILD_TYPE=Release -DWITH_GUDHI_EXAMPLE=OFF -DWITH_GUDHI_TEST=OFF -DWITH_GUDHI_UTILITIES=OFF -DWITH_GUDHI_PYTHON=OFF -DUSER_VERSION_DIR=version .. + make doxygen 2>&1 | tee dox.log + grep warning dox.log + cp dox.log version/doc/html/ + cp -R version/doc/html /tmp/doxygen - store_artifacts: path: /tmp/doxygen + destination: doxygen workflows: version: 2 diff --git a/Dockerfile_for_circleci_image b/Dockerfile_for_circleci_image index 464097e7..87f57071 100644 --- a/Dockerfile_for_circleci_image +++ b/Dockerfile_for_circleci_image @@ -23,6 +23,9 @@ ENV LANG en_US.UTF-8 ENV LANGUAGE en_US:en ENV LC_ALL en_US.UTF-8 +# Update again +RUN apt-get update + # Required for Gudhi compilation RUN apt-get install -y make \ git \ -- cgit v1.2.3 From 3845d669233afda0cb50270e3204c87d2814626f Mon Sep 17 00:00:00 2001 From: ROUVREAU Vincent Date: Fri, 21 Aug 2020 08:11:45 +0200 Subject: Add -DCMAKE_BUILD_TYPE=Release on installation doc --- src/common/doc/installation.h | 10 +++++----- src/python/doc/installation.rst | 2 +- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/src/common/doc/installation.h b/src/common/doc/installation.h index ce2c5448..6af645e2 100644 --- a/src/common/doc/installation.h +++ b/src/common/doc/installation.h @@ -14,13 +14,13 @@ \verbatim cd /path-to-gudhi/ mkdir build cd build/ -cmake .. +cmake -DCMAKE_BUILD_TYPE=Release .. make \endverbatim * By default, examples are disabled. You can activate their compilation with * ccmake (on Linux and Mac OSX), * cmake-gui (on Windows) or by modifying the * cmake command as follows : -\verbatim cmake -DWITH_GUDHI_EXAMPLE=ON .. +\verbatim cmake -DCMAKE_BUILD_TYPE=Release -DWITH_GUDHI_EXAMPLE=ON .. make \endverbatim * A list of utilities and examples is available here. * @@ -66,9 +66,9 @@ make doxygen * Some GUDHI modules (cf. \ref main_page "modules list"), and few examples require CGAL, a C++ library that provides * easy access to efficient and reliable geometric algorithms. * - * \note There is no need to install CGAL, you can just cmake . && make CGAL (or even - * cmake -DCGAL_HEADER_ONLY=ON .), thereafter you will be able to compile - * GUDHI by calling cmake -DCGAL_DIR=/your/path/to/CGAL-X.Y .. && make + * \note There is no need to install CGAL, you can just cmake -DCMAKE_BUILD_TYPE=Release . && make CGAL + * (or even cmake -DCMAKE_BUILD_TYPE=Release -DCGAL_HEADER_ONLY=ON .), thereafter you will be able to + * compile GUDHI by calling cmake -DCMAKE_BUILD_TYPE=Release -DCGAL_DIR=/your/path/to/CGAL-X.Y .. && make * * The procedure to install this library according to * your operating system is detailed here http://doc.cgal.org/latest/Manual/installation.html diff --git a/src/python/doc/installation.rst b/src/python/doc/installation.rst index 78e1af73..4cc31d5c 100644 --- a/src/python/doc/installation.rst +++ b/src/python/doc/installation.rst @@ -65,7 +65,7 @@ one can build the GUDHI Python module, by running the following commands in a te cd /path-to-gudhi/ mkdir build cd build/ - cmake .. + cmake -DCMAKE_BUILD_TYPE=Release .. cd python make -- cgit v1.2.3 From 34c3812e5c70799a184cec315e7ee9d71c7ad5b7 Mon Sep 17 00:00:00 2001 From: ROUVREAU Vincent Date: Fri, 21 Aug 2020 09:56:44 +0200 Subject: Virtual functions need signatures that exactly match --- .../Bitmap_cubical_complex_periodic_boundary_conditions_base.h | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/Bitmap_cubical_complex/include/gudhi/Bitmap_cubical_complex_periodic_boundary_conditions_base.h b/src/Bitmap_cubical_complex/include/gudhi/Bitmap_cubical_complex_periodic_boundary_conditions_base.h index 18901469..6a18f0eb 100644 --- a/src/Bitmap_cubical_complex/include/gudhi/Bitmap_cubical_complex_periodic_boundary_conditions_base.h +++ b/src/Bitmap_cubical_complex/include/gudhi/Bitmap_cubical_complex_periodic_boundary_conditions_base.h @@ -83,7 +83,7 @@ class Bitmap_cubical_complex_periodic_boundary_conditions_base : public Bitmap_c * The boundary elements are guaranteed to be returned so that the * incidence coefficients are alternating. */ - virtual std::vector get_boundary_of_a_cell(std::size_t cell) const; + virtual inline std::vector get_boundary_of_a_cell(std::size_t cell) const; /** * A version of a function that return coboundary of a given cell for an object of @@ -93,7 +93,7 @@ class Bitmap_cubical_complex_periodic_boundary_conditions_base : public Bitmap_c * To compute incidence between cells use compute_incidence_between_cells * procedure */ - virtual std::vector get_coboundary_of_a_cell(std::size_t cell) const; + virtual inline std::vector get_coboundary_of_a_cell(std::size_t cell) const; /** * This procedure compute incidence numbers between cubes. For a cube \f$A\f$ of @@ -114,7 +114,7 @@ class Bitmap_cubical_complex_periodic_boundary_conditions_base : public Bitmap_c * @exception std::logic_error In case when the cube \f$B\f$ is not n-1 * dimensional face of a cube \f$A\f$. **/ - virtual int compute_incidence_between_cells(std::size_t coface, std::size_t face) { + virtual int compute_incidence_between_cells(std::size_t coface, std::size_t face) const { // first get the counters for coface and face: std::vector coface_counter = this->compute_counter_for_given_cell(coface); std::vector face_counter = this->compute_counter_for_given_cell(face); -- cgit v1.2.3 From e8cfcc7017f9002a229996232fdb2d03a41d7ea7 Mon Sep 17 00:00:00 2001 From: ROUVREAU Vincent Date: Fri, 21 Aug 2020 15:40:17 +0200 Subject: Fix compilation issues when cgal but no eigen --- src/Alpha_complex/example/CMakeLists.txt | 8 ++- src/Alpha_complex/include/gudhi/Alpha_complex_3d.h | 2 - src/Alpha_complex/test/CMakeLists.txt | 6 +- src/Alpha_complex/utilities/CMakeLists.txt | 4 +- src/Collapse/example/CMakeLists.txt | 41 ++++++++------ .../include/gudhi/Flag_complex_edge_collapser.h | 6 ++ src/Collapse/test/CMakeLists.txt | 16 ++++-- src/Collapse/utilities/CMakeLists.txt | 66 ++++++++++++---------- 8 files changed, 87 insertions(+), 62 deletions(-) diff --git a/src/Alpha_complex/example/CMakeLists.txt b/src/Alpha_complex/example/CMakeLists.txt index 2eecd50c..6e231773 100644 --- a/src/Alpha_complex/example/CMakeLists.txt +++ b/src/Alpha_complex/example/CMakeLists.txt @@ -25,7 +25,7 @@ if (NOT CGAL_WITH_EIGEN3_VERSION VERSION_LESS 4.11.0) add_test(NAME Alpha_complex_example_fast_from_off_32 COMMAND $ "${CMAKE_SOURCE_DIR}/data/points/alphacomplexdoc.off" "32.0" "${CMAKE_CURRENT_BINARY_DIR}/fastalphaoffreader_result_32.txt") -if (DIFF_PATH) + if (DIFF_PATH) # Do not forget to copy test results files in current binary dir file(COPY "alphaoffreader_for_doc_32.txt" DESTINATION ${CMAKE_CURRENT_BINARY_DIR}/) file(COPY "alphaoffreader_for_doc_60.txt" DESTINATION ${CMAKE_CURRENT_BINARY_DIR}/) @@ -43,8 +43,10 @@ if (DIFF_PATH) add_test(Alpha_complex_example_fast_from_off_32_diff_files ${DIFF_PATH} ${CMAKE_CURRENT_BINARY_DIR}/fastalphaoffreader_result_32.txt ${CMAKE_CURRENT_BINARY_DIR}/alphaoffreader_for_doc_32.txt) set_tests_properties(Alpha_complex_example_fast_from_off_32_diff_files PROPERTIES DEPENDS Alpha_complex_example_fast_from_off_32) -endif() + endif() + endif(NOT CGAL_WITH_EIGEN3_VERSION VERSION_LESS 4.11.0) +if (NOT CGAL_VERSION VERSION_LESS 4.11.0) add_executable ( Alpha_complex_example_weighted_3d_from_points Weighted_alpha_complex_3d_from_points.cpp ) target_link_libraries(Alpha_complex_example_weighted_3d_from_points ${CGAL_LIBRARY}) if (TBB_FOUND) @@ -61,4 +63,4 @@ endif() add_test(NAME Alpha_complex_example_3d_from_points COMMAND $) -endif(NOT CGAL_WITH_EIGEN3_VERSION VERSION_LESS 4.11.0) +endif(NOT CGAL_VERSION VERSION_LESS 4.11.0) diff --git a/src/Alpha_complex/include/gudhi/Alpha_complex_3d.h b/src/Alpha_complex/include/gudhi/Alpha_complex_3d.h index 2c1b97a4..622b10ee 100644 --- a/src/Alpha_complex/include/gudhi/Alpha_complex_3d.h +++ b/src/Alpha_complex/include/gudhi/Alpha_complex_3d.h @@ -38,8 +38,6 @@ #include #include // for CGAL_VERSION_NR -#include // for EIGEN_VERSION_AT_LEAST - #include #include diff --git a/src/Alpha_complex/test/CMakeLists.txt b/src/Alpha_complex/test/CMakeLists.txt index fe4b23e4..f38bd096 100644 --- a/src/Alpha_complex/test/CMakeLists.txt +++ b/src/Alpha_complex/test/CMakeLists.txt @@ -18,6 +18,10 @@ if (NOT CGAL_WITH_EIGEN3_VERSION VERSION_LESS 4.11.0) gudhi_add_boost_test(Alpha_complex_test_unit) gudhi_add_boost_test(Delaunay_complex_test_unit) +endif (NOT CGAL_WITH_EIGEN3_VERSION VERSION_LESS 4.11.0) + +if (NOT CGAL_VERSION VERSION_LESS 4.11.0) + add_executable ( Alpha_complex_3d_test_unit Alpha_complex_3d_unit_test.cpp ) 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 ) @@ -38,4 +42,4 @@ if (NOT CGAL_WITH_EIGEN3_VERSION VERSION_LESS 4.11.0) 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) +endif (NOT CGAL_VERSION VERSION_LESS 4.11.0) diff --git a/src/Alpha_complex/utilities/CMakeLists.txt b/src/Alpha_complex/utilities/CMakeLists.txt index 2ffbdde0..f0ddfc2c 100644 --- a/src/Alpha_complex/utilities/CMakeLists.txt +++ b/src/Alpha_complex/utilities/CMakeLists.txt @@ -27,7 +27,9 @@ if (NOT CGAL_WITH_EIGEN3_VERSION VERSION_LESS 4.11.0) endif() install(TARGETS alpha_complex_persistence DESTINATION bin) +endif (NOT CGAL_WITH_EIGEN3_VERSION VERSION_LESS 4.11.0) +if (NOT CGAL_VERSION VERSION_LESS 4.11.0) add_executable(alpha_complex_3d_persistence alpha_complex_3d_persistence.cpp) target_link_libraries(alpha_complex_3d_persistence ${CGAL_LIBRARY} Boost::program_options) if (TBB_FOUND) @@ -75,4 +77,4 @@ if (NOT CGAL_WITH_EIGEN3_VERSION VERSION_LESS 4.11.0) install(TARGETS alpha_complex_3d_persistence DESTINATION bin) -endif (NOT CGAL_WITH_EIGEN3_VERSION VERSION_LESS 4.11.0) +endif (NOT CGAL_VERSION VERSION_LESS 4.11.0) diff --git a/src/Collapse/example/CMakeLists.txt b/src/Collapse/example/CMakeLists.txt index ba0e75e3..4456a844 100644 --- a/src/Collapse/example/CMakeLists.txt +++ b/src/Collapse/example/CMakeLists.txt @@ -1,23 +1,28 @@ project(Edge_collapse_examples) -# Point cloud -add_executable ( Edge_collapse_example_basic edge_collapse_basic_example.cpp ) -if (TBB_FOUND) - target_link_libraries(Edge_collapse_example_basic ${TBB_LIBRARIES}) -endif() +if (NOT EIGEN3_VERSION VERSION_LESS 3.1.0) -add_test(NAME Edge_collapse_example_basic COMMAND $) + # Point cloud + add_executable ( Edge_collapse_example_basic edge_collapse_basic_example.cpp ) + + if (TBB_FOUND) + target_link_libraries(Edge_collapse_example_basic ${TBB_LIBRARIES}) + endif() + + add_test(NAME Edge_collapse_example_basic COMMAND $) + + # Point cloud + add_executable ( Edge_collapse_conserve_persistence edge_collapse_conserve_persistence.cpp ) + + if (TBB_FOUND) + target_link_libraries(Edge_collapse_conserve_persistence ${TBB_LIBRARIES}) + endif() + + add_test(NAME Edge_collapse_conserve_persistence_1 COMMAND $ + "${CMAKE_SOURCE_DIR}/data/points/tore3D_300.off" "0.2") + + add_test(NAME Edge_collapse_conserve_persistence_2 COMMAND $ + "${CMAKE_SOURCE_DIR}/data/points/tore3D_300.off" "1.8") -# Point cloud -add_executable ( Edge_collapse_conserve_persistence edge_collapse_conserve_persistence.cpp ) - -if (TBB_FOUND) - target_link_libraries(Edge_collapse_conserve_persistence ${TBB_LIBRARIES}) -endif() - -add_test(NAME Edge_collapse_conserve_persistence_1 COMMAND $ - "${CMAKE_SOURCE_DIR}/data/points/tore3D_300.off" "0.2") - -add_test(NAME Edge_collapse_conserve_persistence_2 COMMAND $ - "${CMAKE_SOURCE_DIR}/data/points/tore3D_300.off" "1.8") +endif() \ No newline at end of file diff --git a/src/Collapse/include/gudhi/Flag_complex_edge_collapser.h b/src/Collapse/include/gudhi/Flag_complex_edge_collapser.h index b6b7f7c1..d3aead70 100644 --- a/src/Collapse/include/gudhi/Flag_complex_edge_collapser.h +++ b/src/Collapse/include/gudhi/Flag_complex_edge_collapser.h @@ -18,6 +18,7 @@ #include #include +#include // for EIGEN_VERSION_AT_LEAST #ifdef GUDHI_USE_TBB #include @@ -34,6 +35,11 @@ #include // for std::inserter #include // for std::decay +// Make compilation fail - required for external projects - https://github.com/GUDHI/gudhi-devel/issues/10 +#if !EIGEN_VERSION_AT_LEAST(3,1,0) +# error Alpha_complex is only available for Eigen3 >= 3.1.0 installed with CGAL +#endif + namespace Gudhi { namespace collapse { diff --git a/src/Collapse/test/CMakeLists.txt b/src/Collapse/test/CMakeLists.txt index c7eafb46..c04199e2 100644 --- a/src/Collapse/test/CMakeLists.txt +++ b/src/Collapse/test/CMakeLists.txt @@ -1,9 +1,13 @@ project(Collapse_tests) -include(GUDHI_boost_test) +if (NOT EIGEN3_VERSION VERSION_LESS 3.1.0) -add_executable ( Collapse_test_unit collapse_unit_test.cpp ) -if (TBB_FOUND) - target_link_libraries(Collapse_test_unit ${TBB_LIBRARIES}) -endif() -gudhi_add_boost_test(Collapse_test_unit) + include(GUDHI_boost_test) + + add_executable ( Collapse_test_unit collapse_unit_test.cpp ) + if (TBB_FOUND) + target_link_libraries(Collapse_test_unit ${TBB_LIBRARIES}) + endif() + gudhi_add_boost_test(Collapse_test_unit) + +endif() \ No newline at end of file diff --git a/src/Collapse/utilities/CMakeLists.txt b/src/Collapse/utilities/CMakeLists.txt index c742144b..97fef649 100644 --- a/src/Collapse/utilities/CMakeLists.txt +++ b/src/Collapse/utilities/CMakeLists.txt @@ -1,33 +1,37 @@ project(Collapse_utilities) -# From a point cloud -add_executable ( point_cloud_edge_collapse_rips_persistence point_cloud_edge_collapse_rips_persistence.cpp ) -target_link_libraries(point_cloud_edge_collapse_rips_persistence Boost::program_options) - -if (TBB_FOUND) - target_link_libraries(point_cloud_edge_collapse_rips_persistence ${TBB_LIBRARIES}) -endif() -add_test(NAME Edge_collapse_utilities_point_cloud_rips_persistence COMMAND $ - "${CMAKE_SOURCE_DIR}/data/points/tore3D_1307.off" "-r" "0.25" "-m" "0.5" "-d" "3" "-p" "3" "-o" "off_results.pers") - -install(TARGETS point_cloud_edge_collapse_rips_persistence DESTINATION bin) - -# From a distance matrix -add_executable ( distance_matrix_edge_collapse_rips_persistence distance_matrix_edge_collapse_rips_persistence.cpp ) -target_link_libraries(distance_matrix_edge_collapse_rips_persistence Boost::program_options) - -if (TBB_FOUND) - target_link_libraries(distance_matrix_edge_collapse_rips_persistence ${TBB_LIBRARIES}) -endif() -add_test(NAME Edge_collapse_utilities_distance_matrix_rips_persistence COMMAND $ - "${CMAKE_SOURCE_DIR}/data/distance_matrix/tore3D_1307_distance_matrix.csv" "-r" "0.25" "-m" "0.5" "-d" "3" "-p" "3" "-o" "csv_results.pers") - -install(TARGETS distance_matrix_edge_collapse_rips_persistence DESTINATION bin) - -if (DIFF_PATH) - add_test(Edge_collapse_utilities_diff_persistence ${DIFF_PATH} - "off_results.pers" "csv_results.pers") - set_tests_properties(Edge_collapse_utilities_diff_persistence PROPERTIES DEPENDS - "Edge_collapse_utilities_point_cloud_rips_persistence;Edge_collapse_utilities_distance_matrix_rips_persistence") - -endif() +if (NOT EIGEN3_VERSION VERSION_LESS 3.1.0) + + # From a point cloud + add_executable ( point_cloud_edge_collapse_rips_persistence point_cloud_edge_collapse_rips_persistence.cpp ) + target_link_libraries(point_cloud_edge_collapse_rips_persistence Boost::program_options) + + if (TBB_FOUND) + target_link_libraries(point_cloud_edge_collapse_rips_persistence ${TBB_LIBRARIES}) + endif() + add_test(NAME Edge_collapse_utilities_point_cloud_rips_persistence COMMAND $ + "${CMAKE_SOURCE_DIR}/data/points/tore3D_1307.off" "-r" "0.25" "-m" "0.5" "-d" "3" "-p" "3" "-o" "off_results.pers") + + install(TARGETS point_cloud_edge_collapse_rips_persistence DESTINATION bin) + + # From a distance matrix + add_executable ( distance_matrix_edge_collapse_rips_persistence distance_matrix_edge_collapse_rips_persistence.cpp ) + target_link_libraries(distance_matrix_edge_collapse_rips_persistence Boost::program_options) + + if (TBB_FOUND) + target_link_libraries(distance_matrix_edge_collapse_rips_persistence ${TBB_LIBRARIES}) + endif() + add_test(NAME Edge_collapse_utilities_distance_matrix_rips_persistence COMMAND $ + "${CMAKE_SOURCE_DIR}/data/distance_matrix/tore3D_1307_distance_matrix.csv" "-r" "0.25" "-m" "0.5" "-d" "3" "-p" "3" "-o" "csv_results.pers") + + install(TARGETS distance_matrix_edge_collapse_rips_persistence DESTINATION bin) + + if (DIFF_PATH) + add_test(Edge_collapse_utilities_diff_persistence ${DIFF_PATH} + "off_results.pers" "csv_results.pers") + set_tests_properties(Edge_collapse_utilities_diff_persistence PROPERTIES DEPENDS + "Edge_collapse_utilities_point_cloud_rips_persistence;Edge_collapse_utilities_distance_matrix_rips_persistence") + + endif() + +endif() \ No newline at end of file -- cgit v1.2.3 From f424715caab7609085cf155abd98c88674ec329d Mon Sep 17 00:00:00 2001 From: ROUVREAU Vincent Date: Mon, 24 Aug 2020 09:20:02 +0200 Subject: code review: really bad copy/paste... --- src/Collapse/include/gudhi/Flag_complex_edge_collapser.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Collapse/include/gudhi/Flag_complex_edge_collapser.h b/src/Collapse/include/gudhi/Flag_complex_edge_collapser.h index d3aead70..713c6608 100644 --- a/src/Collapse/include/gudhi/Flag_complex_edge_collapser.h +++ b/src/Collapse/include/gudhi/Flag_complex_edge_collapser.h @@ -37,7 +37,7 @@ // Make compilation fail - required for external projects - https://github.com/GUDHI/gudhi-devel/issues/10 #if !EIGEN_VERSION_AT_LEAST(3,1,0) -# error Alpha_complex is only available for Eigen3 >= 3.1.0 installed with CGAL +# error Edge Collapse is only available for Eigen3 >= 3.1.0 #endif namespace Gudhi { -- cgit v1.2.3 From 023c4cc8a4fc167a03f9c87f066c80f722c0e520 Mon Sep 17 00:00:00 2001 From: ROUVREAU Vincent Date: Mon, 24 Aug 2020 10:12:01 +0200 Subject: code review: override and remove inline --- .../Bitmap_cubical_complex_periodic_boundary_conditions_base.h | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/Bitmap_cubical_complex/include/gudhi/Bitmap_cubical_complex_periodic_boundary_conditions_base.h b/src/Bitmap_cubical_complex/include/gudhi/Bitmap_cubical_complex_periodic_boundary_conditions_base.h index 6a18f0eb..8ac7ae23 100644 --- a/src/Bitmap_cubical_complex/include/gudhi/Bitmap_cubical_complex_periodic_boundary_conditions_base.h +++ b/src/Bitmap_cubical_complex/include/gudhi/Bitmap_cubical_complex_periodic_boundary_conditions_base.h @@ -83,7 +83,7 @@ class Bitmap_cubical_complex_periodic_boundary_conditions_base : public Bitmap_c * The boundary elements are guaranteed to be returned so that the * incidence coefficients are alternating. */ - virtual inline std::vector get_boundary_of_a_cell(std::size_t cell) const; + virtual std::vector get_boundary_of_a_cell(std::size_t cell) const override; /** * A version of a function that return coboundary of a given cell for an object of @@ -93,7 +93,7 @@ class Bitmap_cubical_complex_periodic_boundary_conditions_base : public Bitmap_c * To compute incidence between cells use compute_incidence_between_cells * procedure */ - virtual inline std::vector get_coboundary_of_a_cell(std::size_t cell) const; + virtual std::vector get_coboundary_of_a_cell(std::size_t cell) const override; /** * This procedure compute incidence numbers between cubes. For a cube \f$A\f$ of @@ -114,7 +114,7 @@ class Bitmap_cubical_complex_periodic_boundary_conditions_base : public Bitmap_c * @exception std::logic_error In case when the cube \f$B\f$ is not n-1 * dimensional face of a cube \f$A\f$. **/ - virtual int compute_incidence_between_cells(std::size_t coface, std::size_t face) const { + virtual int compute_incidence_between_cells(std::size_t coface, std::size_t face) const override { // first get the counters for coface and face: std::vector coface_counter = this->compute_counter_for_given_cell(coface); std::vector face_counter = this->compute_counter_for_given_cell(face); -- cgit v1.2.3 From 12371aa8ec7693f97200c5b3df3aa20add4ad621 Mon Sep 17 00:00:00 2001 From: ROUVREAU Vincent Date: Tue, 25 Aug 2020 08:43:19 +0200 Subject: Code review: min_dim = 0 as default and some doc review --- src/Simplex_tree/include/gudhi/Simplex_tree.h | 9 ++++++--- src/python/gudhi/simplex_tree.pyx | 13 ++++++++----- 2 files changed, 14 insertions(+), 8 deletions(-) diff --git a/src/Simplex_tree/include/gudhi/Simplex_tree.h b/src/Simplex_tree/include/gudhi/Simplex_tree.h index 89b4a5df..9cd51081 100644 --- a/src/Simplex_tree/include/gudhi/Simplex_tree.h +++ b/src/Simplex_tree/include/gudhi/Simplex_tree.h @@ -1670,10 +1670,13 @@ class Simplex_tree { public: /** \brief This function resets filtration value from a given dimension. Resets all the Simplex_tree when * `min_dim = 0`. + * `reset_filtration` may break the filtration property with `min_dim > 0`, and it is the user's responsibility to + * make it a valid filtration (using a large enough `filt_value`, or calling `make_filtration_non_decreasing` + * afterwards for instance). * @param[in] filt_value The new filtration value. - * @param[in] min_dim The minimal dimension. + * @param[in] min_dim The minimal dimension. Default value is 0. */ - void reset_filtration(Filtration_value filt_value, int min_dim) { + void reset_filtration(Filtration_value filt_value, int min_dim = 0) { for (auto& simplex : root_.members()) { if (min_dim <= 0) { simplex.second.assign_filtration(filt_value); @@ -1689,7 +1692,7 @@ class Simplex_tree { /** \brief Recursively resets filtration value from a given dimension. * @param[in] sib Siblings to be parsed. * @param[in] filt_value The new filtration value. - * @param[in] min_dim The maximal dimension. + * @param[in] min_dim The minimal dimension. */ void rec_reset_filtration(Siblings * sib, Filtration_value filt_value, int min_dim) { for (auto sh = sib->members().begin(); sh != sib->members().end(); ++sh) { diff --git a/src/python/gudhi/simplex_tree.pyx b/src/python/gudhi/simplex_tree.pyx index 657d55be..f28990cc 100644 --- a/src/python/gudhi/simplex_tree.pyx +++ b/src/python/gudhi/simplex_tree.pyx @@ -358,14 +358,17 @@ cdef class SimplexTree: """ return self.get_ptr().make_filtration_non_decreasing() - def reset_filtration(self, filtration, min_dim): - """This function resets filtration value from a given dimension. - Resets all the simplex tree when `min_dim = 0`. + def reset_filtration(self, filtration, min_dim = 0): + """This function resets filtration value from a given dimension. Resets all the simplex tree when + `min_dim = 0`. + `reset_filtration` may break the filtration property with `min_dim > 0`, and it is the user's responsibility to + make it a valid filtration (using a large enough `filt_value`, or calling `make_filtration_non_decreasing` + afterwards for instance). :param filtration: New threshold value. :type filtration: float. - :param max_dim: The minimal dimension. - :type max_dim: int. + :param min_dim: The minimal dimension. Default value is 0. + :type min_dim: int. """ self.get_ptr().reset_filtration(filtration, min_dim) -- cgit v1.2.3 From 723252b311a7989ef1d4271b3a812ec7d0be05f2 Mon Sep 17 00:00:00 2001 From: ROUVREAU Vincent Date: Tue, 25 Aug 2020 12:50:22 +0200 Subject: Code review: use minimal depth recursively instead of computing dimension on each loop --- src/Simplex_tree/include/gudhi/Simplex_tree.h | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/Simplex_tree/include/gudhi/Simplex_tree.h b/src/Simplex_tree/include/gudhi/Simplex_tree.h index 9cd51081..70ef4c66 100644 --- a/src/Simplex_tree/include/gudhi/Simplex_tree.h +++ b/src/Simplex_tree/include/gudhi/Simplex_tree.h @@ -1682,25 +1682,25 @@ class Simplex_tree { simplex.second.assign_filtration(filt_value); } if (has_children(&simplex)) { - rec_reset_filtration(simplex.second.children(), filt_value, min_dim); + rec_reset_filtration(simplex.second.children(), filt_value, min_dim - 1); } } clear_filtration(); // Drop the cache. } private: - /** \brief Recursively resets filtration value from a given dimension. + /** \brief Recursively resets filtration value when minimal depth <= 0. * @param[in] sib Siblings to be parsed. * @param[in] filt_value The new filtration value. - * @param[in] min_dim The minimal dimension. + * @param[in] min_depth The minimal depth. */ - void rec_reset_filtration(Siblings * sib, Filtration_value filt_value, int min_dim) { + void rec_reset_filtration(Siblings * sib, Filtration_value filt_value, int min_depth) { for (auto sh = sib->members().begin(); sh != sib->members().end(); ++sh) { - if (min_dim <= dimension(sh)) { + if (min_depth <= 0) { sh->second.assign_filtration(filt_value); } if (has_children(sh)) { - rec_reset_filtration(sh->second.children(), filt_value, min_dim); + rec_reset_filtration(sh->second.children(), filt_value, min_depth - 1); } } } -- cgit v1.2.3 From 625ff957479c8a37b4ae02bba29dfffc0d3f1a84 Mon Sep 17 00:00:00 2001 From: ROUVREAU Vincent Date: Fri, 28 Aug 2020 14:38:28 +0200 Subject: code review: Rollback as these changes does not help --- src/python/setup.py.in | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/src/python/setup.py.in b/src/python/setup.py.in index f211f5d2..d2708177 100644 --- a/src/python/setup.py.in +++ b/src/python/setup.py.in @@ -32,7 +32,7 @@ runtime_library_dirs=[@GUDHI_PYTHON_RUNTIME_LIBRARY_DIRS@] # Create ext_modules list from module list ext_modules = [] for module in cython_modules: - extension = Extension( + ext_modules.append(Extension( 'gudhi.' + module, sources = [source_dir + module + '.pyx',], language = 'c++', @@ -41,9 +41,8 @@ for module in cython_modules: libraries=libraries, library_dirs=library_dirs, include_dirs=include_dirs, - runtime_library_dirs=runtime_library_dirs,) - extension.cython_directives = {'language_level': str(sys.version_info[0])} - ext_modules.append(extension) + runtime_library_dirs=runtime_library_dirs, + cython_directives = {'language_level': str(sys.version_info[0])},)) ext_modules = cythonize(ext_modules) -- cgit v1.2.3 From 4e794277bfa2158ecaeb7e9db303b92ec84a2f3c Mon Sep 17 00:00:00 2001 From: ROUVREAU Vincent Date: Fri, 28 Aug 2020 14:40:22 +0200 Subject: bad identation --- src/python/setup.py.in | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/python/setup.py.in b/src/python/setup.py.in index d2708177..98d058fc 100644 --- a/src/python/setup.py.in +++ b/src/python/setup.py.in @@ -42,7 +42,7 @@ for module in cython_modules: library_dirs=library_dirs, include_dirs=include_dirs, runtime_library_dirs=runtime_library_dirs, - cython_directives = {'language_level': str(sys.version_info[0])},)) + cython_directives = {'language_level': str(sys.version_info[0])},)) ext_modules = cythonize(ext_modules) -- cgit v1.2.3 From 05c9c0060ec8ff4cbf8619ff74724c2eea426d84 Mon Sep 17 00:00:00 2001 From: ROUVREAU Vincent Date: Tue, 8 Sep 2020 16:43:36 +0200 Subject: CMake > 3.5 to use Boost targets. Compile only what is available from boost targets --- CMakeLists.txt | 2 +- src/Alpha_complex/utilities/CMakeLists.txt | 128 +++++++++++---------- src/Bottleneck_distance/example/CMakeLists.txt | 20 ++-- src/CMakeLists.txt | 2 +- src/Cech_complex/benchmark/CMakeLists.txt | 15 +-- src/Cech_complex/example/CMakeLists.txt | 15 +-- src/Cech_complex/test/CMakeLists.txt | 3 - src/Cech_complex/utilities/CMakeLists.txt | 19 +-- src/Collapse/utilities/CMakeLists.txt | 62 +++++----- src/Persistent_cohomology/benchmark/CMakeLists.txt | 14 ++- src/Persistent_cohomology/example/CMakeLists.txt | 79 +++++++------ src/Rips_complex/utilities/CMakeLists.txt | 67 ++++++----- src/Simplex_tree/example/CMakeLists.txt | 14 ++- src/Witness_complex/utilities/CMakeLists.txt | 36 +++--- src/cmake/modules/GUDHI_modules.cmake | 7 +- .../modules/GUDHI_third_party_libraries.cmake | 39 +------ src/common/doc/installation.h | 8 +- src/python/doc/installation.rst | 2 +- 18 files changed, 267 insertions(+), 265 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 8b82036b..4257a025 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,4 +1,4 @@ -cmake_minimum_required(VERSION 3.1) +cmake_minimum_required(VERSION 3.5) project(GUDHIdev) diff --git a/src/Alpha_complex/utilities/CMakeLists.txt b/src/Alpha_complex/utilities/CMakeLists.txt index f0ddfc2c..1e7dc1dd 100644 --- a/src/Alpha_complex/utilities/CMakeLists.txt +++ b/src/Alpha_complex/utilities/CMakeLists.txt @@ -1,80 +1,82 @@ project(Alpha_complex_utilities) if (NOT CGAL_WITH_EIGEN3_VERSION VERSION_LESS 4.11.0) - add_executable (alpha_complex_persistence alpha_complex_persistence.cpp) - target_link_libraries(alpha_complex_persistence ${CGAL_LIBRARY} Boost::program_options) + if (TARGET Boost::program_options) + add_executable (alpha_complex_persistence alpha_complex_persistence.cpp) + target_link_libraries(alpha_complex_persistence ${CGAL_LIBRARY} Boost::program_options) - if (TBB_FOUND) - target_link_libraries(alpha_complex_persistence ${TBB_LIBRARIES}) - endif(TBB_FOUND) - add_test(NAME Alpha_complex_utilities_safe_alpha_complex_persistence COMMAND $ - "${CMAKE_SOURCE_DIR}/data/points/tore3D_300.off" "-p" "2" "-m" "0.45" "-o" "safe.pers") - add_test(NAME Alpha_complex_utilities_fast_alpha_complex_persistence COMMAND $ - "${CMAKE_SOURCE_DIR}/data/points/tore3D_300.off" "-p" "2" "-m" "0.45" "-o" "fast.pers" "-f") - add_test(NAME Alpha_complex_utilities_exact_alpha_complex_persistence COMMAND $ - "${CMAKE_SOURCE_DIR}/data/points/tore3D_300.off" "-p" "2" "-m" "0.45" "-o" "exact.pers" "-e") - if (DIFF_PATH) - add_test(Alpha_complex_utilities_diff_exact_alpha_complex ${DIFF_PATH} - "exact.pers" "safe.pers") - set_tests_properties(Alpha_complex_utilities_diff_exact_alpha_complex PROPERTIES DEPENDS - "Alpha_complex_utilities_exact_alpha_complex_persistence;Alpha_complex_utilities_safe_alpha_complex_persistence") - - add_test(Alpha_complex_utilities_diff_fast_alpha_complex ${DIFF_PATH} - "fast.pers" "safe.pers") - set_tests_properties(Alpha_complex_utilities_diff_fast_alpha_complex PROPERTIES DEPENDS - "Alpha_complex_utilities_fast_alpha_complex_persistence;Alpha_complex_utilities_safe_alpha_complex_persistence") + if (TBB_FOUND) + target_link_libraries(alpha_complex_persistence ${TBB_LIBRARIES}) + endif(TBB_FOUND) + add_test(NAME Alpha_complex_utilities_safe_alpha_complex_persistence COMMAND $ + "${CMAKE_SOURCE_DIR}/data/points/tore3D_300.off" "-p" "2" "-m" "0.45" "-o" "safe.pers") + add_test(NAME Alpha_complex_utilities_fast_alpha_complex_persistence COMMAND $ + "${CMAKE_SOURCE_DIR}/data/points/tore3D_300.off" "-p" "2" "-m" "0.45" "-o" "fast.pers" "-f") + add_test(NAME Alpha_complex_utilities_exact_alpha_complex_persistence COMMAND $ + "${CMAKE_SOURCE_DIR}/data/points/tore3D_300.off" "-p" "2" "-m" "0.45" "-o" "exact.pers" "-e") + if (DIFF_PATH) + add_test(Alpha_complex_utilities_diff_exact_alpha_complex ${DIFF_PATH} + "exact.pers" "safe.pers") + set_tests_properties(Alpha_complex_utilities_diff_exact_alpha_complex PROPERTIES DEPENDS + "Alpha_complex_utilities_exact_alpha_complex_persistence;Alpha_complex_utilities_safe_alpha_complex_persistence") + add_test(Alpha_complex_utilities_diff_fast_alpha_complex ${DIFF_PATH} + "fast.pers" "safe.pers") + set_tests_properties(Alpha_complex_utilities_diff_fast_alpha_complex PROPERTIES DEPENDS + "Alpha_complex_utilities_fast_alpha_complex_persistence;Alpha_complex_utilities_safe_alpha_complex_persistence") + endif() + + install(TARGETS alpha_complex_persistence DESTINATION bin) endif() - - install(TARGETS alpha_complex_persistence DESTINATION bin) endif (NOT CGAL_WITH_EIGEN3_VERSION VERSION_LESS 4.11.0) if (NOT CGAL_VERSION VERSION_LESS 4.11.0) - add_executable(alpha_complex_3d_persistence alpha_complex_3d_persistence.cpp) - target_link_libraries(alpha_complex_3d_persistence ${CGAL_LIBRARY} Boost::program_options) - if (TBB_FOUND) - target_link_libraries(alpha_complex_3d_persistence ${TBB_LIBRARIES}) - endif(TBB_FOUND) + if (TARGET Boost::program_options) + add_executable(alpha_complex_3d_persistence alpha_complex_3d_persistence.cpp) + target_link_libraries(alpha_complex_3d_persistence ${CGAL_LIBRARY} Boost::program_options) + if (TBB_FOUND) + target_link_libraries(alpha_complex_3d_persistence ${TBB_LIBRARIES}) + endif(TBB_FOUND) - add_test(NAME Alpha_complex_utilities_alpha_complex_3d COMMAND $ - "${CMAKE_SOURCE_DIR}/data/points/tore3D_300.off" - "-p" "2" "-m" "0.45" "-o" "safe_3d.pers") + add_test(NAME Alpha_complex_utilities_alpha_complex_3d COMMAND $ + "${CMAKE_SOURCE_DIR}/data/points/tore3D_300.off" + "-p" "2" "-m" "0.45" "-o" "safe_3d.pers") - add_test(NAME Alpha_complex_utilities_exact_alpha_complex_3d COMMAND $ - "${CMAKE_SOURCE_DIR}/data/points/tore3D_300.off" - "-p" "2" "-m" "0.45" "-o" "exact_3d.pers" "-e") + add_test(NAME Alpha_complex_utilities_exact_alpha_complex_3d COMMAND $ + "${CMAKE_SOURCE_DIR}/data/points/tore3D_300.off" + "-p" "2" "-m" "0.45" "-o" "exact_3d.pers" "-e") - add_test(NAME Alpha_complex_utilities_fast_alpha_complex_3d COMMAND $ - "${CMAKE_SOURCE_DIR}/data/points/tore3D_300.off" - "-p" "2" "-m" "0.45" "-o" "fast_3d.pers" "-f") - - if (DIFF_PATH) - add_test(Alpha_complex_utilities_diff_exact_alpha_complex_3d ${DIFF_PATH} - "exact_3d.pers" "safe_3d.pers") - set_tests_properties(Alpha_complex_utilities_diff_exact_alpha_complex_3d PROPERTIES DEPENDS - "Alpha_complex_utilities_exact_alpha_complex_3d;Alpha_complex_utilities_alpha_complex_3d") - add_test(Alpha_complex_utilities_diff_fast_alpha_complex_3d ${DIFF_PATH} - "fast_3d.pers" "safe_3d.pers") - set_tests_properties(Alpha_complex_utilities_diff_fast_alpha_complex_3d PROPERTIES DEPENDS - "Alpha_complex_utilities_fast_alpha_complex_3d;Alpha_complex_utilities_alpha_complex_3d") - endif() + add_test(NAME Alpha_complex_utilities_fast_alpha_complex_3d COMMAND $ + "${CMAKE_SOURCE_DIR}/data/points/tore3D_300.off" + "-p" "2" "-m" "0.45" "-o" "fast_3d.pers" "-f") - add_test(NAME Alpha_complex_utilities_periodic_alpha_complex_3d_persistence COMMAND $ - "${CMAKE_SOURCE_DIR}/data/points/grid_10_10_10_in_0_1.off" - "-c" "${CMAKE_SOURCE_DIR}/data/points/iso_cuboid_3_in_0_1.txt" - "-p" "2" "-m" "0") + if (DIFF_PATH) + add_test(Alpha_complex_utilities_diff_exact_alpha_complex_3d ${DIFF_PATH} + "exact_3d.pers" "safe_3d.pers") + set_tests_properties(Alpha_complex_utilities_diff_exact_alpha_complex_3d PROPERTIES DEPENDS + "Alpha_complex_utilities_exact_alpha_complex_3d;Alpha_complex_utilities_alpha_complex_3d") + add_test(Alpha_complex_utilities_diff_fast_alpha_complex_3d ${DIFF_PATH} + "fast_3d.pers" "safe_3d.pers") + set_tests_properties(Alpha_complex_utilities_diff_fast_alpha_complex_3d PROPERTIES DEPENDS + "Alpha_complex_utilities_fast_alpha_complex_3d;Alpha_complex_utilities_alpha_complex_3d") + endif() - add_test(NAME Alpha_complex_utilities_weighted_alpha_complex_3d COMMAND $ - "${CMAKE_SOURCE_DIR}/data/points/grid_10_10_10_in_0_1.off" - "-w" "${CMAKE_SOURCE_DIR}/data/points/grid_10_10_10_in_0_1.weights" - "-p" "2" "-m" "0") + add_test(NAME Alpha_complex_utilities_periodic_alpha_complex_3d_persistence COMMAND $ + "${CMAKE_SOURCE_DIR}/data/points/grid_10_10_10_in_0_1.off" + "-c" "${CMAKE_SOURCE_DIR}/data/points/iso_cuboid_3_in_0_1.txt" + "-p" "2" "-m" "0") - add_test(NAME Alpha_complex_utilities_weighted_periodic_alpha_complex_3d COMMAND $ - "${CMAKE_SOURCE_DIR}/data/points/grid_10_10_10_in_0_1.off" - "-w" "${CMAKE_SOURCE_DIR}/data/points/grid_10_10_10_in_0_1.weights" - "-c" "${CMAKE_SOURCE_DIR}/data/points/iso_cuboid_3_in_0_1.txt" - "-p" "2" "-m" "0" "-e") - - install(TARGETS alpha_complex_3d_persistence DESTINATION bin) + add_test(NAME Alpha_complex_utilities_weighted_alpha_complex_3d COMMAND $ + "${CMAKE_SOURCE_DIR}/data/points/grid_10_10_10_in_0_1.off" + "-w" "${CMAKE_SOURCE_DIR}/data/points/grid_10_10_10_in_0_1.weights" + "-p" "2" "-m" "0") + add_test(NAME Alpha_complex_utilities_weighted_periodic_alpha_complex_3d COMMAND $ + "${CMAKE_SOURCE_DIR}/data/points/grid_10_10_10_in_0_1.off" + "-w" "${CMAKE_SOURCE_DIR}/data/points/grid_10_10_10_in_0_1.weights" + "-c" "${CMAKE_SOURCE_DIR}/data/points/iso_cuboid_3_in_0_1.txt" + "-p" "2" "-m" "0" "-e") + + install(TARGETS alpha_complex_3d_persistence DESTINATION bin) + endif() endif (NOT CGAL_VERSION VERSION_LESS 4.11.0) diff --git a/src/Bottleneck_distance/example/CMakeLists.txt b/src/Bottleneck_distance/example/CMakeLists.txt index 9839c59d..d16ea6e5 100644 --- a/src/Bottleneck_distance/example/CMakeLists.txt +++ b/src/Bottleneck_distance/example/CMakeLists.txt @@ -12,14 +12,16 @@ if (NOT CGAL_VERSION VERSION_LESS 4.11.0) endif (NOT CGAL_VERSION VERSION_LESS 4.11.0) if (NOT CGAL_WITH_EIGEN3_VERSION VERSION_LESS 4.11.0) - add_executable (alpha_rips_persistence_bottleneck_distance alpha_rips_persistence_bottleneck_distance.cpp) - target_link_libraries(alpha_rips_persistence_bottleneck_distance Boost::program_options) + if (TARGET Boost::program_options) + add_executable (alpha_rips_persistence_bottleneck_distance alpha_rips_persistence_bottleneck_distance.cpp) + target_link_libraries(alpha_rips_persistence_bottleneck_distance Boost::program_options) - if (TBB_FOUND) - target_link_libraries(alpha_rips_persistence_bottleneck_distance ${TBB_LIBRARIES}) - endif(TBB_FOUND) - - add_test(NAME Bottleneck_distance_example_alpha_rips_persistence_bottleneck - COMMAND $ - "${CMAKE_SOURCE_DIR}/data/points/tore3D_1307.off" "-r" "0.15" "-m" "0.12" "-d" "3" "-p" "3") + if (TBB_FOUND) + target_link_libraries(alpha_rips_persistence_bottleneck_distance ${TBB_LIBRARIES}) + endif(TBB_FOUND) + + add_test(NAME Bottleneck_distance_example_alpha_rips_persistence_bottleneck + COMMAND $ + "${CMAKE_SOURCE_DIR}/data/points/tore3D_1307.off" "-r" "0.15" "-m" "0.12" "-d" "3" "-p" "3") + endif() endif (NOT CGAL_WITH_EIGEN3_VERSION VERSION_LESS 4.11.0) diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 9e4d78ac..cc230531 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -1,4 +1,4 @@ -cmake_minimum_required(VERSION 3.1) +cmake_minimum_required(VERSION 3.5) project(GUDHI) diff --git a/src/Cech_complex/benchmark/CMakeLists.txt b/src/Cech_complex/benchmark/CMakeLists.txt index c04bca53..bc54c0f3 100644 --- a/src/Cech_complex/benchmark/CMakeLists.txt +++ b/src/Cech_complex/benchmark/CMakeLists.txt @@ -1,12 +1,13 @@ -cmake_minimum_required(VERSION 2.6) project(Cech_complex_benchmark) # Do not forget to copy test files in current binary dir file(COPY "${CMAKE_SOURCE_DIR}/data/points/tore3D_1307.off" DESTINATION ${CMAKE_CURRENT_BINARY_DIR}/) -add_executable(cech_complex_benchmark cech_complex_benchmark.cpp) -target_link_libraries(cech_complex_benchmark Boost::filesystem) - -if (TBB_FOUND) - target_link_libraries(cech_complex_benchmark ${TBB_LIBRARIES}) -endif() +if(TARGET Boost::filesystem) + add_executable(cech_complex_benchmark cech_complex_benchmark.cpp) + target_link_libraries(cech_complex_benchmark Boost::filesystem) + + if (TBB_FOUND) + target_link_libraries(cech_complex_benchmark ${TBB_LIBRARIES}) + endif() +endif() \ No newline at end of file diff --git a/src/Cech_complex/example/CMakeLists.txt b/src/Cech_complex/example/CMakeLists.txt index 98757988..1b08c7cb 100644 --- a/src/Cech_complex/example/CMakeLists.txt +++ b/src/Cech_complex/example/CMakeLists.txt @@ -1,13 +1,14 @@ -cmake_minimum_required(VERSION 2.6) project(Cech_complex_examples) -add_executable ( Cech_complex_example_step_by_step cech_complex_step_by_step.cpp ) -target_link_libraries(Cech_complex_example_step_by_step Boost::program_options) -if (TBB_FOUND) - target_link_libraries(Cech_complex_example_step_by_step ${TBB_LIBRARIES}) +if (TARGET Boost::program_options) + add_executable ( Cech_complex_example_step_by_step cech_complex_step_by_step.cpp ) + target_link_libraries(Cech_complex_example_step_by_step Boost::program_options) + if (TBB_FOUND) + target_link_libraries(Cech_complex_example_step_by_step ${TBB_LIBRARIES}) + endif() + add_test(NAME Cech_complex_utility_from_rips_on_tore_3D COMMAND $ + "${CMAKE_SOURCE_DIR}/data/points/tore3D_300.off" "-r" "0.25" "-d" "3") endif() -add_test(NAME Cech_complex_utility_from_rips_on_tore_3D COMMAND $ - "${CMAKE_SOURCE_DIR}/data/points/tore3D_300.off" "-r" "0.25" "-d" "3") add_executable ( Cech_complex_example_from_points cech_complex_example_from_points.cpp) if (TBB_FOUND) diff --git a/src/Cech_complex/test/CMakeLists.txt b/src/Cech_complex/test/CMakeLists.txt index db510af3..e6a2a18f 100644 --- a/src/Cech_complex/test/CMakeLists.txt +++ b/src/Cech_complex/test/CMakeLists.txt @@ -1,6 +1,3 @@ -cmake_minimum_required(VERSION 2.6) -project(Cech_complex_tests) - include(GUDHI_boost_test) add_executable ( Cech_complex_test_unit test_cech_complex.cpp ) diff --git a/src/Cech_complex/utilities/CMakeLists.txt b/src/Cech_complex/utilities/CMakeLists.txt index 253d7304..b183c8d8 100644 --- a/src/Cech_complex/utilities/CMakeLists.txt +++ b/src/Cech_complex/utilities/CMakeLists.txt @@ -1,14 +1,15 @@ -cmake_minimum_required(VERSION 2.6) project(Cech_complex_utilities) -add_executable(cech_persistence cech_persistence.cpp) -target_link_libraries(cech_persistence Boost::program_options) +if (TARGET Boost::program_options) + add_executable(cech_persistence cech_persistence.cpp) + target_link_libraries(cech_persistence Boost::program_options) -if (TBB_FOUND) - target_link_libraries(cech_persistence ${TBB_LIBRARIES}) -endif() + if (TBB_FOUND) + target_link_libraries(cech_persistence ${TBB_LIBRARIES}) + endif() -add_test(NAME Cech_complex_utility_from_rips_on_tore_3D COMMAND $ - "${CMAKE_SOURCE_DIR}/data/points/tore3D_300.off" "-r" "0.25" "-m" "0.5" "-d" "3" "-p" "3") + add_test(NAME Cech_complex_utility_from_rips_on_tore_3D COMMAND $ + "${CMAKE_SOURCE_DIR}/data/points/tore3D_300.off" "-r" "0.25" "-m" "0.5" "-d" "3" "-p" "3") -install(TARGETS cech_persistence DESTINATION bin) + install(TARGETS cech_persistence DESTINATION bin) +endif() \ No newline at end of file diff --git a/src/Collapse/utilities/CMakeLists.txt b/src/Collapse/utilities/CMakeLists.txt index 97fef649..bce99e90 100644 --- a/src/Collapse/utilities/CMakeLists.txt +++ b/src/Collapse/utilities/CMakeLists.txt @@ -1,37 +1,37 @@ project(Collapse_utilities) if (NOT EIGEN3_VERSION VERSION_LESS 3.1.0) - - # From a point cloud - add_executable ( point_cloud_edge_collapse_rips_persistence point_cloud_edge_collapse_rips_persistence.cpp ) - target_link_libraries(point_cloud_edge_collapse_rips_persistence Boost::program_options) - - if (TBB_FOUND) - target_link_libraries(point_cloud_edge_collapse_rips_persistence ${TBB_LIBRARIES}) - endif() - add_test(NAME Edge_collapse_utilities_point_cloud_rips_persistence COMMAND $ - "${CMAKE_SOURCE_DIR}/data/points/tore3D_1307.off" "-r" "0.25" "-m" "0.5" "-d" "3" "-p" "3" "-o" "off_results.pers") - - install(TARGETS point_cloud_edge_collapse_rips_persistence DESTINATION bin) - - # From a distance matrix - add_executable ( distance_matrix_edge_collapse_rips_persistence distance_matrix_edge_collapse_rips_persistence.cpp ) - target_link_libraries(distance_matrix_edge_collapse_rips_persistence Boost::program_options) - - if (TBB_FOUND) - target_link_libraries(distance_matrix_edge_collapse_rips_persistence ${TBB_LIBRARIES}) - endif() - add_test(NAME Edge_collapse_utilities_distance_matrix_rips_persistence COMMAND $ - "${CMAKE_SOURCE_DIR}/data/distance_matrix/tore3D_1307_distance_matrix.csv" "-r" "0.25" "-m" "0.5" "-d" "3" "-p" "3" "-o" "csv_results.pers") - - install(TARGETS distance_matrix_edge_collapse_rips_persistence DESTINATION bin) - - if (DIFF_PATH) - add_test(Edge_collapse_utilities_diff_persistence ${DIFF_PATH} - "off_results.pers" "csv_results.pers") - set_tests_properties(Edge_collapse_utilities_diff_persistence PROPERTIES DEPENDS - "Edge_collapse_utilities_point_cloud_rips_persistence;Edge_collapse_utilities_distance_matrix_rips_persistence") - + if (TARGET Boost::program_options) + # From a point cloud + add_executable ( point_cloud_edge_collapse_rips_persistence point_cloud_edge_collapse_rips_persistence.cpp ) + target_link_libraries(point_cloud_edge_collapse_rips_persistence Boost::program_options) + + if (TBB_FOUND) + target_link_libraries(point_cloud_edge_collapse_rips_persistence ${TBB_LIBRARIES}) + endif() + add_test(NAME Edge_collapse_utilities_point_cloud_rips_persistence COMMAND $ + "${CMAKE_SOURCE_DIR}/data/points/tore3D_1307.off" "-r" "0.25" "-m" "0.5" "-d" "3" "-p" "3" "-o" "off_results.pers") + + install(TARGETS point_cloud_edge_collapse_rips_persistence DESTINATION bin) + + # From a distance matrix + add_executable ( distance_matrix_edge_collapse_rips_persistence distance_matrix_edge_collapse_rips_persistence.cpp ) + target_link_libraries(distance_matrix_edge_collapse_rips_persistence Boost::program_options) + + if (TBB_FOUND) + target_link_libraries(distance_matrix_edge_collapse_rips_persistence ${TBB_LIBRARIES}) + endif() + add_test(NAME Edge_collapse_utilities_distance_matrix_rips_persistence COMMAND $ + "${CMAKE_SOURCE_DIR}/data/distance_matrix/tore3D_1307_distance_matrix.csv" "-r" "0.25" "-m" "0.5" "-d" "3" "-p" "3" "-o" "csv_results.pers") + + install(TARGETS distance_matrix_edge_collapse_rips_persistence DESTINATION bin) + + if (DIFF_PATH) + add_test(Edge_collapse_utilities_diff_persistence ${DIFF_PATH} + "off_results.pers" "csv_results.pers") + set_tests_properties(Edge_collapse_utilities_diff_persistence PROPERTIES DEPENDS + "Edge_collapse_utilities_point_cloud_rips_persistence;Edge_collapse_utilities_distance_matrix_rips_persistence") + endif() endif() endif() \ No newline at end of file diff --git a/src/Persistent_cohomology/benchmark/CMakeLists.txt b/src/Persistent_cohomology/benchmark/CMakeLists.txt index f38cc543..ad8dc84b 100644 --- a/src/Persistent_cohomology/benchmark/CMakeLists.txt +++ b/src/Persistent_cohomology/benchmark/CMakeLists.txt @@ -2,11 +2,13 @@ project(Persistent_cohomology_benchmark) if(GMP_FOUND) if(GMPXX_FOUND) - add_executable ( performance_rips_persistence EXCLUDE_FROM_ALL performance_rips_persistence.cpp ) - target_link_libraries(performance_rips_persistence Boost::program_options ${GMPXX_LIBRARIES} ${GMP_LIBRARIES}) - if (TBB_FOUND) - target_link_libraries(performance_rips_persistence ${TBB_LIBRARIES}) - endif(TBB_FOUND) - file(COPY "${CMAKE_SOURCE_DIR}/data/points/Kl.off" DESTINATION ${CMAKE_CURRENT_BINARY_DIR}/) + if (TARGET Boost::program_options) + add_executable ( performance_rips_persistence EXCLUDE_FROM_ALL performance_rips_persistence.cpp ) + target_link_libraries(performance_rips_persistence Boost::program_options ${GMPXX_LIBRARIES} ${GMP_LIBRARIES}) + if (TBB_FOUND) + target_link_libraries(performance_rips_persistence ${TBB_LIBRARIES}) + endif(TBB_FOUND) + file(COPY "${CMAKE_SOURCE_DIR}/data/points/Kl.off" DESTINATION ${CMAKE_CURRENT_BINARY_DIR}/) + endif() endif(GMPXX_FOUND) endif(GMP_FOUND) diff --git a/src/Persistent_cohomology/example/CMakeLists.txt b/src/Persistent_cohomology/example/CMakeLists.txt index 4c08cd68..d6a92ed6 100644 --- a/src/Persistent_cohomology/example/CMakeLists.txt +++ b/src/Persistent_cohomology/example/CMakeLists.txt @@ -1,46 +1,58 @@ project(Persistent_cohomology_examples) add_executable(plain_homology plain_homology.cpp) +if (TBB_FOUND) + target_link_libraries(plain_homology ${TBB_LIBRARIES}) +endif() +add_test(NAME Persistent_cohomology_example_plain_homology COMMAND $) +install(TARGETS plain_homology DESTINATION bin) add_executable(persistence_from_simple_simplex_tree persistence_from_simple_simplex_tree.cpp) - -add_executable(rips_persistence_step_by_step rips_persistence_step_by_step.cpp) -target_link_libraries(rips_persistence_step_by_step Boost::program_options) - -add_executable(rips_persistence_via_boundary_matrix rips_persistence_via_boundary_matrix.cpp) -target_link_libraries(rips_persistence_via_boundary_matrix Boost::program_options) - -add_executable(persistence_from_file persistence_from_file.cpp) -target_link_libraries(persistence_from_file Boost::program_options) - if (TBB_FOUND) - target_link_libraries(plain_homology ${TBB_LIBRARIES}) target_link_libraries(persistence_from_simple_simplex_tree ${TBB_LIBRARIES}) - target_link_libraries(rips_persistence_step_by_step ${TBB_LIBRARIES}) - target_link_libraries(rips_persistence_via_boundary_matrix ${TBB_LIBRARIES}) - target_link_libraries(persistence_from_file ${TBB_LIBRARIES}) endif() - -add_test(NAME Persistent_cohomology_example_plain_homology COMMAND $) add_test(NAME Persistent_cohomology_example_from_simple_simplex_tree COMMAND $ "1" "0") -add_test(NAME Persistent_cohomology_example_from_rips_step_by_step_on_tore_3D COMMAND $ - "${CMAKE_SOURCE_DIR}/data/points/tore3D_1307.off" "-r" "0.25" "-m" "0.5" "-d" "3" "-p" "3") -add_test(NAME Persistent_cohomology_example_via_boundary_matrix COMMAND $ - "${CMAKE_SOURCE_DIR}/data/points/Kl.off" "-r" "0.16" "-d" "3" "-p" "3" "-m" "100") -add_test(NAME Persistent_cohomology_example_from_file_3_2_0 COMMAND $ - "${CMAKE_SOURCE_DIR}/data/filtered_simplicial_complex/bunny_5000_complex.fsc" "-p" "2" "-m" "0") -add_test(NAME Persistent_cohomology_example_from_file_3_3_100 COMMAND $ - "${CMAKE_SOURCE_DIR}/data/filtered_simplicial_complex/bunny_5000_complex.fsc" "-p" "3" "-m" "100") - -install(TARGETS plain_homology DESTINATION bin) install(TARGETS persistence_from_simple_simplex_tree DESTINATION bin) -install(TARGETS rips_persistence_step_by_step DESTINATION bin) -install(TARGETS rips_persistence_via_boundary_matrix DESTINATION bin) -install(TARGETS persistence_from_file DESTINATION bin) + +if(TARGET Boost::program_options) + add_executable(rips_persistence_step_by_step rips_persistence_step_by_step.cpp) + target_link_libraries(rips_persistence_step_by_step Boost::program_options) + if (TBB_FOUND) + target_link_libraries(rips_persistence_step_by_step ${TBB_LIBRARIES}) + endif() + add_test(NAME Persistent_cohomology_example_from_rips_step_by_step_on_tore_3D COMMAND $ + "${CMAKE_SOURCE_DIR}/data/points/tore3D_1307.off" "-r" "0.25" "-m" "0.5" "-d" "3" "-p" "3") + install(TARGETS rips_persistence_step_by_step DESTINATION bin) +endif() + +if(TARGET Boost::program_options) + add_executable(rips_persistence_via_boundary_matrix rips_persistence_via_boundary_matrix.cpp) + target_link_libraries(rips_persistence_via_boundary_matrix Boost::program_options) + if (TBB_FOUND) + target_link_libraries(rips_persistence_via_boundary_matrix ${TBB_LIBRARIES}) + endif() + add_test(NAME Persistent_cohomology_example_via_boundary_matrix COMMAND $ + "${CMAKE_SOURCE_DIR}/data/points/Kl.off" "-r" "0.16" "-d" "3" "-p" "3" "-m" "100") + install(TARGETS rips_persistence_via_boundary_matrix DESTINATION bin) +endif() + +if(TARGET Boost::program_options) + add_executable(persistence_from_file persistence_from_file.cpp) + target_link_libraries(persistence_from_file Boost::program_options) + if (TBB_FOUND) + target_link_libraries(persistence_from_file ${TBB_LIBRARIES}) + endif() + add_test(NAME Persistent_cohomology_example_from_file_3_2_0 COMMAND $ + "${CMAKE_SOURCE_DIR}/data/filtered_simplicial_complex/bunny_5000_complex.fsc" "-p" "2" "-m" "0") + add_test(NAME Persistent_cohomology_example_from_file_3_3_100 COMMAND $ + "${CMAKE_SOURCE_DIR}/data/filtered_simplicial_complex/bunny_5000_complex.fsc" "-p" "3" "-m" "100") + install(TARGETS persistence_from_file DESTINATION bin) +endif() if(GMP_FOUND) - if(GMPXX_FOUND) + if(GMPXX_FOUND) + if(TARGET Boost::program_options) add_executable(rips_multifield_persistence rips_multifield_persistence.cpp ) target_link_libraries(rips_multifield_persistence Boost::program_options ${GMPXX_LIBRARIES} ${GMP_LIBRARIES}) @@ -50,19 +62,16 @@ if(GMP_FOUND) add_test(NAME Persistent_cohomology_example_multifield_2_71 COMMAND $ "${CMAKE_SOURCE_DIR}/data/points/tore3D_1307.off" "-r" "0.25" "-m" "0.5" "-d" "3" "-p" "2" "-q" "71") install(TARGETS rips_multifield_persistence DESTINATION bin) - endif(GMPXX_FOUND) + endif() + endif(GMPXX_FOUND) endif(GMP_FOUND) if (NOT CGAL_WITH_EIGEN3_VERSION VERSION_LESS 4.11.0) - add_executable(custom_persistence_sort custom_persistence_sort.cpp) target_link_libraries(custom_persistence_sort ${CGAL_LIBRARY}) - if (TBB_FOUND) target_link_libraries(custom_persistence_sort ${TBB_LIBRARIES}) endif(TBB_FOUND) add_test(NAME Persistent_cohomology_example_custom_persistence_sort COMMAND $) - install(TARGETS custom_persistence_sort DESTINATION bin) - endif (NOT CGAL_WITH_EIGEN3_VERSION VERSION_LESS 4.11.0) diff --git a/src/Rips_complex/utilities/CMakeLists.txt b/src/Rips_complex/utilities/CMakeLists.txt index d2448d7b..2081f142 100644 --- a/src/Rips_complex/utilities/CMakeLists.txt +++ b/src/Rips_complex/utilities/CMakeLists.txt @@ -1,34 +1,45 @@ project(Rips_complex_utilities) -add_executable(rips_distance_matrix_persistence rips_distance_matrix_persistence.cpp) -target_link_libraries(rips_distance_matrix_persistence Boost::program_options) - -add_executable(rips_persistence rips_persistence.cpp) -target_link_libraries(rips_persistence Boost::program_options) - -add_executable(rips_correlation_matrix_persistence rips_correlation_matrix_persistence.cpp) -target_link_libraries(rips_correlation_matrix_persistence Boost::system Boost::program_options) - -add_executable(sparse_rips_persistence sparse_rips_persistence.cpp) -target_link_libraries(sparse_rips_persistence Boost::program_options) +if(TARGET Boost::program_options) + add_executable(rips_distance_matrix_persistence rips_distance_matrix_persistence.cpp) + target_link_libraries(rips_distance_matrix_persistence Boost::program_options) + if (TBB_FOUND) + target_link_libraries(rips_distance_matrix_persistence ${TBB_LIBRARIES}) + endif() + add_test(NAME Rips_complex_utility_from_rips_distance_matrix COMMAND $ + "${CMAKE_SOURCE_DIR}/data/distance_matrix/full_square_distance_matrix.csv" "-r" "1.0" "-d" "3" "-p" "3" "-m" "0") + install(TARGETS rips_distance_matrix_persistence DESTINATION bin) +endif() -if (TBB_FOUND) - target_link_libraries(rips_distance_matrix_persistence ${TBB_LIBRARIES}) - target_link_libraries(rips_persistence ${TBB_LIBRARIES}) - target_link_libraries(rips_correlation_matrix_persistence ${TBB_LIBRARIES}) - target_link_libraries(sparse_rips_persistence ${TBB_LIBRARIES}) +if(TARGET Boost::program_options) + add_executable(rips_persistence rips_persistence.cpp) + target_link_libraries(rips_persistence Boost::program_options) + if (TBB_FOUND) + target_link_libraries(rips_persistence ${TBB_LIBRARIES}) + endif() + add_test(NAME Rips_complex_utility_from_rips_on_tore_3D COMMAND $ + "${CMAKE_SOURCE_DIR}/data/points/tore3D_1307.off" "-r" "0.25" "-m" "0.5" "-d" "3" "-p" "3") + install(TARGETS rips_persistence DESTINATION bin) endif() -add_test(NAME Rips_complex_utility_from_rips_distance_matrix COMMAND $ - "${CMAKE_SOURCE_DIR}/data/distance_matrix/full_square_distance_matrix.csv" "-r" "1.0" "-d" "3" "-p" "3" "-m" "0") -add_test(NAME Rips_complex_utility_from_rips_on_tore_3D COMMAND $ - "${CMAKE_SOURCE_DIR}/data/points/tore3D_1307.off" "-r" "0.25" "-m" "0.5" "-d" "3" "-p" "3") -add_test(NAME Rips_complex_utility_from_rips_correlation_matrix COMMAND $ - "${CMAKE_SOURCE_DIR}/data/correlation_matrix/lower_triangular_correlation_matrix.csv" "-c" "0.3" "-d" "3" "-p" "3" "-m" "0") -add_test(NAME Sparse_rips_complex_utility_on_tore_3D COMMAND $ - "${CMAKE_SOURCE_DIR}/data/points/tore3D_300.off" "-e" "0.5" "-m" "0.2" "-d" "3" "-p" "2") +if(TARGET Boost::program_options) + add_executable(rips_correlation_matrix_persistence rips_correlation_matrix_persistence.cpp) + target_link_libraries(rips_correlation_matrix_persistence Boost::system Boost::program_options) + if (TBB_FOUND) + target_link_libraries(rips_correlation_matrix_persistence ${TBB_LIBRARIES}) + endif() + add_test(NAME Rips_complex_utility_from_rips_correlation_matrix COMMAND $ + "${CMAKE_SOURCE_DIR}/data/correlation_matrix/lower_triangular_correlation_matrix.csv" "-c" "0.3" "-d" "3" "-p" "3" "-m" "0") + install(TARGETS rips_correlation_matrix_persistence DESTINATION bin) +endif() -install(TARGETS rips_distance_matrix_persistence DESTINATION bin) -install(TARGETS rips_persistence DESTINATION bin) -install(TARGETS rips_correlation_matrix_persistence DESTINATION bin) -install(TARGETS sparse_rips_persistence DESTINATION bin) +if(TARGET Boost::program_options) + add_executable(sparse_rips_persistence sparse_rips_persistence.cpp) + target_link_libraries(sparse_rips_persistence Boost::program_options) + if (TBB_FOUND) + target_link_libraries(sparse_rips_persistence ${TBB_LIBRARIES}) + endif() + add_test(NAME Sparse_rips_complex_utility_on_tore_3D COMMAND $ + "${CMAKE_SOURCE_DIR}/data/points/tore3D_300.off" "-e" "0.5" "-m" "0.2" "-d" "3" "-p" "2") + install(TARGETS sparse_rips_persistence DESTINATION bin) +endif() diff --git a/src/Simplex_tree/example/CMakeLists.txt b/src/Simplex_tree/example/CMakeLists.txt index a0aabee2..73b2c6f9 100644 --- a/src/Simplex_tree/example/CMakeLists.txt +++ b/src/Simplex_tree/example/CMakeLists.txt @@ -34,13 +34,15 @@ if(GMP_FOUND AND NOT CGAL_VERSION VERSION_LESS 4.11.0) endif() if (NOT CGAL_WITH_EIGEN3_VERSION VERSION_LESS 4.11.0) - add_executable ( Simplex_tree_example_cech_complex_cgal_mini_sphere_3d cech_complex_cgal_mini_sphere_3d.cpp ) - target_link_libraries(Simplex_tree_example_cech_complex_cgal_mini_sphere_3d Boost::program_options ${CGAL_LIBRARY}) - if (TBB_FOUND) - target_link_libraries(Simplex_tree_example_cech_complex_cgal_mini_sphere_3d ${TBB_LIBRARIES}) + if(TARGET Boost::program_options) + add_executable ( Simplex_tree_example_cech_complex_cgal_mini_sphere_3d cech_complex_cgal_mini_sphere_3d.cpp ) + target_link_libraries(Simplex_tree_example_cech_complex_cgal_mini_sphere_3d Boost::program_options ${CGAL_LIBRARY}) + if (TBB_FOUND) + target_link_libraries(Simplex_tree_example_cech_complex_cgal_mini_sphere_3d ${TBB_LIBRARIES}) + endif() + add_test(NAME Simplex_tree_example_cech_complex_cgal_mini_sphere_3d COMMAND $ + "${CMAKE_SOURCE_DIR}/data/points/tore3D_300.off" -r 0.3 -d 3) endif() - add_test(NAME Simplex_tree_example_cech_complex_cgal_mini_sphere_3d COMMAND $ - "${CMAKE_SOURCE_DIR}/data/points/tore3D_300.off" -r 0.3 -d 3) endif () add_executable ( Simplex_tree_example_graph_expansion_with_blocker graph_expansion_with_blocker.cpp ) diff --git a/src/Witness_complex/utilities/CMakeLists.txt b/src/Witness_complex/utilities/CMakeLists.txt index d986d2d1..60fea0b4 100644 --- a/src/Witness_complex/utilities/CMakeLists.txt +++ b/src/Witness_complex/utilities/CMakeLists.txt @@ -2,26 +2,26 @@ project(Witness_complex_utilities) # 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_strong_witness_persistence strong_witness_persistence.cpp ) - target_link_libraries(Witness_complex_strong_witness_persistence Boost::program_options) + if(TARGET Boost::program_options) + add_executable ( Witness_complex_strong_witness_persistence strong_witness_persistence.cpp ) + target_link_libraries(Witness_complex_strong_witness_persistence Boost::program_options) - add_executable ( Witness_complex_weak_witness_persistence weak_witness_persistence.cpp ) - target_link_libraries(Witness_complex_weak_witness_persistence Boost::program_options) + add_executable ( Witness_complex_weak_witness_persistence weak_witness_persistence.cpp ) + target_link_libraries(Witness_complex_weak_witness_persistence Boost::program_options) - if (TBB_FOUND) - target_link_libraries(Witness_complex_strong_witness_persistence ${TBB_LIBRARIES}) - target_link_libraries(Witness_complex_weak_witness_persistence ${TBB_LIBRARIES}) - endif() - - add_test(NAME Witness_complex_strong_test_torus_persistence - COMMAND $ - "${CMAKE_SOURCE_DIR}/data/points/tore3D_1307.off" "-l" "20" "-a" "0.5") - add_test(NAME Witness_complex_weak_test_torus_persistence - COMMAND $ - "${CMAKE_SOURCE_DIR}/data/points/tore3D_1307.off" "-l" "20" "-a" "0.5") + if (TBB_FOUND) + target_link_libraries(Witness_complex_strong_witness_persistence ${TBB_LIBRARIES}) + target_link_libraries(Witness_complex_weak_witness_persistence ${TBB_LIBRARIES}) + endif() - install(TARGETS Witness_complex_strong_witness_persistence DESTINATION bin) - install(TARGETS Witness_complex_weak_witness_persistence DESTINATION bin) + add_test(NAME Witness_complex_strong_test_torus_persistence + COMMAND $ + "${CMAKE_SOURCE_DIR}/data/points/tore3D_1307.off" "-l" "20" "-a" "0.5") + add_test(NAME Witness_complex_weak_test_torus_persistence + COMMAND $ + "${CMAKE_SOURCE_DIR}/data/points/tore3D_1307.off" "-l" "20" "-a" "0.5") + install(TARGETS Witness_complex_strong_witness_persistence DESTINATION bin) + install(TARGETS Witness_complex_weak_witness_persistence DESTINATION bin) + endif() endif(NOT CGAL_WITH_EIGEN3_VERSION VERSION_LESS 4.11.0) diff --git a/src/cmake/modules/GUDHI_modules.cmake b/src/cmake/modules/GUDHI_modules.cmake index aab1dd08..ccaf1ac5 100644 --- a/src/cmake/modules/GUDHI_modules.cmake +++ b/src/cmake/modules/GUDHI_modules.cmake @@ -30,7 +30,12 @@ if (WITH_GUDHI_EXAMPLE) set(GUDHI_SUB_DIRECTORIES "${GUDHI_SUB_DIRECTORIES};example") endif() if (WITH_GUDHI_TEST) - set(GUDHI_SUB_DIRECTORIES "${GUDHI_SUB_DIRECTORIES};test") + # All tests are using boost tests + if(TARGET Boost::unit_test_framework) + set(GUDHI_SUB_DIRECTORIES "${GUDHI_SUB_DIRECTORIES};test") + else() + message("++ WITH_GUDHI_TEST but no TARGET Boost::unit_test_framework") + endif() endif() if (WITH_GUDHI_UTILITIES) set(GUDHI_SUB_DIRECTORIES "${GUDHI_SUB_DIRECTORIES};utilities") diff --git a/src/cmake/modules/GUDHI_third_party_libraries.cmake b/src/cmake/modules/GUDHI_third_party_libraries.cmake index a56a2756..489f3de5 100644 --- a/src/cmake/modules/GUDHI_third_party_libraries.cmake +++ b/src/cmake/modules/GUDHI_third_party_libraries.cmake @@ -1,42 +1,11 @@ # This files manage third party libraries required by GUDHI -find_package(Boost 1.56.0 REQUIRED COMPONENTS system filesystem unit_test_framework program_options thread) +find_package(Boost 1.56.0 QUIET OPTIONAL_COMPONENTS system thread filesystem unit_test_framework program_options) -if(NOT Boost_FOUND) +# Boost_FOUND is not reliable +if(NOT Boost_VERSION) message(FATAL_ERROR "NOTICE: This program requires Boost and will not be compiled.") -endif(NOT Boost_FOUND) - -# cf. https://cliutils.gitlab.io/modern-cmake/chapters/packages/Boost.html -# This is needed if your Boost version is newer than your CMake version -# or if you have an old version of CMake (<3.5) -if(NOT TARGET Boost::program_options) - add_library(Boost::program_options IMPORTED INTERFACE) - set_property(TARGET Boost::program_options PROPERTY - INTERFACE_INCLUDE_DIRECTORIES ${Boost_INCLUDE_DIR}) - set_property(TARGET Boost::program_options PROPERTY - INTERFACE_LINK_LIBRARIES ${Boost_LIBRARIES}) -endif() -if(NOT TARGET Boost::filesystem) - add_library(Boost::filesystem IMPORTED INTERFACE) - set_property(TARGET Boost::filesystem PROPERTY - INTERFACE_INCLUDE_DIRECTORIES ${Boost_INCLUDE_DIR}) - set_property(TARGET Boost::filesystem PROPERTY - INTERFACE_LINK_LIBRARIES ${Boost_LIBRARIES}) -endif() -if(NOT TARGET Boost::unit_test_framework) - add_library(Boost::unit_test_framework IMPORTED INTERFACE) - set_property(TARGET Boost::unit_test_framework PROPERTY - INTERFACE_INCLUDE_DIRECTORIES ${Boost_INCLUDE_DIR}) - set_property(TARGET Boost::unit_test_framework PROPERTY - INTERFACE_LINK_LIBRARIES ${Boost_LIBRARIES}) -endif() -if(NOT TARGET Boost::system) - add_library(Boost::system IMPORTED INTERFACE) - set_property(TARGET Boost::system PROPERTY - INTERFACE_INCLUDE_DIRECTORIES ${Boost_INCLUDE_DIR}) - set_property(TARGET Boost::system PROPERTY - INTERFACE_LINK_LIBRARIES ${Boost_LIBRARIES}) -endif() +endif(NOT Boost_VERSION) find_package(GMP) if(GMP_FOUND) diff --git a/src/common/doc/installation.h b/src/common/doc/installation.h index 6af645e2..9df1c2f0 100644 --- a/src/common/doc/installation.h +++ b/src/common/doc/installation.h @@ -6,7 +6,7 @@ * * \section compiling Compiling * The library uses c++14 and requires Boost ≥ 1.56.0 - * and CMake ≥ 3.1. + * and CMake ≥ 3.5. * It is a multi-platform library and compiles on Linux, Mac OSX and Visual Studio 2015. * * \subsection utilities Utilities and examples @@ -17,8 +17,8 @@ cd build/ cmake -DCMAKE_BUILD_TYPE=Release .. make \endverbatim * By default, examples are disabled. You can activate their compilation with - * ccmake (on Linux and Mac OSX), - * cmake-gui (on Windows) or by modifying the + * ccmake (on Linux and Mac OSX), + * cmake-gui (on Windows) or by modifying the * cmake command as follows : \verbatim cmake -DCMAKE_BUILD_TYPE=Release -DWITH_GUDHI_EXAMPLE=ON .. make \endverbatim @@ -28,7 +28,7 @@ make \endverbatim * To install the library (headers and activated utilities), run the following command in a terminal: * \verbatim make install \endverbatim * This action may require to be in the sudoer or administrator of the machine in function of the operating system and - * of CMAKE_INSTALL_PREFIX. + * of CMAKE_INSTALL_PREFIX. * * \subsection testsuites Test suites * To test your build, run the following command in a terminal: diff --git a/src/python/doc/installation.rst b/src/python/doc/installation.rst index 4cc31d5c..2f161d66 100644 --- a/src/python/doc/installation.rst +++ b/src/python/doc/installation.rst @@ -40,7 +40,7 @@ different, and in particular the `python/` subdirectory is actually `src/python/ there. The library uses c++14 and requires `Boost `_ :math:`\geq` 1.56.0, -`CMake `_ :math:`\geq` 3.1 to generate makefiles, +`CMake `_ :math:`\geq` 3.5 to generate makefiles, `NumPy `_, `Cython `_ and `pybind11 `_ to compile the GUDHI Python module. -- cgit v1.2.3 From e213f44cdf0b2e2cfa854789c5f14cbb5cb4ec96 Mon Sep 17 00:00:00 2001 From: ROUVREAU Vincent Date: Tue, 8 Sep 2020 17:51:26 +0200 Subject: Remove boost::system --- src/Rips_complex/utilities/CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Rips_complex/utilities/CMakeLists.txt b/src/Rips_complex/utilities/CMakeLists.txt index 2081f142..d8c8e0b8 100644 --- a/src/Rips_complex/utilities/CMakeLists.txt +++ b/src/Rips_complex/utilities/CMakeLists.txt @@ -24,7 +24,7 @@ endif() if(TARGET Boost::program_options) add_executable(rips_correlation_matrix_persistence rips_correlation_matrix_persistence.cpp) - target_link_libraries(rips_correlation_matrix_persistence Boost::system Boost::program_options) + target_link_libraries(rips_correlation_matrix_persistence Boost::program_options) if (TBB_FOUND) target_link_libraries(rips_correlation_matrix_persistence ${TBB_LIBRARIES}) endif() -- cgit v1.2.3 From c09f54487cc88eeb3afe1629ff8a3edc223df1eb Mon Sep 17 00:00:00 2001 From: ROUVREAU Vincent Date: Wed, 9 Sep 2020 11:17:02 +0200 Subject: Even if CGAL was requiring boost::thread no need to find it for gudhi. boost::thread removed from cgal on https://github.com/CGAL/cgal/commit/8a7d3fa --- src/cmake/modules/GUDHI_third_party_libraries.cmake | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/cmake/modules/GUDHI_third_party_libraries.cmake b/src/cmake/modules/GUDHI_third_party_libraries.cmake index 489f3de5..1fbc4244 100644 --- a/src/cmake/modules/GUDHI_third_party_libraries.cmake +++ b/src/cmake/modules/GUDHI_third_party_libraries.cmake @@ -1,6 +1,6 @@ # This files manage third party libraries required by GUDHI -find_package(Boost 1.56.0 QUIET OPTIONAL_COMPONENTS system thread filesystem unit_test_framework program_options) +find_package(Boost 1.56.0 QUIET OPTIONAL_COMPONENTS filesystem unit_test_framework program_options) # Boost_FOUND is not reliable if(NOT Boost_VERSION) -- cgit v1.2.3 From 58d79c972198938c6f3655a40540903e08242b36 Mon Sep 17 00:00:00 2001 From: ROUVREAU Vincent Date: Wed, 9 Sep 2020 17:37:01 +0200 Subject: Use cgal 5.1 as only boost header only --- Dockerfile_for_pip | 21 +++++++++++---------- 1 file changed, 11 insertions(+), 10 deletions(-) diff --git a/Dockerfile_for_pip b/Dockerfile_for_pip index 8f60e37c..98668a04 100644 --- a/Dockerfile_for_pip +++ b/Dockerfile_for_pip @@ -14,23 +14,24 @@ RUN mkdir -p /opt/cmake \ && sh cmake-3.16.2-Linux-x86_64.sh --skip-license --prefix=/opt/cmake \ && rm -f cmake-3.16.2-Linux-x86_64.sh -RUN git clone -b boost-1.73.0 --depth 1 https://github.com/boostorg/boost.git \ - && cd boost \ - && git submodule update --init \ - && ./bootstrap.sh --with-libraries=filesystem,program_options,system,thread,test \ - && ./b2 headers \ - && ./b2 install \ +# yum install boost-devel installs boost 1.53 and copy is the only way to install headers only boost +RUN wget https://dl.bintray.com/boostorg/release/1.73.0/source/boost_1_73_0.tar.gz \ + && tar xf boost_1_73_0.tar.gz \ + && cd boost_1_73_0 \ + && ./bootstrap.sh \ + && ls \ + && cp -r boost /usr/local/include/ \ && cd .. \ && rm -rf boost -RUN wget https://github.com/CGAL/cgal/releases/download/releases%2FCGAL-5.0.2/CGAL-5.0.2.tar.xz \ - && tar xf CGAL-5.0.2.tar.xz \ +RUN wget https://github.com/CGAL/cgal/releases/download/v5.1/CGAL-5.1.tar.xz \ + && tar xf CGAL-5.1.tar.xz \ && mkdir build \ && cd build \ - && /opt/cmake/bin/cmake -DCMAKE_BUILD_TYPE=Release ../CGAL-5.0.2/ \ + && /opt/cmake/bin/cmake -DCMAKE_BUILD_TYPE=Release ../CGAL-5.1/ \ && make install \ && cd .. \ - && rm -rf build CGAL-5.0.2 + && rm -rf build CGAL-5.1 ADD .github/build-requirements.txt / -- cgit v1.2.3 From e64dd4039e6dff35322ff01a8aa82d79c77e9c8e Mon Sep 17 00:00:00 2001 From: ROUVREAU Vincent Date: Mon, 28 Sep 2020 09:44:43 +0200 Subject: doc review: improve reset_filtration documentation --- src/Simplex_tree/include/gudhi/Simplex_tree.h | 4 ++-- src/python/gudhi/simplex_tree.pyx | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/Simplex_tree/include/gudhi/Simplex_tree.h b/src/Simplex_tree/include/gudhi/Simplex_tree.h index 70ef4c66..5afd0e23 100644 --- a/src/Simplex_tree/include/gudhi/Simplex_tree.h +++ b/src/Simplex_tree/include/gudhi/Simplex_tree.h @@ -1668,8 +1668,8 @@ class Simplex_tree { } public: - /** \brief This function resets filtration value from a given dimension. Resets all the Simplex_tree when - * `min_dim = 0`. + /** \brief This function resets the filtration value of all the simplices of dimension at least min_dim. Resets all + * the Simplex_tree when `min_dim = 0`. * `reset_filtration` may break the filtration property with `min_dim > 0`, and it is the user's responsibility to * make it a valid filtration (using a large enough `filt_value`, or calling `make_filtration_non_decreasing` * afterwards for instance). diff --git a/src/python/gudhi/simplex_tree.pyx b/src/python/gudhi/simplex_tree.pyx index f28990cc..910711a9 100644 --- a/src/python/gudhi/simplex_tree.pyx +++ b/src/python/gudhi/simplex_tree.pyx @@ -359,8 +359,8 @@ cdef class SimplexTree: return self.get_ptr().make_filtration_non_decreasing() def reset_filtration(self, filtration, min_dim = 0): - """This function resets filtration value from a given dimension. Resets all the simplex tree when - `min_dim = 0`. + """This function resets the filtration value of all the simplices of dimension at least min_dim. Resets all the + simplex tree when `min_dim = 0`. `reset_filtration` may break the filtration property with `min_dim > 0`, and it is the user's responsibility to make it a valid filtration (using a large enough `filt_value`, or calling `make_filtration_non_decreasing` afterwards for instance). -- cgit v1.2.3 From 0c843fd01f0cd1ccff92c8ed40e989b3fbf8f1e9 Mon Sep 17 00:00:00 2001 From: ROUVREAU Vincent Date: Mon, 28 Sep 2020 09:56:44 +0200 Subject: code review: Simplify recursivity --- src/Simplex_tree/include/gudhi/Simplex_tree.h | 9 +-------- 1 file changed, 1 insertion(+), 8 deletions(-) diff --git a/src/Simplex_tree/include/gudhi/Simplex_tree.h b/src/Simplex_tree/include/gudhi/Simplex_tree.h index 5afd0e23..85d6c3b0 100644 --- a/src/Simplex_tree/include/gudhi/Simplex_tree.h +++ b/src/Simplex_tree/include/gudhi/Simplex_tree.h @@ -1677,14 +1677,7 @@ class Simplex_tree { * @param[in] min_dim The minimal dimension. Default value is 0. */ void reset_filtration(Filtration_value filt_value, int min_dim = 0) { - for (auto& simplex : root_.members()) { - if (min_dim <= 0) { - simplex.second.assign_filtration(filt_value); - } - if (has_children(&simplex)) { - rec_reset_filtration(simplex.second.children(), filt_value, min_dim - 1); - } - } + rec_reset_filtration(&root_, filt_value, min_dim); clear_filtration(); // Drop the cache. } -- cgit v1.2.3 From e7b7947adf13ec1dcb8c126a4373fa29baaecb63 Mon Sep 17 00:00:00 2001 From: ROUVREAU Vincent Date: Tue, 29 Sep 2020 13:23:56 +0200 Subject: Added tests for wasserstein distance with tensorflow --- .../modules/GUDHI_third_party_libraries.cmake | 1 + src/python/CMakeLists.txt | 8 +++++++ src/python/doc/installation.rst | 5 +++++ src/python/test/test_wasserstein_with_tensors.py | 25 ++++++++++++++++++++++ 4 files changed, 39 insertions(+) create mode 100755 src/python/test/test_wasserstein_with_tensors.py diff --git a/src/cmake/modules/GUDHI_third_party_libraries.cmake b/src/cmake/modules/GUDHI_third_party_libraries.cmake index 1fbc4244..9dadac4f 100644 --- a/src/cmake/modules/GUDHI_third_party_libraries.cmake +++ b/src/cmake/modules/GUDHI_third_party_libraries.cmake @@ -155,6 +155,7 @@ if( PYTHONINTERP_FOUND ) find_python_module("pykeops") find_python_module("eagerpy") find_python_module_no_version("hnswlib") + find_python_module("tensorflow") endif() if(NOT GUDHI_PYTHON_PATH) diff --git a/src/python/CMakeLists.txt b/src/python/CMakeLists.txt index 4f26481e..cc71503f 100644 --- a/src/python/CMakeLists.txt +++ b/src/python/CMakeLists.txt @@ -103,6 +103,9 @@ if(PYTHONINTERP_FOUND) if(EAGERPY_FOUND) add_gudhi_debug_info("EagerPy version ${EAGERPY_VERSION}") endif() + if(TENSORFLOW_FOUND) + add_gudhi_debug_info("TensorFlow version ${TENSORFLOW_VERSION}") + endif() set(GUDHI_PYTHON_EXTRA_COMPILE_ARGS "${GUDHI_PYTHON_EXTRA_COMPILE_ARGS}'-DBOOST_RESULT_OF_USE_DECLTYPE', ") set(GUDHI_PYTHON_EXTRA_COMPILE_ARGS "${GUDHI_PYTHON_EXTRA_COMPILE_ARGS}'-DBOOST_ALL_NO_LIB', ") @@ -501,6 +504,11 @@ if(PYTHONINTERP_FOUND) endif() add_gudhi_py_test(test_wasserstein_barycenter) endif() + if(OT_FOUND) + if(TENSORFLOW_FOUND AND EAGERPY_FOUND) + add_gudhi_py_test(test_wasserstein_with_tensors) + endif() + endif() # Representations if(SKLEARN_FOUND AND MATPLOTLIB_FOUND) diff --git a/src/python/doc/installation.rst b/src/python/doc/installation.rst index 2f161d66..66efe45a 100644 --- a/src/python/doc/installation.rst +++ b/src/python/doc/installation.rst @@ -394,6 +394,11 @@ mathematics, science, and engineering. :class:`~gudhi.point_cloud.knn.KNearestNeighbors` can use the Python package `SciPy `_ as a backend if explicitly requested. +TensorFlow +---------- + +`TensorFlow `_ is currently only used in some automatic differentiation tests. + Bug reports and contributions ***************************** diff --git a/src/python/test/test_wasserstein_with_tensors.py b/src/python/test/test_wasserstein_with_tensors.py new file mode 100755 index 00000000..8957705d --- /dev/null +++ b/src/python/test/test_wasserstein_with_tensors.py @@ -0,0 +1,25 @@ +""" 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): Mathieu Carriere + + Copyright (C) 2020 Inria + + Modification(s): + - YYYY/MM Author: Description of the modification +""" + +from gudhi.wasserstein import wasserstein_distance as pot +import numpy as np + +def test_wasserstein_distance_grad_tensorflow(): + import tensorflow as tf + + with tf.GradientTape() as tape: + diag4 = tf.convert_to_tensor(tf.Variable(initial_value=np.array([[0., 10.]]), trainable=True)) + diag5 = tf.convert_to_tensor(tf.Variable(initial_value=np.array([[1., 11.], [3., 4.]]), trainable=True)) + dist45 = pot(diag4, diag5, internal_p=1, order=1, enable_autodiff=True) + assert dist45 == 3. + + grads = tape.gradient(dist45, [diag4, diag5]) + assert np.array_equal(grads[0].values, [[-1., -1.]]) + assert np.array_equal(grads[1].values, [[1., 1.], [-1., 1.]]) \ No newline at end of file -- cgit v1.2.3 From f0beb329f5a1767e4e0a0575ef3e078bf4563a44 Mon Sep 17 00:00:00 2001 From: ROUVREAU Vincent Date: Mon, 5 Oct 2020 11:12:44 +0200 Subject: code review: move test_wasserstein_distance_grad from test_wasserstein_distance.py to test_wasserstein_with_tensors.py --- src/python/CMakeLists.txt | 5 +++-- src/python/test/test_wasserstein_distance.py | 24 ---------------------- src/python/test/test_wasserstein_with_tensors.py | 26 ++++++++++++++++++++++-- 3 files changed, 27 insertions(+), 28 deletions(-) diff --git a/src/python/CMakeLists.txt b/src/python/CMakeLists.txt index cc71503f..c09996fe 100644 --- a/src/python/CMakeLists.txt +++ b/src/python/CMakeLists.txt @@ -499,13 +499,14 @@ if(PYTHONINTERP_FOUND) # Wasserstein if(OT_FOUND AND PYBIND11_FOUND) - if(TORCH_FOUND AND EAGERPY_FOUND) + # EagerPy dependency because of enable_autodiff=True + if(EAGERPY_FOUND) add_gudhi_py_test(test_wasserstein_distance) endif() add_gudhi_py_test(test_wasserstein_barycenter) endif() if(OT_FOUND) - if(TENSORFLOW_FOUND AND EAGERPY_FOUND) + if(TORCH_FOUND AND TENSORFLOW_FOUND AND EAGERPY_FOUND) add_gudhi_py_test(test_wasserstein_with_tensors) endif() endif() diff --git a/src/python/test/test_wasserstein_distance.py b/src/python/test/test_wasserstein_distance.py index 90d26809..e3b521d6 100755 --- a/src/python/test/test_wasserstein_distance.py +++ b/src/python/test/test_wasserstein_distance.py @@ -97,27 +97,3 @@ def test_wasserstein_distance_pot(): def test_wasserstein_distance_hera(): _basic_wasserstein(hera_wrap(delta=1e-12), 1e-12, test_matching=False) _basic_wasserstein(hera_wrap(delta=.1), .1, test_matching=False) - -def test_wasserstein_distance_grad(): - import torch - - diag1 = torch.tensor([[2.7, 3.7], [9.6, 14.0], [34.2, 34.974]], requires_grad=True) - diag2 = torch.tensor([[2.8, 4.45], [9.5, 14.1]], requires_grad=True) - diag3 = torch.tensor([[2.8, 4.45], [9.5, 14.1]], requires_grad=True) - assert diag1.grad is None and diag2.grad is None and diag3.grad is None - dist12 = pot(diag1, diag2, internal_p=2, order=2, enable_autodiff=True) - dist30 = pot(diag3, torch.tensor([]), internal_p=2, order=2, enable_autodiff=True) - dist12.backward() - dist30.backward() - assert not torch.isnan(diag1.grad).any() and not torch.isnan(diag2.grad).any() and not torch.isnan(diag3.grad).any() - diag4 = torch.tensor([[0., 10.]], requires_grad=True) - diag5 = torch.tensor([[1., 11.], [3., 4.]], requires_grad=True) - dist45 = pot(diag4, diag5, internal_p=1, order=1, enable_autodiff=True) - assert dist45 == 3. - dist45.backward() - assert np.array_equal(diag4.grad, [[-1., -1.]]) - assert np.array_equal(diag5.grad, [[1., 1.], [-1., 1.]]) - diag6 = torch.tensor([[5., 10.]], requires_grad=True) - pot(diag6, diag6, internal_p=2, order=2, enable_autodiff=True).backward() - # https://github.com/jonasrauber/eagerpy/issues/6 - # assert np.array_equal(diag6.grad, [[0., 0.]]) diff --git a/src/python/test/test_wasserstein_with_tensors.py b/src/python/test/test_wasserstein_with_tensors.py index 8957705d..e3f1411a 100755 --- a/src/python/test/test_wasserstein_with_tensors.py +++ b/src/python/test/test_wasserstein_with_tensors.py @@ -10,10 +10,32 @@ from gudhi.wasserstein import wasserstein_distance as pot import numpy as np +import torch +import tensorflow as tf -def test_wasserstein_distance_grad_tensorflow(): - import tensorflow as tf +def test_wasserstein_distance_grad(): + diag1 = torch.tensor([[2.7, 3.7], [9.6, 14.0], [34.2, 34.974]], requires_grad=True) + diag2 = torch.tensor([[2.8, 4.45], [9.5, 14.1]], requires_grad=True) + diag3 = torch.tensor([[2.8, 4.45], [9.5, 14.1]], requires_grad=True) + assert diag1.grad is None and diag2.grad is None and diag3.grad is None + dist12 = pot(diag1, diag2, internal_p=2, order=2, enable_autodiff=True) + dist30 = pot(diag3, torch.tensor([]), internal_p=2, order=2, enable_autodiff=True) + dist12.backward() + dist30.backward() + assert not torch.isnan(diag1.grad).any() and not torch.isnan(diag2.grad).any() and not torch.isnan(diag3.grad).any() + diag4 = torch.tensor([[0., 10.]], requires_grad=True) + diag5 = torch.tensor([[1., 11.], [3., 4.]], requires_grad=True) + dist45 = pot(diag4, diag5, internal_p=1, order=1, enable_autodiff=True) + assert dist45 == 3. + dist45.backward() + assert np.array_equal(diag4.grad, [[-1., -1.]]) + assert np.array_equal(diag5.grad, [[1., 1.], [-1., 1.]]) + diag6 = torch.tensor([[5., 10.]], requires_grad=True) + pot(diag6, diag6, internal_p=2, order=2, enable_autodiff=True).backward() + # https://github.com/jonasrauber/eagerpy/issues/6 + # assert np.array_equal(diag6.grad, [[0., 0.]]) +def test_wasserstein_distance_grad_tensorflow(): with tf.GradientTape() as tape: diag4 = tf.convert_to_tensor(tf.Variable(initial_value=np.array([[0., 10.]]), trainable=True)) diag5 = tf.convert_to_tensor(tf.Variable(initial_value=np.array([[1., 11.], [3., 4.]]), trainable=True)) -- cgit v1.2.3 From c66b9126429e1ff18f9ca69b27c5f357f071a697 Mon Sep 17 00:00:00 2001 From: Marc Glisse Date: Mon, 19 Oct 2020 01:05:04 +0200 Subject: Handle duplicated points --- src/Subsampling/include/gudhi/choose_n_farthest_points.h | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/Subsampling/include/gudhi/choose_n_farthest_points.h b/src/Subsampling/include/gudhi/choose_n_farthest_points.h index 66421a69..38c3a76b 100644 --- a/src/Subsampling/include/gudhi/choose_n_farthest_points.h +++ b/src/Subsampling/include/gudhi/choose_n_farthest_points.h @@ -111,6 +111,8 @@ void choose_n_farthest_points(Kernel const &k, curr_max_dist = dist_to_L[i]; curr_max_w = i; } + // If all that remains are duplicates of points already taken, stop. + if (curr_max_dist == 0) break; } } -- cgit v1.2.3 From dda7885005c343601c6630796eb56bdcf91a559f Mon Sep 17 00:00:00 2001 From: Marc Glisse Date: Thu, 22 Oct 2020 22:23:28 +0200 Subject: Document the change It would be possible to emit the duplicate points instead of stopping, but the current implementation makes that inconvenient. --- .../include/gudhi/choose_n_farthest_points.h | 3 ++- src/python/gudhi/subsampling.pyx | 21 +++++++++++---------- 2 files changed, 13 insertions(+), 11 deletions(-) diff --git a/src/Subsampling/include/gudhi/choose_n_farthest_points.h b/src/Subsampling/include/gudhi/choose_n_farthest_points.h index 38c3a76b..0e13fc5a 100644 --- a/src/Subsampling/include/gudhi/choose_n_farthest_points.h +++ b/src/Subsampling/include/gudhi/choose_n_farthest_points.h @@ -48,7 +48,8 @@ enum : std::size_t { * \tparam PointOutputIterator Output iterator whose value type is Kernel::Point_d. * \tparam DistanceOutputIterator Output iterator for distances. * \details It chooses `final_size` points from a random access range - * `input_pts` and outputs them in the output iterator `output_it`. It also + * `input_pts` (or the number of distinct points if `final_size` is larger) + * and outputs them in the output iterator `output_it`. It also * outputs the distance from each of those points to the set of previous * points in `dist_it`. * @param[in] k A kernel object. diff --git a/src/python/gudhi/subsampling.pyx b/src/python/gudhi/subsampling.pyx index f77c6f75..b11d07e5 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: Iterable[Iterable[float]]. + :type points: Iterable[Iterable[float]] Or @@ -42,14 +42,15 @@ def choose_n_farthest_points(points=None, off_file='', nb_points=0, starting_poi And in both cases - :param nb_points: Number of points of the subsample. - :type nb_points: unsigned. + :param nb_points: Number of points of the subsample (the subsample may be \ + smaller if there are fewer than nb_points distinct input points) + :type nb_points: int :param starting_point: The iteration starts with the landmark `starting \ - point`,which is the index of the point to start with. If not set, this \ + point`, which is the index of the point to start with. If not set, this \ index is chosen randomly. - :type starting_point: unsigned. + :type starting_point: int :returns: The subsample point set. - :rtype: List[List[float]]. + :rtype: List[List[float]] """ if off_file: if os.path.isfile(off_file): @@ -76,7 +77,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: Iterable[Iterable[float]]. + :type points: Iterable[Iterable[float]] Or @@ -86,7 +87,7 @@ def pick_n_random_points(points=None, off_file='', nb_points=0): And in both cases :param nb_points: Number of points of the subsample. - :type nb_points: unsigned. + :type nb_points: int :returns: The subsample point set. :rtype: List[List[float]] """ @@ -107,7 +108,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: Iterable[Iterable[float]]. + :type points: Iterable[Iterable[float]] Or @@ -118,7 +119,7 @@ def sparsify_point_set(points=None, off_file='', min_squared_dist=0.0): :param min_squared_dist: Minimum squared distance separating the output \ points. - :type min_squared_dist: float. + :type min_squared_dist: float :returns: The subsample point set. :rtype: List[List[float]] """ -- cgit v1.2.3 From 8aea376ed0b3c9066fb7e649f1cd66ffbed99a8d Mon Sep 17 00:00:00 2001 From: Marc Glisse Date: Thu, 22 Oct 2020 22:27:10 +0200 Subject: Simplify strange iterator use the syntax with [] is already used a few lines above --- src/Subsampling/include/gudhi/choose_n_farthest_points.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Subsampling/include/gudhi/choose_n_farthest_points.h b/src/Subsampling/include/gudhi/choose_n_farthest_points.h index 0e13fc5a..b70af8a0 100644 --- a/src/Subsampling/include/gudhi/choose_n_farthest_points.h +++ b/src/Subsampling/include/gudhi/choose_n_farthest_points.h @@ -100,7 +100,7 @@ void choose_n_farthest_points(Kernel const &k, *dist_it++ = dist_to_L[curr_max_w]; std::size_t i = 0; for (auto&& p : input_pts) { - double curr_dist = sqdist(p, *(std::begin(input_pts) + curr_max_w)); + double curr_dist = sqdist(p, input_pts[curr_max_w]); if (curr_dist < dist_to_L[i]) dist_to_L[i] = curr_dist; ++i; -- cgit v1.2.3 From 3ae0bc89f6ef853c1c52fc609bfe08097d3594db Mon Sep 17 00:00:00 2001 From: Marc Glisse Date: Thu, 22 Oct 2020 22:49:23 +0200 Subject: test with duplicated point --- src/Subsampling/test/test_choose_n_farthest_points.cpp | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/src/Subsampling/test/test_choose_n_farthest_points.cpp b/src/Subsampling/test/test_choose_n_farthest_points.cpp index 5c4bd4cb..08b82d61 100644 --- a/src/Subsampling/test/test_choose_n_farthest_points.cpp +++ b/src/Subsampling/test/test_choose_n_farthest_points.cpp @@ -93,7 +93,15 @@ BOOST_AUTO_TEST_CASE_TEMPLATE(test_choose_farthest_point_limits, Kernel, list_of std::vector point2({1.0, 0.0, 0.0, 0.0}); points.push_back(Point_d(point2.begin(), point2.end())); - // Choose all farthest points in a one point cloud + // Choose all farthest points among 2 points + Gudhi::subsampling::choose_n_farthest_points(k, points, -1, -1, std::back_inserter(landmarks), std::back_inserter(distances)); + BOOST_CHECK(landmarks.size() == 2 && distances.size() == 2); + BOOST_CHECK(distances[0] == std::numeric_limits::infinity()); + BOOST_CHECK(distances[1] == 1); + landmarks.clear(); distances.clear(); + + // Ignore duplicated points + points.push_back(Point_d(point.begin(), point.end())); Gudhi::subsampling::choose_n_farthest_points(k, points, -1, -1, std::back_inserter(landmarks), std::back_inserter(distances)); BOOST_CHECK(landmarks.size() == 2 && distances.size() == 2); BOOST_CHECK(distances[0] == std::numeric_limits::infinity()); -- cgit v1.2.3 From 705aa3b7ddc0a2bbbcc31c4b45e19792bd4ce9a5 Mon Sep 17 00:00:00 2001 From: Marc Glisse Date: Wed, 28 Oct 2020 00:04:37 +0100 Subject: emplace_back --- src/Subsampling/test/test_choose_n_farthest_points.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/Subsampling/test/test_choose_n_farthest_points.cpp b/src/Subsampling/test/test_choose_n_farthest_points.cpp index 08b82d61..b318d58e 100644 --- a/src/Subsampling/test/test_choose_n_farthest_points.cpp +++ b/src/Subsampling/test/test_choose_n_farthest_points.cpp @@ -39,7 +39,7 @@ BOOST_AUTO_TEST_CASE_TEMPLATE(test_choose_farthest_point, Kernel, list_of_tested for (FT k = 0; k < 5; k += 1.0) for (FT l = 0; l < 5; l += 1.0) { std::vector point({i, j, k, l}); - points.push_back(Point_d(point.begin(), point.end())); + points.emplace_back(point.begin(), point.end()); } landmarks.clear(); @@ -75,7 +75,7 @@ BOOST_AUTO_TEST_CASE_TEMPLATE(test_choose_farthest_point_limits, Kernel, list_of landmarks.clear(); distances.clear(); std::vector point({0.0, 0.0, 0.0, 0.0}); - points.push_back(Point_d(point.begin(), point.end())); + points.emplace_back(point.begin(), point.end()); // Choose -1 farthest points in a one point cloud Gudhi::subsampling::choose_n_farthest_points(k, points, -1, -1, std::back_inserter(landmarks), std::back_inserter(distances)); BOOST_CHECK(landmarks.size() == 1 && distances.size() == 1); @@ -92,7 +92,7 @@ BOOST_AUTO_TEST_CASE_TEMPLATE(test_choose_farthest_point_limits, Kernel, list_of landmarks.clear(); distances.clear(); std::vector point2({1.0, 0.0, 0.0, 0.0}); - points.push_back(Point_d(point2.begin(), point2.end())); + points.emplace_back(point2.begin(), point2.end()); // Choose all farthest points among 2 points Gudhi::subsampling::choose_n_farthest_points(k, points, -1, -1, std::back_inserter(landmarks), std::back_inserter(distances)); BOOST_CHECK(landmarks.size() == 2 && distances.size() == 2); @@ -101,7 +101,7 @@ BOOST_AUTO_TEST_CASE_TEMPLATE(test_choose_farthest_point_limits, Kernel, list_of landmarks.clear(); distances.clear(); // Ignore duplicated points - points.push_back(Point_d(point.begin(), point.end())); + points.emplace_back(point.begin(), point.end()); Gudhi::subsampling::choose_n_farthest_points(k, points, -1, -1, std::back_inserter(landmarks), std::back_inserter(distances)); BOOST_CHECK(landmarks.size() == 2 && distances.size() == 2); BOOST_CHECK(distances[0] == std::numeric_limits::infinity()); -- cgit v1.2.3