Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Lowerstar fix #154

Merged
merged 4 commits into from
Feb 5, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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))
Loading