Skip to content

Commit 021bc13

Browse files
committed
Avoid type coercion due to numbe uint behaviour
This is not required when compiled with numba see numpy/numpy#20905
1 parent 569ed61 commit 021bc13

1 file changed

Lines changed: 3 additions & 1 deletion

File tree

‎sgkit/stats/hwe.py‎

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,9 @@ def hardy_weinberg_p_value(obs_hets: int, obs_hom1: int, obs_hom2: int) -> float
4747

4848
obs_homc = obs_hom2 if obs_hom1 < obs_hom2 else obs_hom1
4949
obs_homr = obs_hom1 if obs_hom1 < obs_hom2 else obs_hom2
50-
obs_mac = 2 * obs_homr + obs_hets
50+
# ensure obs_mac is integer to guard against https://github.com/numpy/numpy/issues/20905
51+
# (not an issue when compiled with numba)
52+
obs_mac = int(2 * obs_homr + obs_hets)
5153
obs_n = obs_hets + obs_homc + obs_homr
5254
het_probs = np.zeros(obs_mac + 1, dtype=np.float64)
5355

0 commit comments

Comments
 (0)