-
Notifications
You must be signed in to change notification settings - Fork 79
make subset and canonicalise deal with individual parents #1226
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
|
This would close #1223. |
c3be9ec to
5efbb17
Compare
|
Well, this is bothersome: I get some VCF-related errors: that are apparently triggered by having individual parents - removing these two lines from Edit: oh, I see - it's not actually because of the individual parents, it's just because it changed the randomness, and we happened to get a ploidy-zero individual, i.e., one without any nodes. |
Codecov Report
@@ Coverage Diff @@
## main #1226 +/- ##
==========================================
- Coverage 93.76% 93.76% -0.01%
==========================================
Files 26 26
Lines 21798 21907 +109
Branches 962 962
==========================================
+ Hits 20439 20541 +102
- Misses 1318 1325 +7
Partials 41 41
Flags with carried forward coverage won't be shown. Click here to find out more.
Continue to review full report at Codecov.
|
|
I think this is ready for review - @benjeffery? |
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.
Looks great, thanks for working all this out @petrelharp! Some minor comments.
|
Codecov is complaining, but not for a good reason, I think. |
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.
Love it, looks great. A couple of minor clarification points on naming things, but good to merge after squash I think.
c/tskit/tables.c
Outdated
| static int | ||
| tsk_table_sorter_sort_individuals(tsk_table_sorter_t *self) | ||
| tsk_individual_table_count_descendants( | ||
| tsk_individual_table_t *self, tsk_size_t *num_descendants, tsk_id_t *traversal_order) |
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.
This is nitpicking, but we'd normally put any optional arguments last - you'd never pass in NULL for traversal_order, right?
c/tskit/tables.c
Outdated
| ret = TSK_ERR_NO_MEMORY; | ||
| goto out; | ||
| } | ||
| memset(new_id_map, 0xff, num_individuals * sizeof(tsk_id_t)); |
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.
Might as well use sizeof(*new_id_map)) here for consistency with mallocs above
c/tskit/tables.c
Outdated
|
|
||
| static int | ||
| tsk_table_sorter_sort_individuals(tsk_table_sorter_t *self) | ||
| tsk_individual_table_count_descendants( |
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.
Hmm, it's not just counting descendents though. How about tsk_individual_table_topological_sort? This returns a topological sorting of the individuals and optionally a count of their descendents.
benjeffery
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.
Brilliant stuff! Once JKs comments are resolved we can merge and release!
python/tests/test_tables.py
Outdated
| assert tables2.mutations.num_rows == 0 | ||
|
|
||
| def test_doesnt_reorder_individuals(self): | ||
| tables = wf.wf_sim(N=5, ngens=5, num_pops=2, seed=123, record_individuals=True) |
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.
Record individuals is now the default since #1238
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.
Thought so, but I didn't see it... oh, I need to rebase.
3f8717e to
1e173f0
Compare
|
There's some kind of bug; I'm tracking it down. |
| ): | ||
| individuals.parents[i] = ind_map[individuals.parents[i]] | ||
| new_parents[i] = ind_map[individuals.parents[i]] | ||
| individuals.parents = new_parents |
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.
doh!!! This was the error.
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.
Gah, that looks like my bad, sorry! I thought this would have been caught by the tests. Also a good argument for allowing assignment in the tables api.
python/tests/test_tables.py
Outdated
| def verify_union_consistency(self, tables, other, node_mapping): | ||
| ts1 = tsutil.insert_unique_metadata(tables) | ||
| ts2 = tsutil.insert_unique_metadata(other, offset=1000000) | ||
| for tsk in [False, True]: |
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.
This is checking both the tskit union and py_union for consistency; we don't need to do that now that they both pass, I guess - but I did this to find the error in py_union.
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.
These are great and close #1243
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.
oh sweet
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.
To really close that one we should tests mutations and sites too; I've done this and updated.
|
I did a much more thorough test for consistency of union; it took longer than expected, but it's a good test. Hopefully everything passes, now? |
|
All looks good, will merge and release tomorrow! |
canonicalise sorts on (num descendants, earliest referring node)
9ab6723 to
f48a9ee
Compare
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, let's merge and ship!
As discussed in #1199, the plan is for
WIP.