本文整理汇总了Python中optimizer.Optimizer.get_optimized_matches方法的典型用法代码示例。如果您正苦于以下问题:Python Optimizer.get_optimized_matches方法的具体用法?Python Optimizer.get_optimized_matches怎么用?Python Optimizer.get_optimized_matches使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类optimizer.Optimizer
的用法示例。
在下文中一共展示了Optimizer.get_optimized_matches方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: TestOptimizer
# 需要导入模块: from optimizer import Optimizer [as 别名]
# 或者: from optimizer.Optimizer import get_optimized_matches [as 别名]
class TestOptimizer(unittest.TestCase):
def setUp(self):
roster_data = {
"players": [
{"name": "Kalpesh Shah", "skill": 3, "division": "West"},
{"name": "Larry Ward", "skill": 3, "division": "West"},
{"name": "Trent Miller", "skill": 3, "division": "West"},
{"name": "Katrina Brinkley", "skill": 2, "division": "West"},
{"name": "Dan Doepner", "skill": 2, "division": "West"},
{"name": "Kevin Dahl", "skill": 2, "division": "West"},
{"name": "Doug Nufer", "skill": 1, "division": "West"},
{"name": "Bill Schaefermeyer", "skill": 3, "division": "East"},
{"name": "James Morris", "skill": 3, "division": "East"},
{"name": "Justin Long", "skill": 3, "division": "East"},
{"name": "Joe Au", "skill": 2, "division": "East"},
{"name": "Joseph Hoyal", "skill": 2, "division": "East"},
{"name": "Eric Prusse", "skill": 2, "division": "East"},
{"name": "Maria Bates", "skill": 1, "division": "East"},
]
}
roster = Roster(roster_data)
matchmaker = Matchmaker()
teams = matchmaker.get_teams(roster)
matches = matchmaker.get_matches(teams)
self.optimizer = Optimizer(matches)
def tearDown(self):
self.matches = None
def test_matches_count(self):
optimized_matches = self.optimizer.get_optimized_matches()
self.assertEqual(21, len(optimized_matches))
def test_match_skill_difference(self):
optimized_matches = self.optimizer.get_optimized_matches()
for match in optimized_matches:
self.assertEqual(0, match.get_skill_difference())