Skip to content

Commit

Permalink
Refactor site sums
Browse files Browse the repository at this point in the history
  • Loading branch information
szhan committed Mar 11, 2024
1 parent 663b5db commit cb323a0
Showing 1 changed file with 3 additions and 4 deletions.
7 changes: 3 additions & 4 deletions python/tests/beagle_numba.py
Original file line number Diff line number Diff line change
Expand Up @@ -585,10 +585,9 @@ def interpolate_allele_probs(
if max(sum_probs_a_k, sum_probs_a_kM1) > _MIN_THRESHOLD:
probs[i, a] += w * sum_probs_a_kM1
probs[i, a] += (1 - w) * sum_probs_a_k
# Rescale probabilities.
# TODO: Check if this is necessary. Could this be a subtle source of error?
assert np.all(np.sum(probs, axis=1) > 0), "Sum of allele probabilities is not > 0."
probs_rescaled = probs / np.sum(probs, axis=1)[:, np.newaxis]
site_sums = np.sum(probs, axis=1)
assert np.all(site_sums > 0), "Some site sums of allele probabilities is <= 0."
probs_rescaled = probs / site_sums[:, np.newaxis]
if return_weights:
return (probs_rescaled, weights)
return (probs_rescaled, None)
Expand Down

0 comments on commit cb323a0

Please sign in to comment.