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 authored Nov 22, 2024
1 parent a30f508 commit 0527741
Show file tree
Hide file tree
Showing 3 changed files with 44 additions and 2 deletions.
8 changes: 8 additions & 0 deletions doc/misc/changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,14 @@
Major changes are listed below. Each release likely contains fiddling with back-end code,
updates to latest `fwdpp` version, etc.

## 0.24.3

Bug fix:

* Raise error when simulating neutral mutations and
tracking mutation counts suppresses table indexing.
(PR {pr}`1342`)

## 0.24.2

Back end changes:
Expand Down
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 0527741

Please sign in to comment.