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


Python Optimizer.get_optimized_matches方法代码示例

本文整理汇总了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())
开发者ID:trentdm,项目名称:tourney.maker,代码行数:40,代码来源:test_optimizer.py


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