本文整理汇总了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]))
示例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))