Skip to content

Commit

Permalink
Check for valid input in ARG likelihood
Browse files Browse the repository at this point in the history
  • Loading branch information
Jere Koskela authored and Jere Koskela committed Oct 17, 2022
1 parent 360dfec commit c25eb93
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions msprime/likelihood.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@
"""
import math

import numpy as np

from msprime import _msprime


Expand Down Expand Up @@ -136,6 +138,14 @@ def log_arg_likelihood(ts, recombination_rate, Ne=1):
sequence contains at least one recombination event, then returns
`-DBL_MAX`.
"""
for tree in ts.trees():
if np.any(tree.num_children_array > 2):
raise ValueError(
"ARG likelihood encountered a polytomy."
" Tree sequences must contain binary mergers only for"
" valid likelihood evaluation."
)

# Get the tables into the format we need to interchange with the low-level code.
lw_tables = _msprime.LightweightTableCollection()
lw_tables.fromdict(ts.tables.asdict())
Expand Down

0 comments on commit c25eb93

Please sign in to comment.