Skip to content

Commit 0fc8eb6

Browse files
committed
Fix diversity
1 parent 7d10ae4 commit 0fc8eb6

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

sgkit/stats/popgen.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -92,12 +92,12 @@ def diversity(
9292

9393
ac = ds[cohort_allele_count]
9494
an = ac.sum(axis=2)
95-
n_pairs = an * (an - 1) / 2
96-
n_same = (ac * (ac - 1) / 2).sum(axis=2)
95+
n_pairs = an * (an - 1) // 2
96+
n_same = (ac * (ac - 1) // 2).sum(axis=2)
9797
n_diff = n_pairs - n_same
9898
# replace zeros to avoid divide by zero error
9999
n_pairs_na = n_pairs.where(n_pairs != 0)
100-
pi = n_diff / n_pairs_na
100+
pi = n_diff.astype(np.float64) / n_pairs_na.astype(np.float64)
101101

102102
if has_windows(ds):
103103
div = window_statistic(

0 commit comments

Comments
 (0)