Skip to content
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

Fix consensusTree() #441

Merged
merged 5 commits into from
Apr 4, 2024
Merged

Fix consensusTree() #441

merged 5 commits into from
Apr 4, 2024

Conversation

davidcerny
Copy link
Contributor

This branch reverts one of the readability changes introduced by @bredelings into the TreeSummary::mrTree() function in commit 2114c4b. As it turns out, this was the source of issue #361. I have verified that after changing the iterator back to what it was, RevBayes produces the same output as in v1.1.0, i.e., the version which was reported to still work correctly by the author of the issue.

Note that I haven't touched any of the other function in TreeSummary, many of which had analogous changes made to them. I haven't checked if any of those suffer from similar issues.

@bredelings
Copy link
Contributor

bredelings commented Apr 4, 2024

Oh drat. So the iterator version is walking the list in reverse, but my "readable" version is not.

It looks like there are 2 other instances where I switched a reverse walk to a forward walk. (i.e. they used .rbegin() and .rend())

@davidcerny
Copy link
Contributor Author

Ah, so that was it! Feel free to add commits to this branch as needed, of course

@bredelings
Copy link
Contributor

Hmm... I'd like to fix the other 2 cases in this file, and I also think we should add the test case from #361. Instead of just reverting the readability change, I have a way of fixing it.

@bredelings
Copy link
Contributor

OK, so I have fixed the bug in a different way, and also addressed the readability of for-loops doing a reverse walk.

Basically, anything that was iterating over a std::set<Sample<T>> and then doing a break to quit the loop when the count gets low enough needs to iterate in a reverse fashion, because the highest-probability items are at the end of the list.

When this finishes compiling on my slow laptop, I'm going to check that the we now get the right consensus tree for #361. Would it be possible for you to make a test-case out of this?

I'm thinking we need to add a new test_consensus directory. The new test script should start with seed(12345) and end with q() I think (just based on what the others do). It should load the trees, and then write out the majority consensus to output/, and then we should put the real output in output_expected. It would be nice to also generate (say) the mcc to a different file.

Does that sound doable for you, or should I do it?

@davidcerny
Copy link
Contributor Author

That sounds doable; I've written tests before. I'll get right on it

@bredelings bredelings merged commit 3299dbc into development Apr 4, 2024
20 checks passed
@bredelings
Copy link
Contributor

Fixes #361

@bredelings
Copy link
Contributor

Nice test case.
Thanks for finding this!

@davidcerny
Copy link
Contributor Author

Thank you for solving the issue in a much more elegant way!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants