<commit_before>import unittest
import numpy
import axelrod


class TestResultSet(unittest.TestCase):

    @classmethod
    def setUpClass(cls):
        cls.players = ('Player1', 'Player2', 'Player3')
        cls.test_results = [
            [[0, 0], [10, 10], [21, 21]],
            [[10, 8], [0, 0], [16, 20]],
            [[16, 16], [16, 16], [0, 0]]]
        cls.expected_scores = numpy.array(
            [[31, 31],
             [26, 28],
             [32, 32]])
        cls.expected_ranking = [1, 0, 2]
        cls.expected_ranked_names = ['Player2', 'Player1', 'Player3']
        cls.expected_csv = 'Player2, Player1, Player3\n26, 31, 32\n28, 31, 32\n'

    def test_init(self):
        rs = axelrod.ResultSet(self.players, 5, 2)
        expected_results = [
            [[0, 0], [0, 0], [0, 0]],
            [[0, 0], [0, 0], [0, 0]],
            [[0, 0], [0, 0], [0, 0]]]
        self.assertEquals(rs.nplayers, 3)
        self.assertEquals(rs.players, self.players)
        self.assertEquals(rs.turns, 5)
        self.assertEquals(rs.repetitions, 2)
        self.assertEquals(rs.results, expected_results)
        self.assertFalse(rs.output_initialised)

    def test_generate_scores(self):
        rs = axelrod.ResultSet(self.players, 5, 2)
        rs.results = self.test_results
        self.assertTrue(numpy.array_equal(rs.generate_scores(), self.expected_scores))

    def test_generate_ranking(self):
        rs = axelrod.ResultSet(self.players, 5, 2)
        rs.results = self.test_results
        scores = rs.generate_scores()
        self.assertEquals(rs.generate_ranking(scores), self.expected_ranking)

    def test_generate_ranked_names(self):
        rs = axelrod.ResultSet(self.players, 5, 2)
        rs.results = self.test_results
        scores = rs.generate_scores()
        rankings = rs.generate_ranking(scores)
        self.assertEquals(rs.generate_ranked_names(rankings), self.expected_ranked_names)

    def test_init_output(self):
        rs = axelrod.ResultSet(self.players, 5, 2)
        rs.results = self.test_results
        rs.init_output()
        self.assertTrue(numpy.array_equal(rs.scores, self.expected_scores))
        self.assertEquals(rs.ranking, self.expected_ranking)
        self.assertEquals(rs.ranked_names, self.expected_ranked_names)

    def test_csv(self):
        rs = axelrod.ResultSet(self.players, 5, 2)
        rs.results = self.test_results
        self.assertEquals(rs.csv(), self.expected_csv)

if __name__ == '__main__':<commit_msg>adds missing test for output_initialised flag in test_init_output<commit_after>import unittest
import numpy
import axelrod


class TestResultSet(unittest.TestCase):

    @classmethod
    def setUpClass(cls):
        cls.players = ('Player1', 'Player2', 'Player3')
        cls.test_results = [
            [[0, 0], [10, 10], [21, 21]],
            [[10, 8], [0, 0], [16, 20]],
            [[16, 16], [16, 16], [0, 0]]]
        cls.expected_scores = numpy.array(
            [[31, 31],
             [26, 28],
             [32, 32]])
        cls.expected_ranking = [1, 0, 2]
        cls.expected_ranked_names = ['Player2', 'Player1', 'Player3']
        cls.expected_csv = 'Player2, Player1, Player3\n26, 31, 32\n28, 31, 32\n'

    def test_init(self):
        rs = axelrod.ResultSet(self.players, 5, 2)
        expected_results = [
            [[0, 0], [0, 0], [0, 0]],
            [[0, 0], [0, 0], [0, 0]],
            [[0, 0], [0, 0], [0, 0]]]
        self.assertEquals(rs.nplayers, 3)
        self.assertEquals(rs.players, self.players)
        self.assertEquals(rs.turns, 5)
        self.assertEquals(rs.repetitions, 2)
        self.assertEquals(rs.results, expected_results)
        self.assertFalse(rs.output_initialised)

    def test_generate_scores(self):
        rs = axelrod.ResultSet(self.players, 5, 2)
        rs.results = self.test_results
        self.assertTrue(numpy.array_equal(rs.generate_scores(), self.expected_scores))

    def test_generate_ranking(self):
        rs = axelrod.ResultSet(self.players, 5, 2)
        rs.results = self.test_results
        scores = rs.generate_scores()
        self.assertEquals(rs.generate_ranking(scores), self.expected_ranking)

    def test_generate_ranked_names(self):
        rs = axelrod.ResultSet(self.players, 5, 2)
        rs.results = self.test_results
        scores = rs.generate_scores()
        rankings = rs.generate_ranking(scores)
        self.assertEquals(rs.generate_ranked_names(rankings), self.expected_ranked_names)

    def test_init_output(self):
        rs = axelrod.ResultSet(self.players, 5, 2)
        rs.results = self.test_results
        rs.init_output()
        self.assertTrue(numpy.array_equal(rs.scores, self.expected_scores))
        self.assertEquals(rs.ranking, self.expected_ranking)
        self.assertEquals(rs.ranked_names, self.expected_ranked_names)
        self.assertTrue(rs.output_initialised)

    def test_csv(self):
        rs = axelrod.ResultSet(self.players, 5, 2)
        rs.results = self.test_results
        self.assertEquals(rs.csv(), self.expected_csv)

if __name__ == '__main__':
{'fraction_non_alphanumeric': 0.13535313791068268, 'fraction_numerical': 0.038559905567578205, 'mean_word_length': 2.654924514737599, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 6, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '644117', 'n_tokens_mistral': 1841, 'n_tokens_neox': 1667, 'n_words': 323}