-
Notifications
You must be signed in to change notification settings - Fork 79
avoid possible infinite loop in canonicalize #1198
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
Conversation
Codecov Report
@@ Coverage Diff @@
## main #1198 +/- ##
==========================================
+ Coverage 93.70% 93.71% +0.01%
==========================================
Files 26 26
Lines 21466 21472 +6
Branches 904 904
==========================================
+ Hits 20114 20122 +8
+ Misses 1314 1312 -2
Partials 38 38
Flags with carried forward coverage won't be shown. Click here to find out more.
Continue to review full report at Codecov.
|
|
Whoops, this doesn't fix it. Consider 0->1, 1->2, 2->1. Huh, tricky. |
|
I guess we have to sort first so that parents come before children, and then check for inconsistencies? (Like #1197?) |
|
The problem occurs while computing the number of descendant mutations, which is the key that allows us to sort so parents come before children if times are equal (or, unknown). This is the problem of detecting cycles in a directed graph; I'll have a look at algorithms for that. |
|
Ok, this will correctly check things now. I think it's totally good enough. |
a1003ae to
50dda78
Compare
|
Wait, never mind - not right yet. |
e5a1874 to
9ed3cc4
Compare
|
Ok, for reals now! I think to do this in a clever way we'd need to build the trees-of-mutations and then traverse them in an ordered fashion, which seems overkill here, since in general we don't expect a lot of mutations per site. I'm just checking if there's a loop in the boneheaded way: by checking if we think any mutation has more than num_mutations descendants. |
jeromekelleher
left a comment
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.
LGTM!
|
This is clever - detect a loop by letting it loop until we know it's definitely gone too far. Who cares if it's not the most efficient possible way of detecting the loop, it's an error anyway. Very elegant! |
Looking at #1192 I realized there was potential for an infinite loop in the case of bad mutation parent input. Whoops! Here's a fix.