本文整理匯總了Python中cogent.seqsim.usage.Probs.isValid方法的典型用法代碼示例。如果您正苦於以下問題:Python Probs.isValid方法的具體用法?Python Probs.isValid怎麽用?Python Probs.isValid使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類cogent.seqsim.usage.Probs
的用法示例。
在下文中一共展示了Probs.isValid方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: test_isValid
# 需要導入模塊: from cogent.seqsim.usage import Probs [as 別名]
# 或者: from cogent.seqsim.usage.Probs import isValid [as 別名]
def test_isValid(self):
"""Probs isValid should return True if it's a prob matrix"""
a = self.ab_pairs
m = Probs([0.5,0.5,1,0], a)
self.assertEqual(m.isValid(), True)
#fails if don't sum to 1
m = Probs([0.5, 0, 1, 0], a)
self.assertEqual(m.isValid(), False)
#fails if negative elements
m = Probs([1, -1, 0, 1], a)
self.assertEqual(m.isValid(), False)
示例2: test_toRates
# 需要導入模塊: from cogent.seqsim.usage import Probs [as 別名]
# 或者: from cogent.seqsim.usage.Probs import isValid [as 別名]
def test_toRates(self):
"""Probs toRates should return log of probs, optionally normalized"""
a = Alphabet('abc')**2
p = Probs([0.9,0.05,0.05,0.1,0.85,0.05,0.02,0.02,0.96], a)
assert p.isValid()
r = p.toRates()
assert isinstance(r, Rates)
assert r.isValid()
assert not r.isComplex()
self.assertEqual(r._data, logm(p._data))
r_norm = p.toRates(normalize=True)
self.assertFloatEqual(trace(r_norm._data), -1.0)