Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Tau returns none if there is no expression in the profile
  • Loading branch information
proost committed Oct 25, 2016
1 parent be16ce4 commit 712efa4
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
1 change: 1 addition & 0 deletions tests/utils.py
Expand Up @@ -10,6 +10,7 @@ class UtilsTest(TestCase):
def test_tau(self):
self.assertEqual(tau([1, 0, 0, 0, 0, 0]), 1)
self.assertEqual(tau([1, 1, 1, 1, 1, 1]), 0)
self.assertEqual(tau([0, 0, 0, 0, 0, 0]), None)
self.assertEqual("%.2f" % tau([0, 8, 0, 0, 0, 2, 0, 2, 0, 0, 0, 0]), "0.95") # example from Yanai et al. 2005

def test_entropy(self):
Expand Down
7 changes: 5 additions & 2 deletions utils/tau.py
Expand Up @@ -8,6 +8,9 @@ def tau(values):
n = len(values) # number of values
mxi = max(values) # max value

t = sum([1 - (x/mxi) for x in values])/(n - 1)
if mxi > 0:
t = sum([1 - (x/mxi) for x in values])/(n - 1)

return t
return t
else:
return None

0 comments on commit 712efa4

Please sign in to comment.