Skip to content

Commit

Permalink
Ruff formatting for entropy file
Browse files Browse the repository at this point in the history
  • Loading branch information
alneberg committed Jan 23, 2024
1 parent 776b146 commit 73533b5
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions anglerfish/explore/entropy.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@

import numpy as np


# Rolling window implementation
def _window(seq, n=3):
win = deque(maxlen=n)
Expand All @@ -14,12 +15,12 @@ def _window(seq, n=3):

def _entropy(pk, qk):
"""
Kullback-Leibler divergence (relative entropy)
Kullback-Leibler divergence (relative entropy)
Reference https://docs.scipy.org/doc/scipy/reference/generated/scipy.stats.entropy.html
"""
if np.sum(pk) - 1 > 1e-5:
pk = pk / np.sum(pk)
return np.sum(pk * np.log(pk/qk))
return np.sum(pk * np.log(pk / qk))


# Each sequence gives matrix of position and k-mer occurence.
Expand Down

0 comments on commit 73533b5

Please sign in to comment.