Skip to content

Commit 76da8ca

Browse files
authored
Merge pull request #154 from scikit-tda/lowerstar_fix
Lowerstar fix
2 parents 587dc79 + cec490b commit 76da8ca

File tree

4 files changed

+19
-12
lines changed

4 files changed

+19
-12
lines changed

CHANGELOG.md

+3
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
# 0.6.5
2+
- Bugfix for lower star filtrations with edges that come in at exactly 0 (courtesy of Riccardo Ceccaroni)
3+
14
# 0.6.4
25
- Add some includes to ripser.cpp for newer Ubuntu/C++ environments
36

ripser/_version.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
__version__ = "0.6.4"
1+
__version__ = "0.6.5"

ripser/ripser.cpp

+8-10
Original file line numberDiff line numberDiff line change
@@ -687,16 +687,14 @@ class ripser
687687
v = dset.find(vertices_of_edge[1]);
688688

689689
if (u != v) {
690-
if (get_diameter(e) != 0) {
691-
// Elder rule; youngest class (max birth time of u and v)
692-
// dies first
693-
value_t birth =
694-
std::max(dset.get_birth(u), dset.get_birth(v));
695-
value_t death = get_diameter(e);
696-
if (death > birth) {
697-
births_and_deaths_by_dim[0].push_back(birth);
698-
births_and_deaths_by_dim[0].push_back(death);
699-
}
690+
// Elder rule; youngest class (max birth time of u and v)
691+
// dies first
692+
value_t birth =
693+
std::max(dset.get_birth(u), dset.get_birth(v));
694+
value_t death = get_diameter(e);
695+
if (death > birth) {
696+
births_and_deaths_by_dim[0].push_back(birth);
697+
births_and_deaths_by_dim[0].push_back(death);
700698
}
701699
dset.link(u, v);
702700
} else

test/test_lower_star.py

+7-1
Original file line numberDiff line numberDiff line change
@@ -19,4 +19,10 @@ def test_single_point(self):
1919
assert dgm.shape[0] == 1
2020
assert tuple(dgm[0]) == (0,np.inf)
2121

22-
22+
def test_zero_edge_bug(self):
23+
img = np.ones((5, 5))
24+
img[1:-1, 1:-1] = 0
25+
img[2, 2] = 1
26+
r1 = -lower_star_img(-img)
27+
r2 = 1-lower_star_img(1-img)
28+
assert(np.allclose(r1, r2))

0 commit comments

Comments
 (0)