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


Python Population.randomize方法代码示例

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


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

示例1: test_normal_random_population_creation

# 需要导入模块: from population import Population [as 别名]
# 或者: from population.Population import randomize [as 别名]
 def test_normal_random_population_creation(self):
     # XXX: I suppose it's possible these asserts could fail because we're dealing with
     #      probabalistic outcomes; I haven't taken the time to prove these always work
     p = Population()
     p.randomize(1024)
     self.assertLess(len(p.coaches), len(p.students))
     self.assertLess(len(p.studying_coaches), len(p.coaches))
     self.assertLess(1, max([len(u.coaches()) for u in p.students]))
开发者ID:jrbl,项目名称:python-infection,代码行数:10,代码来源:population_test.py

示例2: test_pessimistic_random_population_creation

# 需要导入模块: from population import Population [as 别名]
# 或者: from population.Population import randomize [as 别名]
 def test_pessimistic_random_population_creation(self):
     p = Population()
     # 10 students who are all infected, all teachers, and all study
     p.randomize(10, infect_rate=1, feature='A', coach_rate=1, coach_study_rate=1)
     self.assertEqual(10, p.N)
     self.assertEqual(p.N, len(p.population))
     self.assertEqual(len(p.population), len(p.infected))
     self.assertEqual(len(p.infected), len(p.students))
     self.assertEqual(len(p.students), len(p.coaches))
开发者ID:jrbl,项目名称:python-infection,代码行数:11,代码来源:population_test.py


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