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: final_population_cleanup mishandles mutation counts if the only preserved generation is the final generation. #844

Closed
molpopgen opened this issue Nov 3, 2021 · 0 comments · Fixed by #845

Comments

@molpopgen
Copy link
Owner

molpopgen commented Nov 3, 2021

Work on #828 has discovered a bug when ancient samples are used along with stopping conditions. Given that stopping conditions have been an undocumented feature and that ancient samples are pretty well-tested, this bug hasn't hurt anyone. However, it is keeping #828 from passing certain tests.

There is a back-end bug in the final cleanup code. This case was missed in tests and in practice we've developed the habit of not recording in that generation, thus never triggering the bug.

This is the first example that we used to trigger the bug:

import numpy as np

import fwdpy11


def preserve(pop, sampler):
    if pop.generation == 10:
        sampler.assign(np.arange(pop.N, dtype=np.uint32))


def stopper(pop, _):
    if pop.generation == 10:
        return True
    return False


pdict = {
    "sregions": [fwdpy11.ExpS(0, 1, 1, -0.05, 1)],
    "gvalue": fwdpy11.Multiplicative(2.0),
    "rates": (0, 0.1, 0),
    "simlen": 20,
}
params = fwdpy11.ModelParams(**pdict)
pop = fwdpy11.DiploidPopulation(100, 1.0)
rng = fwdpy11.GSLrng(90210)

fwdpy11.evolvets(rng, pop, params, 100, recorder=preserve, stopping_criterion=stopper)

However, any recorder in a simulation w/a reasonably high mutation rate that preserves the last generation should also trigger it.

@molpopgen molpopgen added the bug label Nov 3, 2021
molpopgen added a commit that referenced this issue Nov 3, 2021
molpopgen added a commit that referenced this issue Nov 3, 2021
@molpopgen molpopgen changed the title Bug: ancient samples and stopping conditions. Bug: final_population_cleanup mishandles mutation counts in some cases. Nov 3, 2021
molpopgen added a commit that referenced this issue Nov 3, 2021
@molpopgen molpopgen changed the title Bug: final_population_cleanup mishandles mutation counts in some cases. Bug: final_population_cleanup mishandles mutation counts if the only preserved generation is the final generation. Nov 3, 2021
@molpopgen molpopgen linked a pull request Nov 3, 2021 that will close this issue
molpopgen added a commit that referenced this issue Nov 3, 2021
molpopgen added a commit that referenced this issue Nov 3, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant