Skip to content

Commit

Permalink
Add temporary debug function to track down where errors arise.
Browse files Browse the repository at this point in the history
  • Loading branch information
molpopgen committed Jan 30, 2021
1 parent afcfe74 commit 80689f1
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions fwdpy11/src/evolve_population/with_tree_sequences.cc
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,17 @@ simplification(
return simplification_rv;
}

void debug_mutation_table_consistency(const fwdpy11::DiploidPopulation & pop, std::string message)
{
for(auto & mr : pop.tables->mutations)
{
if(pop.mcounts[mr.key] + pop.mcounts_from_preserved_nodes[mr.key] == 0)
{
throw std::runtime_error(message);
}
}
}

void
final_population_cleanup(
bool suppress_edge_table_indexing, bool preserve_selected_fixations,
Expand All @@ -111,6 +122,7 @@ final_population_cleanup(
fwdpy11::DiploidPopulation &pop)
{
index_and_count_mutations(suppress_edge_table_indexing, simulating_neutral_variants, pop);
debug_mutation_table_consistency(pop, "index_and_count_mutations");
if (pop.generation == last_preserved_generation)
{
std::transform(begin(pop.mcounts_from_preserved_nodes),
Expand All @@ -119,6 +131,7 @@ final_population_cleanup(
begin(pop.mcounts_from_preserved_nodes),
std::minus<std::uint32_t>());
}
debug_mutation_table_consistency(pop, "after tweaking via last_preserved_generation_counts");
if (!preserve_selected_fixations)
{
auto itr = std::remove_if(
Expand Down

0 comments on commit 80689f1

Please sign in to comment.