Skip to content

Commit

Permalink
tweak to bincount
Browse files Browse the repository at this point in the history
  • Loading branch information
petrelharp authored and mergify[bot] committed Jul 20, 2022
1 parent 33df3ca commit c12c160
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions python/tskit/genotypes.py
Original file line number Diff line number Diff line change
Expand Up @@ -256,9 +256,9 @@ def counts(self) -> typing.Counter[str | None]:
for i, allele in enumerate(self.alleles[:-1]):
counts[allele] = np.sum(self.genotypes == i)
else:
bincounts = np.bincount(self.genotypes)
bincounts = np.bincount(self.genotypes, minlength=self.num_alleles)
for i, allele in enumerate(self.alleles):
counts[allele] = bincounts[i] if i < len(bincounts) else 0
counts[allele] = bincounts[i]
return counts

def frequencies(self, remove_missing=None) -> dict[str, float]:
Expand Down

0 comments on commit c12c160

Please sign in to comment.