Skip to content

Commit e39c19b

Browse files
committed
Fixes #44
1 parent 320cd79 commit e39c19b

File tree

2 files changed

+4
-5
lines changed

2 files changed

+4
-5
lines changed

persim/bottleneck.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,8 @@ def bottleneck(dgm1, dgm2, matching=False):
8383

8484
# Put diagonal elements into the matrix, being mindful that Linfinity
8585
# balls meet the diagonal line at a diamond vertex
86-
D = np.zeros((M + N, M + N))
86+
D = np.inf*np.ones((M + N, M + N))
87+
np.fill_diagonal(D, 0)
8788
D[0:M, 0:N] = DUL
8889
UR = np.max(D) * np.ones((M, M))
8990
np.fill_diagonal(UR, 0.5 * (S[:, 1] - S[:, 0]))
@@ -95,7 +96,7 @@ def bottleneck(dgm1, dgm2, matching=False):
9596
# Step 2: Perform a binary search + Hopcroft Karp to find the
9697
# bottleneck distance
9798
M = D.shape[0]
98-
ds = np.sort(np.unique(D.flatten()))
99+
ds = np.sort(np.unique(D.flatten()))[0:-1] # Everything but np.inf
99100
bdist = ds[-1]
100101
matching = {}
101102
while len(ds) >= 1:

test/test_distances.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -61,9 +61,7 @@ def test_different_size(self):
6161
[0.5, 1.1]
6262
])
6363
)
64-
65-
# These are very loose bounds
66-
assert d == pytest.approx(0.1, 0.001)
64+
assert d == 0.25
6765

6866
def test_matching(self):
6967
dgm1 = np.array([

0 commit comments

Comments
 (0)