Skip to content

Commit

Permalink
Raise error when simulations w/neutral mutations are badly specified
Browse files Browse the repository at this point in the history
  • Loading branch information
molpopgen committed Nov 22, 2024
1 parent a30f508 commit c5f63b8
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 2 deletions.
4 changes: 2 additions & 2 deletions lib/evolve_discrete_demes/evolvets.cc
Original file line number Diff line number Diff line change
Expand Up @@ -255,12 +255,12 @@ evolve_with_tree_sequences(
{
if (options.track_mutation_counts_during_sim)
{
if (simplification_interval != 1)
if (simplification_interval != 1 or options.suppress_edge_table_indexing == true)
{
throw std::invalid_argument(
"when track_mutation_counts is True and simulating "
"neutral mutations, the simplification interval must be "
"1");
"1 and edge table indexing must not be suppressed");
}
}
}
Expand Down
34 changes: 34 additions & 0 deletions tests/test_tree_sequences_with_neutral_mutations.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
import unittest

import numpy as np
import pytest

import fwdpy11
from test_tree_sequences import set_up_quant_trait_model, set_up_standard_pop_gen_model
Expand Down Expand Up @@ -183,5 +184,38 @@ def test_trigger_final_simplification_with_fixations_to_remove():
)


def test_track_mutation_counts():
burnin = 10
N = 100
pdict = {
# Add a region for neutral mutations:
"nregions": [fwdpy11.Region(0, 1, 1)],
"sregions": [fwdpy11.ExpS(beg=0, end=1, weight=1, mean=0.2)],
"recregions": [fwdpy11.PoissonInterval(0, 1, 1e-2)],
"gvalue": [fwdpy11.Multiplicative(2.0)],
"rates": (1e-3, 1e-3, None),
"simlen": burnin * N,
"demography": fwdpy11.ForwardDemesGraph.tubes(
[N], burnin=10 * N, burnin_is_exact=True
),
"prune_selected": True,
}
params = fwdpy11.ModelParams(**pdict)
pop = fwdpy11.DiploidPopulation(N, 1.0)
rng = fwdpy11.GSLrng(54321)

with pytest.raises(ValueError):
fwdpy11.evolvets(
rng,
pop,
params,
1,
# This is the bad thing...
suppress_table_indexing=True,
# ...combined with this
track_mutation_counts=True,
)


if __name__ == "__main__":
unittest.main()

0 comments on commit c5f63b8

Please sign in to comment.