Skip to content

Commit 8c464f3

Browse files
correction merg_n_ancestors
1 parent 836510b commit 8c464f3

2 files changed

Lines changed: 28 additions & 7 deletions

File tree

lib/msprime.c

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3280,14 +3280,16 @@ msp_merge_n_ancestors(msp_t *self, avl_tree_t *Q, population_id_t population_id,
32803280

32813281
if (num_common_ancestors == 1) {
32823282
merged_head = msp_priority_queue_pop(self, Q);
3283-
if (self->store_unary && self->model.type == MSP_MODEL_DTWF) {
3284-
ret = msp_store_node(
3285-
/*FIXME: not a CA_EVENT but PASS_THROUGH_EVENT*/
3286-
self, MSP_NODE_IS_CA_EVENT, self->time, population_id, TSK_NULL);
3287-
if (ret < 0) {
3288-
goto out;
3283+
if (self->store_unary) {
3284+
if (self->model.type == MSP_MODEL_DTWF) {
3285+
ret = msp_store_node(
3286+
/*FIXME: not a CA_EVENT but PASS_THROUGH_EVENT*/
3287+
self, MSP_NODE_IS_CA_EVENT, self->time, population_id, TSK_NULL);
3288+
if (ret < 0) {
3289+
goto out;
3290+
}
32893291
}
3290-
ret = msp_store_arg_edges(self, merged_head, TSK_NULL);
3292+
ret = msp_store_arg_edges(self, merged_head, new_node_id);
32913293
if (ret < 0) {
32923294
goto out;
32933295
}

tests/test_pedigree.py

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1548,6 +1548,25 @@ def test_pedigree_unary(self):
15481548
)
15491549
self.verify_pedigree_unary(ts)
15501550

1551+
def test_pedigree_unary_simple(self):
1552+
sequence_length = 100
1553+
pb = msprime.PedigreeBuilder()
1554+
mmid = pb.add_individual(time=2)
1555+
mdid = pb.add_individual(time=2)
1556+
dmid = pb.add_individual(time=2)
1557+
ddid = pb.add_individual(time=2)
1558+
mid = pb.add_individual(time=1, parents=[mmid, mdid])
1559+
did = pb.add_individual(time=1, parents=[dmid, ddid])
1560+
pb.add_individual(time=0, parents=[mid, did], is_sample=True)
1561+
pedigree = pb.finalise(sequence_length)
1562+
ts = msprime.sim_ancestry(
1563+
recombination_rate=0.1,
1564+
model="fixed_pedigree",
1565+
record_unary=True,
1566+
initial_state=pedigree,
1567+
)
1568+
self.verify_pedigree_unary(ts)
1569+
15511570
def verify_pedigree_unary(self, ts):
15521571
direct_ancestors = [set() for _ in range(ts.num_nodes)]
15531572

0 commit comments

Comments
 (0)