Skip to content

Commit

Permalink
check mutations are added at the correct time; closes #1496 (#1627)
Browse files Browse the repository at this point in the history
  • Loading branch information
petrelharp authored Dec 23, 2024
1 parent b845b62 commit dc30adb
Showing 1 changed file with 24 additions and 0 deletions.
24 changes: 24 additions & 0 deletions tests/test_slim_engine.py
Original file line number Diff line number Diff line change
Expand Up @@ -321,6 +321,30 @@ def test_recap_and_rescale_on_external_slim_run(self, tmp_path):
assert tables1.edges == tables2.edges
assert tables1.mutations == tables2.mutations

def test_recap_start_time(self):
# check that the correct time to start adding mutations from
# is actually the value recorded in metadata (whether it is or
# differs by 1 or 2 depends on the stages in which the simulation
# is set up and written out; see pyslim:#308
engine = stdpopsim.get_engine("slim")
species = stdpopsim.get_species("AnaPla")
contig = species.get_contig(length=1e3)
model = stdpopsim.PiecewiseConstantSize(100)
samples = {"pop_0": 10}
ts = engine.simulate(
demographic_model=model,
contig=contig,
samples=samples,
slim_burn_in=3,
_recap_and_rescale=False,
)
root_times = set([ts.node(n).time for t in ts.trees() for n in t.roots])
assert root_times == set(
[
ts.metadata["SLiM"]["cycle"],
]
)

def test_assert_min_version(self):
engine = stdpopsim.get_engine("slim")
with mock.patch(
Expand Down

0 comments on commit dc30adb

Please sign in to comment.