Skip to content

Commit

Permalink
run tests over range of parameters
Browse files Browse the repository at this point in the history
  • Loading branch information
molpopgen committed Jan 26, 2021
1 parent 6ad3471 commit b4a64c7
Showing 1 changed file with 24 additions and 13 deletions.
37 changes: 24 additions & 13 deletions tests/test_ancient_samples_with_neutral_mutations.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,15 +52,14 @@ def __call__(self, pop):
@pytest.fixture(
scope="function",
params=[
{"simlen": 10, "nregions": [], "rates": (0.0, 0.025, None)},
{"nregions": [], "rates": (0.0, 0.025, None)},
{
"simlen": 10,
"nregions": [fwdpy11.Region(0.0, 1.0, 1.0)],
"rates": (0.025, 0.025, None),
},
],
)
def params(request):
def pdict(request):
"""
Build models w/ and w/o neutral mutations.
"""
Expand All @@ -71,9 +70,8 @@ def params(request):
"gvalue": [fwdpy11.Multiplicative(2.0)],
"rates": request.param["rates"],
"demography": fwdpy11.DiscreteDemography(),
"simlen": request.param["simlen"],
}
return fwdpy11.ModelParams(**pd)
return pd


def make_counter():
Expand All @@ -92,20 +90,36 @@ def resetter(request):
return request.param()()


@pytest.fixture(params=[5, 10, 25, 33, 50, 73, 100, 101])
def simlen(request):
return request.param


@pytest.fixture(params=[1, 2, 5, 10, 33])
def simplification_inteval(request):
return request.param


@pytest.mark.parametrize("rng", [{"seed": 101 * 45 * 110 * 210}], indirect=True)
@pytest.mark.parametrize("mslike_pop", [{"N": 200}], indirect=True)
def test_ancient_samples_and_neutral_mutations(params, rng, mslike_pop, resetter):
@pytest.mark.parametrize(
"mslike_pop", [{"N": 50}, {"N": 100}, {"N": 200}], indirect=True
)
def test_ancient_samples_and_neutral_mutations(
pdict, simlen, simplification_inteval, rng, mslike_pop, resetter
):
"""
The test involving neutral mutations test GitHub issue 639 and 646
"""
ancient_sample_recorder = fwdpy11.RandomAncientSamples(
seed=42, samplesize=10, timepoints=[i for i in range(1, 101)]
seed=42, samplesize=10, timepoints=[i for i in range(1, simlen + 1)]
)
pdict["simlen"] = simlen
params = fwdpy11.ModelParams(**pdict)
fwdpy11.evolvets(
rng,
mslike_pop,
params,
5,
simplification_inteval,
recorder=ancient_sample_recorder,
post_simplification_recorder=resetter,
)
Expand All @@ -114,13 +128,10 @@ def test_ancient_samples_and_neutral_mutations(params, rng, mslike_pop, resetter
assert len(mslike_pop.tables.preserved_nodes) == 0
assert len(mslike_pop.ancient_sample_metadata) == 0

# FIXME: check that the number of sampled time points is correct?
for _, j in resetter.timepoint_seen.items():
assert j == 1

assert resetter.sample_timepoints == [
float(i) for i in range(1, params.simlen + 1)
]

assert all([i == 10 for i in resetter.sample_sizes]) is True
else:
assert (
Expand Down

0 comments on commit b4a64c7

Please sign in to comment.