-
Notifications
You must be signed in to change notification settings - Fork 88
Allow Demography init from provenance with preset pop IDs #2370
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
base: main
Are you sure you want to change the base?
Conversation
7403228 to
28bf96b
Compare
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## main #2370 +/- ##
=======================================
Coverage 90.85% 90.85%
=======================================
Files 20 20
Lines 11993 12002 +9
Branches 2330 2332 +2
=======================================
+ Hits 10896 10905 +9
Misses 606 606
Partials 491 491
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
|
With this in place, you can plot a demes demography from a tree seq generated by stdpopsim, without having to install stedpopsim, know the model etc., which is neat: |
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.
I think we need a different way of instantiating Demography objects
| try: | ||
| demography_object.__init__(**obj) | ||
| except ValueError as e: | ||
| if str(e).startswith("Population ID should not be set"): |
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 control flow by exception logic is fragile and distributes the logic of creating Demography objects around different modules. We should add a Demography.fromdict method that does this, and can be tested independently;.
The last step to allow demographies to be instantiated from provenance entries. We exceptionally allow a
demography.Populationobject to be created with an existing ID, but only if generated when decoding provenance JSON. This ensures that the IDs in the events etc match with what we expect. It's a slight hack in that we check for the error message. The alternative is to pick a different error (?RuntimeError) or make our own bespoke error that can be allowed through in this case.