Closed VincentRouvreau closed 1 month ago
The code of betti_numbers
looks like
std::vector<int> betti_numbers(std::max(dim_max_, 0));
for (auto pair : persistent_pairs_) {
// Count never ended persistence intervals
if (cpx_->null_simplex() == get<1>(pair)) {
// Increment corresponding betti number
betti_numbers[cpx_->dimension(get<0>(pair))] += 1;
}
}
In this example, dim_max_
is 0, so we create a vector of size 0, but persistent_pairs_
is not empty, it contains infinite intervals for the vertices.
Note that persistence_dim_max
is false
. If I set it to true
, we create a vector of the right size, and things work.
Arguably, the bug is that we computed H0 even though the combination of dimension()
and persistence_dim_max
tells us not to. A completely different testcase:
import gudhi
st=gudhi.SimplexTree()
st.insert([0])
st.insert([1])
st.persistence()
[(0, (0.0, inf)), (0, (0.0, inf))]
but I think according to the documentation it should return []
.