Skip to content

Commit

Permalink
misc fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
mglisse committed Aug 3, 2024
1 parent 6ac1c9f commit 2485582
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
6 changes: 5 additions & 1 deletion src/python/gudhi/_ripser.cc
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,11 @@ py::list doit(DistanceMatrix&& dist, int max_dimension, typename DistanceMatrix:
std::vector<std::vector<std::array<T, 2>>> dgms;
{
py::gil_scoped_release release;
auto output = [&](T birth, T death){ dgms.back().push_back({birth, death}); };
auto output = [&](T birth, T death){
// Skip empty intervals
if (birth < death)
dgms.back().push_back({birth, death});
};
auto switch_dim = [&](int new_dim){
dgms.emplace_back();
};
Expand Down
3 changes: 2 additions & 1 deletion src/python/gudhi/sklearn/rips_persistence.py
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,8 @@ def __transform(self, inp):
else:
raise ValueError("Only 'point cloud', 'lower distance matrix', 'full distance matrix' and 'coo_matrix' are valid input_type") # move to __init__?

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

def transform(self, X, Y=None):
"""Compute all the Vietoris-Rips complexes and their associated persistence diagrams.
Expand Down

0 comments on commit 2485582

Please sign in to comment.