Skip to content

Commit e12bcb1

Browse files
committed
update pytests
1 parent 334dd9e commit e12bcb1

File tree

1 file changed

+13
-32
lines changed

1 file changed

+13
-32
lines changed

tests/test_ancestry.py

Lines changed: 13 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -890,15 +890,23 @@ def test_str(self):
890890
s = str(sim)
891891
assert len(s) > 0
892892

893-
@pytest.mark.parametrize("model", ["dtwf", "hudson"])
893+
@pytest.mark.parametrize(
894+
"model",
895+
[
896+
"dtwf",
897+
"hudson",
898+
msprime.BetaCoalescent(alpha=1.5),
899+
msprime.DiracCoalescent(psi=0.1, c=2),
900+
],
901+
)
894902
def test_simulate_after_local_mrca(self, model):
895903
"""
896904
Tests that simulations run after the local MRCA when the flag is set
897905
"""
898906
end_time = 1000
899907
ts = msprime.sim_ancestry(
900908
10,
901-
population_size=100,
909+
population_size=10,
902910
stop_at_local_mrca=False,
903911
end_time=end_time,
904912
random_seed=1,
@@ -907,17 +915,9 @@ def test_simulate_after_local_mrca(self, model):
907915
model=model,
908916
)
909917

910-
old_time = None
911-
for tree in ts.trees():
912-
assert len(tree.roots) == 1 # otherwise the test is not valid
913-
u = tree.roots[0]
914-
assert (
915-
tree.time(u) >= end_time
916-
) # makes sure that local simulations only stop at end time
917-
if old_time is None:
918-
old_time = tree.time(u)
919-
# check that end time is the same for all roots
920-
assert tree.time(u) == old_time
918+
root_times = [tree.time(tree.root) for tree in ts.trees()]
919+
assert len(set(root_times)) == 1
920+
assert root_times[0] >= end_time
921921

922922

923923
class TestParseRandomSeed:
@@ -2578,25 +2578,6 @@ def test_stop_at_local_mrca(self, model):
25782578
):
25792579
msprime.sim_ancestry(2, stop_at_local_mrca=False, end_time=3)
25802580

2581-
msprime.sim_ancestry(
2582-
2,
2583-
population_size=100,
2584-
stop_at_local_mrca=False,
2585-
recombination_rate=0.1,
2586-
sequence_length=10,
2587-
end_time=3,
2588-
model=model,
2589-
)
2590-
msprime.sim_ancestry( # gene conversion is not allowed for dtwf model
2591-
2,
2592-
population_size=100,
2593-
stop_at_local_mrca=False,
2594-
gene_conversion_rate=0.01,
2595-
gene_conversion_tract_length=10,
2596-
sequence_length=10,
2597-
end_time=3,
2598-
)
2599-
26002581

26012582
class TestSimulateInterface:
26022583
"""

0 commit comments

Comments
 (0)