Skip to content

Commit

Permalink
Update gudhi bindings to latest changes on August 2020 (#468)
Browse files Browse the repository at this point in the history
* Pull latest changes on Gudhi-devel:giotto

* Add Eigen as a submodule

Eigen is now required for latest Gudhi version

* Add Eigen for gudhi modules that require it

* Update get_filtration and get_skeleton with the new Gudhi API

* Update ccache in CI

* Fix type issue for get_persistence in simplex_tree

* Fix persistence in periodic cubical complex

* Fix simplex tree

* Fix cubical complex

* Beautify setup.py

* Move towards fixing #307 in azure_pipelines.yml (still not addressing docker_scripts.sh)

Signed-off-by: julian <julian.burellaperez@heig-vd.ch>
Co-authored-by: Umberto Lupo <umberto.lupo@gmail.com>
  • Loading branch information
reds-heig and ulupo authored Aug 28, 2020
1 parent 9d7ce62 commit bc2bc29
Show file tree
Hide file tree
Showing 15 changed files with 200 additions and 175 deletions.
5 changes: 3 additions & 2 deletions .azure-ci/docker_scripts.sh
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ tar -zxvf /boost_1_69_0.tar.gz
mkdir boost
cd /boost_1_69_0
./bootstrap.sh --prefix=/boost
./b2 install -j3 || echo "Parts of boost failed to build. Continuing.."
./b2 install -j3 || echo "Parts of boost failed to build. Continuing..."
cd ..

ccache -s
Expand All @@ -36,6 +36,7 @@ export Boost_INCLUDE_DIR=/boost/include

# Install dev environment
cd /io
pip install wheel
pip install -e ".[dev]"

# Test dev install with pytest
Expand All @@ -46,10 +47,10 @@ pip uninstall -y giotto-tda
pip uninstall -y giotto-tda-nightly

# Build wheels
pip install wheel==0.34.1 auditwheel==3.1.0
python setup.py bdist_wheel

# Repair wheels with auditwheel
pip install auditwheel
auditwheel repair dist/*whl -w dist/
# remove wheels that are not manylinux2010
rm -rf dist/*-linux*.whl
3 changes: 3 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
Expand Up @@ -8,3 +8,6 @@
[submodule "gtda/externals/hera"]
path = gtda/externals/hera
url = https://github.com/grey-narn/hera
[submodule "gtda/externals/eigen"]
path = gtda/externals/eigen
url = https://gitlab.com/libeigen/eigen
11 changes: 11 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ find_package(OpenMP)
set(RIPSER_SRC_DIR "gtda/externals/ripser")
set(GUDHI_SRC_DIR "gtda/externals/gudhi-devel/src")
set(HERA_DIR "gtda/externals/hera")
set(EIGEN_DIR "gtda/externals/eigen")

#######################################################################
# Ripser #
Expand Down Expand Up @@ -171,6 +172,8 @@ target_include_directories(gtda_simplex_tree PRIVATE "${GUDHI_SRC_DIR}/Cech_comp
target_include_directories(gtda_simplex_tree PRIVATE "${GUDHI_SRC_DIR}/Persistent_cohomology/include")
target_include_directories(gtda_simplex_tree PRIVATE "${GUDHI_SRC_DIR}/Subsampling/include")
target_include_directories(gtda_simplex_tree PRIVATE "${GUDHI_SRC_DIR}/python/include")
target_include_directories(gtda_simplex_tree PRIVATE "${GUDHI_SRC_DIR}/Collapse/include")
target_include_directories(gtda_simplex_tree PRIVATE "${EIGEN_DIR}")

if(MSVC)
target_compile_options(gtda_simplex_tree PUBLIC $<$<CONFIG:RELEASE>: /O2 /Wall /fp:strict>)
Expand Down Expand Up @@ -227,6 +230,8 @@ target_include_directories(gtda_witness_complex PRIVATE "${GUDHI_SRC_DIR}/Cech_c
target_include_directories(gtda_witness_complex PRIVATE "${GUDHI_SRC_DIR}/Persistent_cohomology/include")
target_include_directories(gtda_witness_complex PRIVATE "${GUDHI_SRC_DIR}/python/include")
target_include_directories(gtda_witness_complex PRIVATE "${GUDHI_SRC_DIR}/common/include")
target_include_directories(gtda_witness_complex PRIVATE "${GUDHI_SRC_DIR}/Collapse/include")
target_include_directories(gtda_witness_complex PRIVATE "${EIGEN_DIR}")

if(MSVC)
target_compile_options(gtda_witness_complex PUBLIC $<$<CONFIG:RELEASE>: /O2 /Wall /fp:strict>)
Expand Down Expand Up @@ -256,6 +261,8 @@ target_include_directories(gtda_strong_witness_complex PRIVATE "${GUDHI_SRC_DIR}
target_include_directories(gtda_strong_witness_complex PRIVATE "${GUDHI_SRC_DIR}/Persistent_cohomology/include")
target_include_directories(gtda_strong_witness_complex PRIVATE "${GUDHI_SRC_DIR}/python/include")
target_include_directories(gtda_strong_witness_complex PRIVATE "${GUDHI_SRC_DIR}/common/include")
target_include_directories(gtda_strong_witness_complex PRIVATE "${GUDHI_SRC_DIR}/Collapse/include")
target_include_directories(gtda_strong_witness_complex PRIVATE "${EIGEN_DIR}")

if(MSVC)
target_compile_options(gtda_strong_witness_complex PUBLIC $<$<CONFIG:RELEASE>: /O2 /Wall /fp:strict>)
Expand Down Expand Up @@ -286,6 +293,8 @@ target_include_directories(gtda_sparse_rips_complex PRIVATE "${GUDHI_SRC_DIR}/Pe
target_include_directories(gtda_sparse_rips_complex PRIVATE "${GUDHI_SRC_DIR}/Rips_complex/include")
target_include_directories(gtda_sparse_rips_complex PRIVATE "${GUDHI_SRC_DIR}/Subsampling/include")
target_include_directories(gtda_sparse_rips_complex PRIVATE "${GUDHI_SRC_DIR}/python/include")
target_include_directories(gtda_sparse_rips_complex PRIVATE "${GUDHI_SRC_DIR}/Collapse/include")
target_include_directories(gtda_sparse_rips_complex PRIVATE "${EIGEN_DIR}")

if(MSVC)
target_compile_options(gtda_sparse_rips_complex PUBLIC $<$<CONFIG:RELEASE>: /O2 /Wall /fp:strict>)
Expand Down Expand Up @@ -314,6 +323,8 @@ target_include_directories(gtda_cech_complex PRIVATE "${GUDHI_SRC_DIR}/Cech_comp
target_include_directories(gtda_cech_complex PRIVATE "${GUDHI_SRC_DIR}/Persistent_cohomology/include")
target_include_directories(gtda_cech_complex PRIVATE "${GUDHI_SRC_DIR}/python/include")
target_include_directories(gtda_cech_complex PRIVATE "${GUDHI_SRC_DIR}/common/include")
target_include_directories(gtda_cech_complex PRIVATE "${GUDHI_SRC_DIR}/Collapse/include")
target_include_directories(gtda_cech_complex PRIVATE "${EIGEN_DIR}")

if(MSVC)
target_compile_options(gtda_cech_complex PUBLIC $<$<CONFIG:RELEASE>: /O2 /Wall /fp:strict>)
Expand Down
35 changes: 18 additions & 17 deletions azure-pipelines.yml
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ jobs:

- task: Cache@2
inputs:
key: '"ccache-wheels-v2020.08.08" | $(Agent.OS) | "$(python.version)"'
key: '"ccache-wheels-v2020.08.28" | $(Agent.OS) | "$(python.version)"'
path: $(CCACHE_DIR)
displayName: ccache

Expand All @@ -63,21 +63,21 @@ jobs:
- script: |
set -e
python -m pip install --upgrade pip
pip install dist/*manylinux2010*.whl
python -m pip install dist/*manylinux2010*.whl
displayName: 'Install the wheels'
- script: |
set -e
pip install pytest pytest-cov pytest-azurepipelines pytest-benchmark hypothesis
python -m pip install pytest pytest-cov pytest-azurepipelines pytest-benchmark hypothesis
mkdir tmp_test_cov
cd tmp_test_cov
pytest --pyargs gtda --ignore-glob='*externals*' --no-cov --no-coverage-upload
displayName: 'Test the wheels with pytest'
- script: |
set -e
pip install pandas openml matplotlib
pip install "papermill==1.2.1"
python -m pip install pandas openml matplotlib
python -m pip install "papermill==1.2.1"
cd examples
for n in *.ipynb
do
Expand All @@ -100,7 +100,7 @@ jobs:

- bash: |
set -e
pip install twine
python -m pip install twine
twine upload -u giotto-learn -p $(pypi_psw) --skip-existing dist/*manylinux2010*.whl
condition: eq(variables.nightlyRelease, true)
displayName: 'Upload nightly wheels to PyPI'
Expand Down Expand Up @@ -136,7 +136,7 @@ jobs:
- task: Cache@2
inputs:
key: '"ccache-v2020.08.08" | $(Agent.OS) | "$(python.version)"'
key: '"ccache-v2020.08.28" | $(Agent.OS) | "$(python.version)"'
path: $(CCACHE_DIR)
displayName: ccache

Expand All @@ -149,6 +149,7 @@ jobs:
- script: |
set -e
python -m pip install --upgrade pip setuptools
python -m pip install wheel
source .azure-ci/setup_ccache.sh
python -m pip install -e ".[dev]"
ccache -s
Expand All @@ -172,11 +173,10 @@ jobs:
- script: |
set -e
pip install wheel
python setup.py bdist_wheel
displayName: 'Build the wheels'
- script: pip install dist/*.whl
- script: python -m pip install dist/*.whl
displayName: 'Install the wheels'

- script: |
Expand All @@ -189,7 +189,7 @@ jobs:
- script: |
set -e
python -m pip install -e ".[examples]"
pip install "papermill==1.2.1"
python -m pip install "papermill==1.2.1"
cd examples
for n in *.ipynb
do
Expand All @@ -205,7 +205,7 @@ jobs:

- script: |
set -e
pip install twine
python -m pip install twine
twine check dist/*
displayName: 'Check distribution with twine'
Expand Down Expand Up @@ -257,6 +257,7 @@ jobs:
- script: |
python -m pip install --upgrade pip setuptools
python -m pip install wheel
python -m pip install -e ".[dev]"
displayName: 'Install dev environment'
Expand All @@ -265,18 +266,17 @@ jobs:
displayName: 'Test dev install with pytest'
- script: |
pip uninstall -y giotto-tda
pip uninstall -y giotto-tda-nightly
python -m pip uninstall -y giotto-tda
python -m pip uninstall -y giotto-tda-nightly
displayName: 'Uninstall giotto-tda/giotto-tda-nightly dev'
- bash: |
set -e
sed -i $'s/\r$//' README.rst
pip install wheel
python setup.py bdist_wheel
displayName: 'Build the wheels'
- bash: pip install dist/*.whl
- bash: python -m pip install dist/*.whl
displayName: 'Install the wheels'

- script: |
Expand All @@ -287,7 +287,7 @@ jobs:
- script: |
python -m pip install -e ".[examples]"
pip install "papermill==1.2.1"
python -m pip install "papermill==1.2.1"
cd examples
FOR %%n in (*.ipynb) DO (papermill --start_timeout 2000 %%n - || exit /b)
condition: eq(variables['notebooks_check'], 'true')
Expand All @@ -307,7 +307,8 @@ jobs:

- bash: |
set -e
pip install twine
python -m pip install twine
twine upload -u giotto-learn -p $(pypi_psw) --skip-existing dist/*
condition: eq(variables.nightlyRelease, true)
displayName: 'Upload nightly wheels to PyPI'
3 changes: 1 addition & 2 deletions cmake/HelperBoost.cmake
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@

# Add to BOOST_ROOT variable a custom path to
# ease installation of giotto-tda on Windows platform
# ease installation of giotto-tda on Windows platforms
# The custom path will be at `C:\\local\`
if(WIN32)
list(APPEND BOOST_ROOT "C:/local")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,8 @@ PYBIND11_MODULE(gtda_periodic_cubical_complex, m) {
Bitmap_cubical_complex_periodic_boundary_conditions_base<
double>>*,
bool>())
.def("compute_persistence",
&Persistent_cohomology_interface_inst::compute_persistence)
.def("get_persistence",
&Persistent_cohomology_interface_inst::get_persistence)
.def("betti_numbers",
Expand All @@ -58,4 +60,3 @@ PYBIND11_MODULE(gtda_periodic_cubical_complex, m) {
&Persistent_cohomology_interface_inst::intervals_in_dimension);
m.doc() = "GUDHI periocal cubical complex function interfacing";
}

4 changes: 3 additions & 1 deletion gtda/externals/bindings/persistent_cohomology_bindings.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@ PYBIND11_MODULE(gtda_persistent_cohomology, m) {
.def(py::init<Gudhi::cubical_complex::Cubical_complex_interface<>*>())
.def(py::init<Gudhi::cubical_complex::Cubical_complex_interface<>*,
bool>())
.def("compute_persistence",
&Persistent_cohomology_interface_inst::compute_persistence)
.def("get_persistence",
&Persistent_cohomology_interface_inst::get_persistence)
.def("betti_numbers",
Expand All @@ -28,5 +30,5 @@ PYBIND11_MODULE(gtda_persistent_cohomology, m) {
&Persistent_cohomology_interface_inst::persistent_betti_numbers)
.def("intervals_in_dimension",
&Persistent_cohomology_interface_inst::intervals_in_dimension);
m.doc() = "GUDHI persistant homology interfacing";
m.doc() = "GUDHI persistent homology interfacing";
}
1 change: 0 additions & 1 deletion gtda/externals/bindings/ripser_bindings.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -52,4 +52,3 @@ PYBIND11_MODULE(gtda_ripser, m) {
"I"_a, "J"_a, "V"_a, "NEdges"_a, "N"_a, "modulus"_a, "dim_max"_a,
"threshold"_a, "do_cocycles"_a, "ripser sparse distance matrix");
}

26 changes: 23 additions & 3 deletions gtda/externals/bindings/simplex_tree_bindings.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
* License: Apache 2.0
*****************************************************************************/


#include <iostream>

#include <Persistent_cohomology_interface.h>
#include <Simplex_tree_interface.h>

Expand Down Expand Up @@ -41,8 +41,26 @@ PYBIND11_MODULE(gtda_simplex_tree, m) {
const std::vector<simplex_tree_interface_inst::Vertex_handle>&,
double>(
&simplex_tree_interface_inst::insert_simplex_and_subfaces))
.def("get_filtration", &simplex_tree_interface_inst::get_filtration)
.def("get_skeleton", &simplex_tree_interface_inst::get_skeleton)
.def("get_filtration",
[](simplex_tree_interface_inst& self)
-> std::vector<simplex_tree_interface_inst::Simplex_and_filtration> {
std::vector<simplex_tree_interface_inst::Simplex_and_filtration> tmp;
for (auto elem = self.get_filtration_iterator_begin();
elem != self.get_filtration_iterator_end(); elem++)
tmp.push_back(self.get_simplex_and_filtration(*elem));
return tmp;
})
.def("get_skeleton",
[](simplex_tree_interface_inst& self, size_t dim)
-> std::vector<
simplex_tree_interface_inst::Simplex_and_filtration> {
std::vector<simplex_tree_interface_inst::Simplex_and_filtration>
tmp;
for (auto elem = self.get_skeleton_iterator_begin(dim);
elem != self.get_skeleton_iterator_end(dim); elem++)
tmp.push_back(self.get_simplex_and_filtration(*elem));
return tmp;
})
.def("get_star", &simplex_tree_interface_inst::get_star)
.def("get_cofaces", &simplex_tree_interface_inst::get_cofaces)
.def("expansion", &simplex_tree_interface_inst::expansion)
Expand All @@ -59,6 +77,8 @@ PYBIND11_MODULE(gtda_simplex_tree, m) {
py::class_<Persistent_cohomology_interface_inst>(
m, "Simplex_tree_persistence_interface")
.def(py::init<simplex_tree_interface_inst*, bool>())
.def("compute_persistence",
&Persistent_cohomology_interface_inst::compute_persistence)
.def("get_persistence",
&Persistent_cohomology_interface_inst::get_persistence)
.def("betti_numbers",
Expand Down
1 change: 1 addition & 0 deletions gtda/externals/eigen
Submodule eigen added at 25424d
2 changes: 1 addition & 1 deletion gtda/externals/gudhi-devel
Submodule gudhi-devel updated 108 files
6 changes: 3 additions & 3 deletions gtda/externals/python/cubical_complex_interface.py
Original file line number Diff line number Diff line change
Expand Up @@ -100,9 +100,9 @@ def persistence(self, homology_coeff_field=11, min_persistence=0):
True)
persistence_result = []
if self.pcohptr is not None:
persistence_result = self.pcohptr.get_persistence(
homology_coeff_field, min_persistence)

self.pcohptr.compute_persistence(homology_coeff_field,
min_persistence)
persistence_result = self.pcohptr.get_persistence()
return persistence_result

def betti_numbers(self):
Expand Down
4 changes: 2 additions & 2 deletions gtda/externals/python/periodic_cubical_complex_interface.py
Original file line number Diff line number Diff line change
Expand Up @@ -100,9 +100,9 @@ def persistence(self, homology_coeff_field=11, min_persistence=0):
True)
persistence_result = []
if self.pcohptr is not None:
persistence_result = \
self.pcohptr.get_persistence(homology_coeff_field,
self.pcohptr.compute_persistence(homology_coeff_field,
min_persistence)
persistence_result = self.pcohptr.get_persistence()
return persistence_result

def betti_numbers(self):
Expand Down
Loading

0 comments on commit bc2bc29

Please sign in to comment.