Repository navigation
Conversation
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #111.
Problem
bottleneckandwassersteinonly filter non-finite death times, never birth times. A diagram containing a point with a-infbirth (which can arise, e.g. from ripser'slower_star_imgwhen the image holds-infanchor pixels, or from a negated superlevel persistence) therefore leaks-infinto the cross-similarity matrix:bottleneck,-inf - (-inf)evaluates toNaN, which lands inDand becomesds[-1], so the returned distance is silentlyNaN.wasserstein,pairwise_distancesproducesNaNfor the-infcoordinate, andscipy.optimize.linear_sum_assignmentraisesValueError.Fix
Filter on both coordinates —
np.isfinite(S[:, 0:2]).all(axis=1)— so a non-finite birth is handled the same way a non-finite death already is: the point is dropped with aUserWarning, consistent with the existing convention. The warning text is updated to "non-finite birth or death times" (the change is reflected in the four existingtest_inf_deathtimematches).Tests
test_inf_deathtimetests (bottleneck + wasserstein).test_inf_birthtimeto bothTestBottleneckandTestWasserstein, covering a[-inf, 0.5]point and asserting a finite result (the exact0.5bottleneck distance, and a finite symmetric wasserstein distance).Verification
pytest(full suite) → 114 passedruff check persim/andruff format --check persim/→ clean