当前位置: 首页>>代码示例>>Python>>正文


Python Probs.random方法代码示例

本文整理汇总了Python中cogent.seqsim.usage.Probs.random方法的典型用法代码示例。如果您正苦于以下问题:Python Probs.random方法的具体用法?Python Probs.random怎么用?Python Probs.random使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在cogent.seqsim.usage.Probs的用法示例。


在下文中一共展示了Probs.random方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: test_random_p_matrix_diag_vector

# 需要导入模块: from cogent.seqsim.usage import Probs [as 别名]
# 或者: from cogent.seqsim.usage.Probs import random [as 别名]
 def test_random_p_matrix_diag_vector(self):
     """Probs random should work with a vector diagonal"""
     for i in range(NUM_TESTS):
         diag = [0, 0.2, 0.6, 1.0]
         p = Probs.random(RnaPairs, diag)._data
         for i, d, row in zip(range(4), diag, p):
             self.assertFloatEqual(sum(row), 1.0)
             self.assertEqual(row[i], diag[i])
开发者ID:GavinHuttley,项目名称:pycogent,代码行数:10,代码来源:test_usage.py

示例2: test_random_p_matrix

# 需要导入模块: from cogent.seqsim.usage import Probs [as 别名]
# 或者: from cogent.seqsim.usage.Probs import random [as 别名]
 def test_random_p_matrix(self):
     """Probs random should return random Probsrows that sum to 1"""
     for i in range(NUM_TESTS):
         p = Probs.random(RnaPairs)._data
         for i in p:
             self.assertFloatEqual(sum(i), 1.0)
         #length should be 4 by default
         self.assertEqual(len(p), 4)
         self.assertEqual(len(p[0]), 4)
开发者ID:GavinHuttley,项目名称:pycogent,代码行数:11,代码来源:test_usage.py

示例3: test_random_p_matrix_diag

# 需要导入模块: from cogent.seqsim.usage import Probs [as 别名]
# 或者: from cogent.seqsim.usage.Probs import random [as 别名]
 def test_random_p_matrix_diag(self):
     """Probs random should work with a scalar diagonal"""
     #if diagonal is 1, off-diagonal elements should be 0
     for i in range(NUM_TESTS):
         p = Probs.random(RnaPairs, 1)._data
         self.assertEqual(p, identity(4, 'd'))
     #if diagonal is between 0 and 1, rows should sum to 1
     for i in range(NUM_TESTS):
         p = Probs.random(RnaPairs, 0.5)._data
         for i in range(4):
             self.assertFloatEqual(sum(p[i]), 1.0)
             self.assertEqual(p[i][i], 0.5)
             assert min(p[i]) >= 0
             assert max(p[i]) <= 1
     #if diagonal > 1, rows should still sum to 1
     for i in range(NUM_TESTS):
         p = Probs.random(RnaPairs, 2)._data
         for i in range(4):
             self.assertEqual(p[i][i], 2.0)
             self.assertFloatEqual(sum(p[i]), 1.0)
             assert min(p[i]) < 0
开发者ID:GavinHuttley,项目名称:pycogent,代码行数:23,代码来源:test_usage.py

示例4: test_probs_to_rates

# 需要导入模块: from cogent.seqsim.usage import Probs [as 别名]
# 或者: from cogent.seqsim.usage.Probs import random [as 别名]
 def test_probs_to_rates(self):
     """probs_to_rates converts probs to rates, omitting problem cases"""
     probs = dict([(i, Probs.random(DnaPairs)) for i in range(100)])
     rates = probs_to_rates(probs)
     #check we got at most the same number of items as in probs
     assert len(rates) <= len(probs)
     #check that we didn't get anything bad
     vals = rates.values()
     for v in vals:
         assert not v.isSignificantlyComplex()
     #check that we didn't miss anything good
     for key, val in probs.items():
         if key not in rates:
             try:
                 r = val.toRates()
                 print r.isValid()
                 assert r.isSignificantlyComplex() or (not r.isValid())
             except (ZeroDivisionError, OverflowError, ValueError):
                 pass
开发者ID:GavinHuttley,项目名称:pycogent,代码行数:21,代码来源:test_analysis.py


注:本文中的cogent.seqsim.usage.Probs.random方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。