Skip to content

Add Demography.to_demes().#1724

Merged
mergify[bot] merged 4 commits into
tskit-dev:mainfrom
grahamgower:to_demes
Jun 22, 2021
Merged

Add Demography.to_demes().#1724
mergify[bot] merged 4 commits into
tskit-dev:mainfrom
grahamgower:to_demes

Conversation

@grahamgower
Copy link
Copy Markdown
Member

Closes #1721.


WIP, but seems to be behaving itself. At least, conversion of the Demography._*_model() models look correct when plotting them with demesdraw.

@codecov
Copy link
Copy Markdown

codecov Bot commented Jun 11, 2021

Codecov Report

Merging #1724 (eb293bb) into main (48f2c93) will increase coverage by 0.24%.
The diff coverage is 100.00%.

❗ Current head eb293bb differs from pull request most recent head 8eac2d7. Consider uploading reports for the commit 8eac2d7 to get more accurate results
Impacted file tree graph

@@            Coverage Diff             @@
##             main    #1724      +/-   ##
==========================================
+ Coverage   91.14%   91.38%   +0.24%     
==========================================
  Files          20       20              
  Lines       10271    10393     +122     
  Branches     2159     2200      +41     
==========================================
+ Hits         9361     9498     +137     
+ Misses        468      454      -14     
+ Partials      442      441       -1     
Flag Coverage Δ
C 91.38% <100.00%> (+0.24%) ⬆️
python 98.49% <100.00%> (+0.46%) ⬆️

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

Impacted Files Coverage Δ
msprime/demography.py 99.41% <100.00%> (+0.04%) ⬆️
lib/msprime.c 85.65% <0.00%> (ø)
msprime/ancestry.py 98.72% <0.00%> (+<0.01%) ⬆️
msprime/provenance.py 83.49% <0.00%> (+1.94%) ⬆️
msprime/pedigrees.py 94.44% <0.00%> (+7.22%) ⬆️

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 48f2c93...8eac2d7. Read the comment docs.

Copy link
Copy Markdown
Member

@jeromekelleher jeromekelleher left a comment

Choose a reason for hiding this comment

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

Looks good - is it worth letting the DemographyDebugger do some of the heavy lifting though? It's a good way of avoiding some of the multiple implementations of the event logic.

Comment thread msprime/demography.py
Comment thread msprime/demography.py Outdated
Comment thread msprime/demography.py
@grahamgower
Copy link
Copy Markdown
Member Author

I updated to use the demography debugger for the migration matrices, and to get the deme start/end times with respect to the population's ACTIVE state. It's also desirable to check start/end times of demes based on mass migrations with proportion 1, to support legacy models, so I've left that in. Also, the big loop still iterates the events rather than the demography debugger epochs --- there's some quirk with the granularity of times returned by the demography debugger epochs such that the round tripping gives problems. I don't think it's worth the effort to try and figure that out just to shuffle a couple of lines of code.

@grahamgower
Copy link
Copy Markdown
Member Author

Oh, and I updated the docstring to mention the bottleneck events can't be converted, and that legacy models could be misspecified and in general may not be convertible.

Copy link
Copy Markdown
Member

@jeromekelleher jeromekelleher left a comment

Choose a reason for hiding this comment

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

Looks great, thanks @grahamgower. One tiny typo spotted.

I'm generally a bit uneasy about how much logic is going in here, but I guess it can't be avoided unless we somehow modified the low-level C code to emit a demes model through the debug interface.

Comment thread msprime/demography.py Outdated
@grahamgower
Copy link
Copy Markdown
Member Author

Typo fixed, rebased, and lightly squashed.

@jeromekelleher
Copy link
Copy Markdown
Member

Ah, sorry - can you update the CHANGELOG with this please? This is a big feature, don't want to forget about it on release.

@grahamgower
Copy link
Copy Markdown
Member Author

Changelog updated.

@mergify mergify Bot merged commit d7a34f0 into tskit-dev:main Jun 22, 2021
@grahamgower grahamgower deleted the to_demes branch July 29, 2021 12:02
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.

add Demography.to_demes()

2 participants