-
Notifications
You must be signed in to change notification settings - Fork 66
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
Test insertion of simplex with NaN filtration value #424
base: master
Are you sure you want to change the base?
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
@@ -10,6 +10,7 @@ | |||||||||||||
|
||||||||||||||
from gudhi import SimplexTree | ||||||||||||||
import pytest | ||||||||||||||
import math | ||||||||||||||
|
||||||||||||||
__author__ = "Vincent Rouvreau" | ||||||||||||||
__copyright__ = "Copyright (C) 2016 Inria" | ||||||||||||||
|
@@ -399,3 +400,17 @@ def test_boundaries_iterator(): | |||||||||||||
|
||||||||||||||
with pytest.raises(RuntimeError): | ||||||||||||||
list(st.get_boundaries([6])) # (6) does not exist | ||||||||||||||
|
||||||||||||||
# insert with NaN must not modify filtration values | ||||||||||||||
# make_filtration_non_decreasing considers NaN small | ||||||||||||||
def test_nan(): | ||||||||||||||
st = SimplexTree() | ||||||||||||||
st.insert([1], 2.) | ||||||||||||||
st.insert([4], 5.) | ||||||||||||||
st.insert([2], -1.) | ||||||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
Perhaps already add a single edge (with an admissible value) to make sure that both inserting There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I inserted an extra edge. |
||||||||||||||
st.insert([1, 2, 4], math.nan) | ||||||||||||||
assert math.isnan(st.filtration([2, 4])) | ||||||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
Perhaps we may want to make sure that we did not modify any of the previous values even before calling There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I thought that checking after make_persistence_non_decreasing would be sufficient (if we overwrite a value with insert, make_persistence_non_decreasing won't be able to reinvent that value), but why not, done. |
||||||||||||||
st.make_filtration_non_decreasing() | ||||||||||||||
assert st.filtration([1, 2, 4]) == 5. | ||||||||||||||
assert st.filtration([1, 2]) == 2. | ||||||||||||||
assert st.filtration([2]) == -1. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Perhaps complete this note by adding a warning in the vein of what is done for
assign_filtration()
saying (e.g.) "In this particular case, the result will not be a valid filtration anymore. Callers are responsible for fixing this (usingassign_filtration()
ormake_filtration_non_decreasing()
for instance) before calling any function that relies on the filtration property, likepersistence()
.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I hadn't realized it, but having some NaN in the complex can have some weird effects. In particular, if I have vertex 0 with value NaN, inserting edge [0, 1] with value 42 does not change the value of vertex 0. I added some confusing text to the doc. We could change that behavior, but would need to check that it doesn't slow things down for normal operations.