Skip to content

Remap individuals after union - #1238

Merged
mergify[bot] merged 2 commits into
tskit-dev:mainfrom
benjeffery:union-remap
Mar 15, 2021
Merged

mergify[bot] merged 2 commits into
tskit-dev:mainfrom
benjeffery:union-remap

Conversation

@benjeffery

@benjeffery benjeffery commented Mar 10, 2021 •

Copy link
Copy Markdown
Member

Fixes #1225.

@codecov

codecov Bot commented Mar 10, 2021 •

Copy link
Copy Markdown

Codecov Report

Merging #1238 (701112a) into main (94e2b94) will increase coverage by 0.02%.
The diff coverage is 100.00%.

Impacted file tree graph

@@            Coverage Diff             @@
##             main    #1238      +/-   ##
==========================================
+ Coverage   93.74%   93.76%   +0.02%     
==========================================
  Files          26       26              
  Lines       21781    21792      +11     
  Branches      963      963              
==========================================
+ Hits        20418    20433      +15     
+ Misses       1321     1318       -3     
+ Partials       42       41       -1     
Flag Coverage Δ
c-tests 92.49% <100.00%> (+0.02%) ⬆️
lwt-tests 92.97% <ø> (ø)
python-c-tests 94.98% <ø> (+0.01%) ⬆️
python-tests 98.65% <ø> (+0.03%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

Impacted Files Coverage Δ
c/tskit/tables.c 90.89% <100.00%> (+0.05%) ⬆️
python/tskit/drawing.py 99.07% <0.00%> (+0.23%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 94e2b94...701112a. Read the comment docs.

Comment thread c/tskit/tables.c Outdated
memset(site_map, 0xff, other->sites.num_rows * sizeof(*site_map));

for (k = 0; k < (tsk_id_t) other->individuals.num_rows; k++) {
individual_map[k] = TSK_NULL;

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

isn't this taken care of by the memset above?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah of course!

@petrelharp

Copy link
Copy Markdown
Contributor

This looks right to me! Thanks!!

@benjeffery

Copy link
Copy Markdown
Member Author

Just realised this isn't right as we should only remap the new individuals.

@benjeffery benjeffery changed the title First stab First stab at remap individuals after union Mar 11, 2021
@jeromekelleher

Copy link
Copy Markdown
Member

Maybe a few test cases in Python would help clarify what is required here?

@petrelharp

Copy link
Copy Markdown
Contributor

Oh, right - I guess the individual parent remapping needs to happen during add_and_remap_node. Oh, wait, that won't work, because we don't know if we'll hit parent nodes before children. Gah, this stuff is terrible.

Maybe the easiest thing is to separate out building the node table from building the individual table? First loop over nodes and build the individual map but don't actually add the rows to the individual table; then go through afterwards and add in the individuals?

@benjeffery

Copy link
Copy Markdown
Member Author

I think I have it now - remap after all the add_and_remap_node calls, but only loop over the new individuals. Should have a PR with tests tonight.

@benjeffery
benjeffery marked this pull request as ready for review March 12, 2021 12:09
@benjeffery

Copy link
Copy Markdown
Member Author

Testing this is making me think wf_sim should always default to record_individuals=True. I'm going through the test failures from that now.

@benjeffery

Copy link
Copy Markdown
Member Author

I've just pushed a commit that does this, and it required changing tests to check the metadata of individuals. Seems a good change.

@benjeffery benjeffery changed the title First stab at remap individuals after union Remap individuals after union Mar 12, 2021
@benjeffery

Copy link
Copy Markdown
Member Author

@hyanwong getting an svg error here. Is it possible the svg isn't deterministic?

@hyanwong

Copy link
Copy Markdown
Member

@hyanwong getting an svg error here. Is it possible the svg isn't deterministic?

What's the error? I can't imagine how SVG creation would fail to be deterministic, although I guess it could depend on something unexpected such as e.g. the node order. I'll double-check that the test suite uses random seeds for all the generated tree.I had some SVG changes when switching to the new msprime version, so of which seemed like differences in floating point rounding (although I have no idea why that might happen in this case)

@benjeffery

Copy link
Copy Markdown
Member Author

Ahhh, the nodes have individual classes! And as this PR adds individuals by default to wf sim the svg has changed. False alarm!

@hyanwong

Copy link
Copy Markdown
Member

Phew. If the sim has changed, you can overwrite the old SVG file like this:

pytest tests/test_drawing.py::TestDrawSvg::test_known_svg_ts_multiroot --overwrite-expected-visualizations

@benjeffery

Copy link
Copy Markdown
Member Author

Yeah, that flag is awesome!

@mergify
mergify Bot merged commit 44b3ff7 into tskit-dev:main Mar 15, 2021
@benjeffery
benjeffery deleted the union-remap branch March 15, 2021 11:56
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.

union needs to remap individual parent IDs

4 participants