Ejemplo n.º 1
0
 def setUp(self):
     self.entry_a = hedger.Entry('A')
     self.entry_b = hedger.Entry('B')
     self.entry_c = hedger.Entry('C')
     self.entry_d = hedger.Entry('D')
     self.match = hedger.Match(
         round_=0,
         index=0,
         top=self.entry_a,
         bottom=self.entry_b,
         result=Result.TOP_WINS
     )
Ejemplo n.º 2
0
    def test_get_result_probabilities_using_example_from_538_csv(self):
        virginia = hedger.Entry('Virginia', 88.07)
        ohio = hedger.Entry('Ohio', 77.51)
        match = hedger.Match(
            round_=0,
            index=4,
            top=virginia,
            bottom=ohio,
            result=Result.BOTTOM_WINS
        )

        expected = .136
        actual = match.get_prob()
        self.assertAlmostEqual(actual, expected, 3)
Ejemplo n.º 3
0
    def test_get_result_probabilities_of_equally_rated_teams(self):
        entry_1 = hedger.Entry('Team 1', 100)
        entry_2 = hedger.Entry('Team 2', 100)
        match = hedger.Match(
            round_=0,
            index=0,
            top=entry_1,
            bottom=entry_2,
            result=Result.TOP_WINS
        )

        expected = .5
        actual = match.get_prob()
        self.assertEqual(actual, expected)
Ejemplo n.º 4
0
    def test_make_brackets_with_four_teams(self):
        gryffindor = hedger.Entry('Gryffindor', 100)
        ravenclaw = hedger.Entry('Ravenclaw', 100)
        hufflepuff = hedger.Entry('Hufflepuff', 100)
        slytherin = hedger.Entry('Slytherin', 100)
        entries = [gryffindor, ravenclaw, hufflepuff, slytherin]
        quidditch_cup = hedger.Tournament(entries)
        all_brackets = quidditch_cup.brackets

        all_results = [
            [Result.BOTTOM_WINS, Result.BOTTOM_WINS, Result.BOTTOM_WINS],
            [Result.BOTTOM_WINS, Result.BOTTOM_WINS, Result.TOP_WINS],
            [Result.BOTTOM_WINS, Result.TOP_WINS, Result.BOTTOM_WINS],
            [Result.BOTTOM_WINS, Result.TOP_WINS, Result.TOP_WINS],
            [Result.TOP_WINS, Result.BOTTOM_WINS, Result.BOTTOM_WINS],
            [Result.TOP_WINS, Result.BOTTOM_WINS, Result.TOP_WINS],
            [Result.TOP_WINS, Result.TOP_WINS, Result.BOTTOM_WINS],
            [Result.TOP_WINS, Result.TOP_WINS, Result.TOP_WINS]
        ]

        for bracket, results in zip(all_brackets, all_results):
            actual_matches = bracket.matches

            semifinal_0 = hedger.Match(
                round_=0,
                index=0,
                top=gryffindor,
                bottom=ravenclaw,
                result=results[0]
            )
            semifinal_1 = hedger.Match(
                round_=0,
                index=1,
                top=hufflepuff,
                bottom=slytherin,
                result=results[1]
            )
            final = hedger.Match(
                round_=1,
                index=0,
                top=semifinal_0,
                bottom=semifinal_1,
                result=results[2]
            )
            expected_matches = [semifinal_0, semifinal_1, final]

            self.assertEqual(actual_matches, expected_matches)
Ejemplo n.º 5
0
    def setUp(self):
        teams = ['Gryffindor', 'Slytherin', 'Ravenclaw', 'Hufflepuff']
        entries = [hedger.Entry(team, rating=100) for team in teams]
        equal_tournament = hedger.Tournament(entries)

        gryffindor = hedger.Entry('Gryffindor', rating=106.264)
        slytherin = hedger.Entry('Slytherin', rating=93.736)
        ravenclaw = hedger.Entry('Ravenclaw', rating=100)
        hufflepuff = hedger.Entry('Hufflepuff', rating=100)
        entries = [gryffindor, ravenclaw, hufflepuff, slytherin]
        unequal_tournament = hedger.Tournament(entries)

        self.results = [Result.TOP_WINS, Result.BOTTOM_WINS, Result.TOP_WINS]
        bracket_builder = hedger.BracketBuilder(equal_tournament, self.results)
        self.equal_bracket = bracket_builder.get_bracket()
        bracket_builder = hedger.BracketBuilder(unequal_tournament,
                                                self.results)
        self.unequal_bracket = bracket_builder.get_bracket()
Ejemplo n.º 6
0
    ('Creighton', 88.85),
    ('Southern California', 90.96),
    ('Oregon', 87.39),
    ('Michigan', 90.96),
    ('Florida State', 88.93),
    ('UCLA', 88.97),
    ('Alabama', 90.57),
    ('Baylor', 97.13),
    ('Villanova', 87.75),
    ('Arkansas', 88.38),
    ('Oral Roberts', 76.43),
    ('Loyola (IL)', 88.6),
    ('Oregon State', 86.15),
    ('Syracuse', 86.02),
    ('Houston', 93.12),
]

entries = [hedger.Entry(*team) for team in teams]
tournament = hedger.Tournament(entries)

brackets = tournament.brackets

with cProfile.Profile() as pr:
    for bracket in brackets[:10]:
        bracket.summarize()

with open('time_profile_stats.txt', 'w') as stream:
    stats = pstats.Stats(pr, stream=stream)
    stats.sort_stats(SortKey.CUMULATIVE)
    stats.print_stats()
Ejemplo n.º 7
0
 def test_entry_repr_with_name(self):
     my_team = hedger.Entry('my_team')
     self.assertEqual(repr(my_team), "Entry('my_team')")
Ejemplo n.º 8
0
    def test_empty_entry_not_equal_to_entry_with_name(self):
        my_team = hedger.Entry('my_team')
        empty_entry = hedger.EmptyEntry()

        self.assertNotEqual(empty_entry, my_team)
        self.assertNotEqual(my_team, empty_entry)
Ejemplo n.º 9
0
    def test_two_entries_with_different_names_are_not_equal(self):
        my_team = hedger.Entry('my_team')
        not_my_team = hedger.Entry('not_my_team')

        self.assertNotEqual(my_team, not_my_team)
Ejemplo n.º 10
0
    def test_two_entries_with_same_name_are_equal(self):
        my_team = hedger.Entry('my_team')
        my_team_duplicate = hedger.Entry('my_team')

        self.assertEqual(my_team, my_team_duplicate)
Ejemplo n.º 11
0
 def test_entry_repr_with_rating(self):
     my_team = hedger.Entry('my_team', 100)
     self.assertEqual(repr(my_team), "Entry('my_team', 100)")