Skip to content

Commit

Permalink
Merge pull request #154 from scikit-tda/lowerstar_fix
Browse files Browse the repository at this point in the history
Lowerstar fix
  • Loading branch information
ctralie authored Feb 5, 2024
2 parents 587dc79 + cec490b commit 76da8ca
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 12 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
# 0.6.5
- Bugfix for lower star filtrations with edges that come in at exactly 0 (courtesy of Riccardo Ceccaroni)

# 0.6.4
- Add some includes to ripser.cpp for newer Ubuntu/C++ environments

Expand Down
2 changes: 1 addition & 1 deletion ripser/_version.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
__version__ = "0.6.4"
__version__ = "0.6.5"
18 changes: 8 additions & 10 deletions ripser/ripser.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -687,16 +687,14 @@ class ripser
v = dset.find(vertices_of_edge[1]);

if (u != v) {
if (get_diameter(e) != 0) {
// Elder rule; youngest class (max birth time of u and v)
// dies first
value_t birth =
std::max(dset.get_birth(u), dset.get_birth(v));
value_t death = get_diameter(e);
if (death > birth) {
births_and_deaths_by_dim[0].push_back(birth);
births_and_deaths_by_dim[0].push_back(death);
}
// Elder rule; youngest class (max birth time of u and v)
// dies first
value_t birth =
std::max(dset.get_birth(u), dset.get_birth(v));
value_t death = get_diameter(e);
if (death > birth) {
births_and_deaths_by_dim[0].push_back(birth);
births_and_deaths_by_dim[0].push_back(death);
}
dset.link(u, v);
} else
Expand Down
8 changes: 7 additions & 1 deletion test/test_lower_star.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,4 +19,10 @@ def test_single_point(self):
assert dgm.shape[0] == 1
assert tuple(dgm[0]) == (0,np.inf)


def test_zero_edge_bug(self):
img = np.ones((5, 5))
img[1:-1, 1:-1] = 0
img[2, 2] = 1
r1 = -lower_star_img(-img)
r2 = 1-lower_star_img(1-img)
assert(np.allclose(r1, r2))

0 comments on commit 76da8ca

Please sign in to comment.