Skip to content

Commit

Permalink
Merge branch 'GUDHI:master' into matrix_vine_opt
Browse files Browse the repository at this point in the history
  • Loading branch information
hschreiber authored Oct 14, 2024
2 parents 26c7fb8 + 6391ac2 commit 48d4d66
Show file tree
Hide file tree
Showing 8 changed files with 41 additions and 29 deletions.
20 changes: 8 additions & 12 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
version: 2.0
jobs:

### With all third parties
### With all third parties

examples:
docker:
# cf. https://github.com/GUDHI/gudhi-deploy/blob/main/Dockerfile_for_circleci_image
- image: gudhi/ci_for_gudhi:2024.06.02
- image: gudhi/ci_for_gudhi:2024.09.01
steps:
- checkout
- run:
Expand All @@ -25,7 +24,7 @@ jobs:
tests:
docker:
- image: gudhi/ci_for_gudhi:2024.06.02
- image: gudhi/ci_for_gudhi:2024.09.01
steps:
- checkout
- run:
Expand All @@ -44,7 +43,7 @@ jobs:
debug_tests:
docker:
- image: gudhi/ci_for_gudhi:2024.06.02
- image: gudhi/ci_for_gudhi:2024.09.01
steps:
- checkout
- run:
Expand All @@ -63,7 +62,7 @@ jobs:
utils:
docker:
- image: gudhi/ci_for_gudhi:2024.06.02
- image: gudhi/ci_for_gudhi:2024.09.01
steps:
- checkout
- run:
Expand All @@ -82,7 +81,7 @@ jobs:
python:
docker:
- image: gudhi/ci_for_gudhi:2024.06.02
- image: gudhi/ci_for_gudhi:2024.09.01
resource_class: large # Delaunay complex requires about 5 Gb of RAM to compile
steps:
- checkout
Expand All @@ -94,7 +93,6 @@ jobs:
- run:
name: Build and test python module. Generates and tests the python documentation
command: |
pip3 install pydata-sphinx-theme
mkdir build
cd build
cmake -DWITH_GUDHI_THIRD_PARTY=OFF -DUSER_VERSION_DIR=version ..
Expand Down Expand Up @@ -167,8 +165,7 @@ jobs:
latexmk -pdf -interaction=nonstopmode test_biblio.tex
latexmk -pdf -interaction=nonstopmode test_gudhi_citation.tex
### With all third parties, except CGAL and Eigen
### With all third parties, except CGAL and Eigen

examples_without_cgal_eigen:
docker:
Expand Down Expand Up @@ -248,8 +245,7 @@ jobs:
python3 setup.py build_ext --inplace
ctest --output-on-failure
### With all third parties, except CGAL
### With all third parties, except CGAL

examples_without_cgal:
docker:
Expand Down
1 change: 1 addition & 0 deletions src/Alpha_complex/test/Incremental_delaunay_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
#define BOOST_TEST_MODULE "incremental_delaunay"
#include <boost/test/unit_test.hpp>
#include <boost/range/adaptor/sliced.hpp>
#include <boost/mpl/list.hpp>

#include <CGAL/Epick_d.h>
#include <CGAL/Epeck_d.h>
Expand Down
10 changes: 5 additions & 5 deletions src/Subsampling/include/gudhi/choose_n_farthest_points.h
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,7 @@ using radius_priority_ds =
boost::heap::mutable_<true>, boost::heap::constant_time_size<false>>;
template<class FT>
struct Landmark_info {
std::size_t far; FT radius;
std::size_t farthest; FT radius;
// The points that are closer to this landmark than to other landmarks
std::vector<std::pair<std::size_t, FT>> voronoi;
// For a landmark A, the list of landmarks B such that picking a Voronoi
Expand Down Expand Up @@ -251,7 +251,7 @@ void choose_n_farthest_points_metric(Distance dist_,
}
}
landmarks[i].radius = r;
landmarks[i].far = jmax;
landmarks[i].farthest = jmax;
};
auto update_radius = [&](std::size_t i)
{
Expand Down Expand Up @@ -280,7 +280,7 @@ void choose_n_farthest_points_metric(Distance dist_,
for (std::size_t current_number_of_landmarks = 1; current_number_of_landmarks != final_size; current_number_of_landmarks++) {
std::size_t l_parent = radius_priority.top();
auto& parent_info = landmarks[l_parent];
std::size_t l = parent_info.far;
std::size_t l = parent_info.farthest;
FT radius = parent_info.radius;
auto& info = landmarks[l];
*output_it++ = input_pts[l];
Expand Down Expand Up @@ -309,8 +309,8 @@ void choose_n_farthest_points_metric(Distance dist_,
if (it != ngb_info.voronoi.end()) { // modified, always true for ngb==l_parent
ngb_info.voronoi.erase(it, ngb_info.voronoi.end());
modified_neighbors.push_back(ngb);
// We only need to recompute the radius if far was removed, which we can test here with
// if (dist(l, ngb_info.far) < ngb_info.radius)
// We only need to recompute the radius if farthest was removed, which we can test here with
// if (dist(l, ngb_info.farthest) < ngb_info.radius)
// to avoid a costly test for each w in the loop above, but it does not seem to help.
update_radius(ngb);
// if (ngb_info.voronoi.empty()) radius_priority.erase(ngb_info.position_in_queue);
Expand Down
1 change: 1 addition & 0 deletions src/cmake/modules/GUDHI_third_party_libraries.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -185,6 +185,7 @@ if (WITH_GUDHI_PYTHON)
find_python_module("sphinx_paramlinks")
find_python_module("pydata_sphinx_theme")
find_python_module("sphinxcontrib.bibtex")
find_python_module("sphinx-autodoc-typehints")
find_python_module("networkx")
# Specific case for PyKeops on Windows where import fails because it uses fcntl (not available on Windows)
if (NOT WIN32)
Expand Down
5 changes: 5 additions & 0 deletions src/python/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -178,6 +178,11 @@ if(SPHINXCONTRIB.BIBTEX_FOUND)
else()
disable_python_documentation("sphinxcontrib-bibtex")
endif()
if(SPHINX-AUTODOC-TYPEHINTS_FOUND)
add_gudhi_debug_info("sphinx-autodoc-typehints version ${SPHINX-AUTODOC-TYPEHINTS_VERSION}")
else()
disable_python_documentation("sphinx-autodoc-typehints")
endif()
if(NETWORKX_FOUND)
add_gudhi_debug_info("NetworkX version ${NETWORKX_VERSION}")
endif()
Expand Down
8 changes: 7 additions & 1 deletion src/python/doc/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,18 +8,24 @@
sys.path.insert(0, os.path.abspath("."))

extensions = [
"sphinx.ext.napoleon",
# let napoleon be the first extension, cf. https://github.com/tox-dev/sphinx-autodoc-typehints/issues/15
"matplotlib.sphinxext.plot_directive",
"sphinx.ext.autodoc",
"sphinx_autodoc_typehints",
"sphinx.ext.doctest",
"sphinx.ext.mathjax",
"sphinx.ext.ifconfig",
"sphinx.ext.viewcode",
"sphinx.ext.napoleon",
"sphinxcontrib.bibtex",
"sphinx_paramlinks",
]

autodoc_class_signature = "separated"
# cf. https://github.com/tox-dev/sphinx-autodoc-typehints#options
autodoc_typehints = "none"
napoleon_use_rtype = True
always_use_bars_union = True

bibtex_bibfiles = ["../../biblio/bibliography.bib"]

Expand Down
2 changes: 2 additions & 0 deletions src/python/doc/installation.rst
Original file line number Diff line number Diff line change
Expand Up @@ -183,6 +183,7 @@ A complete configuration would be :
Sphinx-paramlinks version 0.6.0
pydata_sphinx_theme version 0.15.2
sphinxcontrib-bibtex version 2.6.2
sphinx-autodoc-typehints version 2.4.4
NetworkX version 3.3
Eigen3 version 3.4.0
Boost version 1.84.0
Expand All @@ -204,6 +205,7 @@ Documentation

To build the documentation, `sphinx-doc <http://www.sphinx-doc.org>`_,
`sphinxcontrib-bibtex <https://sphinxcontrib-bibtex.readthedocs.io>`_,
`sphinx-autodoc-typehints <https://github.com/tox-dev/sphinx-autodoc-typehints>`_,
`sphinxcontrib-paramlinks <https://github.com/sqlalchemyorg/sphinx-paramlinks>`_ and
`pydata-sphinx-theme <https://github.com/pydata/pydata-sphinx-theme>`_ :math:`\geq` 0.8.0 are
required. As the documentation is auto-tested, `CGAL`_, `Eigen`_,
Expand Down
23 changes: 12 additions & 11 deletions src/python/gudhi/sklearn/rips_persistence.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,23 +52,24 @@ def __init__(
homology_coeff_field: int = 11,
n_jobs: Optional[int] = None,
):
"""
Constructor for the RipsPersistence class.
"""Constructor for the RipsPersistence class.
Parameters:
homology_dimensions (int or list of int): The returned persistence diagrams dimension(s).
homology_dimensions: The returned persistence diagrams dimension(s).
Short circuit the use of :class:`~gudhi.representations.preprocessing.DimensionSelector` when only one
dimension matters (in other words, when `homology_dimensions` is an int).
threshold (float): Rips maximal edge length value. Default is +Inf. Ignored if input_type is 'distance coo_matrix'.
input_type (str): Can be 'point cloud' when inputs are point clouds, 'full distance matrix',
threshold: Rips maximal edge length value. Default is +Inf. Ignored if input_type is
'distance coo_matrix'.
input_type: Can be 'point cloud' when inputs are point clouds, 'full distance matrix',
'lower distance matrix' when inputs are lower triangular distance matrix (can be full square,
but the upper part will not be considered), or 'distance coo_matrix' for a distance matrix in SciPy's
sparse format, which should contain each edge at most once (avoid the symmetric) and no diagonal entry.
Default is 'point cloud'.
num_collapses (int|str): Specify the number of iterations of :func:`~gudhi.flag_filtration.edge_collapse.reduce_graph`
(edge collapse) to perform on the graph. Default value is 'auto'.
homology_coeff_field (int): The homology coefficient field. Must be a prime number. Default value is 11.
n_jobs (Optional[int]): Number of jobs to run in parallel. `None` (default value) means `n_jobs = 1` unless in a
num_collapses: Specify the number of iterations of
:func:`~gudhi.flag_filtration.edge_collapse.reduce_graph` (edge collapse) to perform on the graph.
Default value is 'auto'.
homology_coeff_field: The homology coefficient field. Must be a prime number. Default value is 11.
n_jobs: Number of jobs to run in parallel. `None` (default value) means `n_jobs = 1` unless in a
joblib.parallel_backend context. `-1` means using all processors. cf.
https://joblib.readthedocs.io/en/latest/generated/joblib.Parallel.html for more details.
"""
Expand Down Expand Up @@ -165,7 +166,7 @@ def __transform(self, inp):
dgm = _sparse(inp.row, inp.col, inp.data, inp.shape[0], max_dimension=max_dimension, max_edge_length=threshold, homology_coeff_field=self.homology_coeff_field)
else:
raise ValueError("Only 'point cloud', 'lower distance matrix', 'full distance matrix' and 'distance coo_matrix' are valid input_type") # move to __init__?

# dgm stops at n-2
return [dgm[dim] if dim < len(dgm) else np.empty((0,2)) for dim in self.dim_list_]

Expand All @@ -177,7 +178,7 @@ def transform(self, X, Y=None):
:return: Persistence diagrams in the format:
- If `homology_dimensions` was set to `n`: `[array( Hn(X[0]) ), array( Hn(X[1]) ), ...]`
- If `homology_dimensions` was set to `n`: `[array( Hn(X[0]) ), array( Hn(X[1]) ), ...]`
- If `homology_dimensions` was set to `[i, j]`:
`[[array( Hi(X[0]) ), array( Hj(X[0]) )], [array( Hi(X[1]) ), array( Hj(X[1]) )], ...]`
:rtype: list of numpy ndarray of shape (,2) or list of list of numpy ndarray of shape (,2)
Expand Down

0 comments on commit 48d4d66

Please sign in to comment.