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

Bug: order of demes with same start times #990

Closed
molpopgen opened this issue Oct 5, 2022 · 0 comments
Closed

Bug: order of demes with same start times #990

molpopgen opened this issue Oct 5, 2022 · 0 comments

Comments

@molpopgen
Copy link
Owner

molpopgen commented Oct 5, 2022

There is a problem with importing demes models:

  • If two demes have the same start time, they will be sorted lexically by name.
  • This is not correct -- we wish to respect the order in which the demes appear in the file. This order should be the "natural" order of the file -- for the same start time, we use the order given by the iterator in Python.

A minimal example is:

import fwdpy11
import demes

yaml = """
description: single deme model
time_units: generations
demes:
 - name: B
   epochs:
    - start_size: 100
 - name: A
   epochs:
    - start_size: 100
"""

demes_model = demes.loads(yaml)

for g in demes_model.demes:
    print(g.name)

# No burn-in
fp11_model = fwdpy11.discrete_demography.from_demes(demes_model, 0)

print(fp11_model.metadata)

The output is:

python model.py
B
A
{'deme_labels': {0: 'A', 1: 'B'}, 'initial_sizes': {1: 100, 0: 100}, 'burnin_time': 0, 'total_simulation_length': 0}
molpopgen added a commit that referenced this issue Oct 5, 2022
* Add test of deme ID after import.
* Change mapping deme name -> ID to only depend on sorted start_time.
* Fixes #990
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant