# Unit tests


import unittest


def run_test_instance(unittestinstance, profile, committeesize, tests):
    import rules_approval

    # all rules used?
    for rule in rules_approval.MWRULES:
        unittestinstance.assertTrue(rule in tests.keys())

    for rule in tests.keys():

        output = rules_approval.compute_rule(rule, profile,
                                             committeesize,
                                             resolute=False)
        unittestinstance.assertEqual(
            output, tests[rule], msg=rules_approval.MWRULES[rule] + " failed")
        output = rules_approval.compute_rule(
            rule, profile, committeesize, resolute=True)
        unittestinstance.assertEqual(
            len(output), 1,
            msg=rules_approval.MWRULES[rule] + " failed with resolute=True")
        unittestinstance.assertTrue(
            output[0] in tests[rule],
            msg=rules_approval.MWRULES[rule] + " failed with resolute=True")


class TestApprovalMultiwinner(unittest.TestCase):
    def test_createprofiles(self):
        from preferences import Profile
        from preferences import DichotomousPreferences
        num_cand = 7
        prof = Profile(num_cand)
        self.assertEqual(prof.add_preferences(
            DichotomousPreferences([0, 4, 5])),
            None)
        with self.assertRaises(Exception):
            prof.add_preferences(DichotomousPreferences([num_cand]))
        with self.assertRaises(Exception):
            prof.add_preferences(DichotomousPreferences([-1]))
        self.assertEqual(prof.add_preferences([0, 4, 5]), None)
        with self.assertRaises(Exception):
            prof.add_preferences([0, 4, 5, "1"])
        with self.assertRaises(Exception):
            prof.add_preferences(["1", 0, 4, 5])
        p1 = DichotomousPreferences([0, 4, 5])
        p2 = DichotomousPreferences([1, 2])
        self.assertEqual(prof.add_preferences([p1, p2]), None)
        self.assertTrue(prof.has_unit_weights())
        prof.add_preferences(DichotomousPreferences([0, 4, 5], 2.4))
        self.assertFalse(prof.has_unit_weights())
        self.assertEqual(prof.totalweight(), 6.4)

    def test_mwrules__toofewcandidates(self):
        from preferences import Profile
        import rules_approval
        profile = Profile(5)
        committeesize = 4
        preflist = [[0, 1, 2], [1], [1, 2], [0]]
        profile.add_preferences(preflist)

        for rule in rules_approval.MWRULES.keys():
            with self.assertRaises(Exception):
                rules_approval.compute_rule(rule, profile, committeesize)
            with self.assertRaises(Exception):
                rules_approval.compute_rule(rule, profile,
                                            committeesize, resolute=True)

    def test_mwrules_weightsconsidered(self):
        from preferences import Profile
        from preferences import DichotomousPreferences
        import rules_approval

        self.longMessage = True

        profile = Profile(3)
        profile.add_preferences(DichotomousPreferences([0]))
        profile.add_preferences(DichotomousPreferences([0]))
        profile.add_preferences(DichotomousPreferences([1], 5))
        profile.add_preferences(DichotomousPreferences([0]))
        committeesize = 1

        for rule in rules_approval.MWRULES.keys():
            if "monroe" in rule or "rule-x" in rule:
                # Monroe and rule x only work with unit weights:
                continue
            result = rules_approval.compute_rule(rule, profile, committeesize)
            self.assertTrue([1] in result,
                            msg=rule + " failed"+str(result))

    def test_mwrules_correct_simple(self):
        from preferences import Profile
        import rules_approval

        self.longMessage = True

        profile = Profile(4)
        profile.add_preferences([[0], [1], [2], [3]])
        committeesize = 2

        for rule in rules_approval.MWRULES.keys():
            if rule == "greedy-monroe":   # always returns one committee
                continue
            self.assertEqual(len(rules_approval.compute_rule(rule, profile,
                                                             committeesize)),
                             6, msg=rule + " failed")

        for rule in rules_approval.MWRULES.keys():
            self.assertEqual(len(rules_approval.compute_rule(rule, profile,
                                                             committeesize,
                                                             resolute=True)),
                             1, msg=rule + " failed with resolute=True")

    def test_monroe_indivisible(self):
        from preferences import Profile
        import rules_approval

        self.longMessage = True

        profile = Profile(4)
        profile.add_preferences([[0], [0], [0], [1, 2], [1, 2], [1], [3]])
        committeesize = 3

        for ilp in [True, False]:
            # max Monroe score is 6 (even for committee [0, 1, 3])
            self.assertEqual(
                rules_approval.compute_monroe(profile, committeesize,
                                              ilp=ilp, resolute=False),
                [[0, 1, 2], [0, 1, 3], [0, 2, 3]])

    # this test shows that tiebreaking is not (yet)
    # implemented for opt-Phragmen
    def test_optphrag_notiebreaking(self):
        from preferences import Profile
        from rules_approval import compute_rule

        self.longMessage = True

        profile = Profile(6)
        profile.add_preferences([[0], [0], [1, 3], [1, 3], [1, 4],
                                 [2, 4], [2, 5], [2, 5]])
        committeesize = 3

        self.assertEqual(
                len(compute_rule("optphrag", profile, committeesize,
                                 resolute=False)),
                12)

    def test_mwrules_correct_advanced_1(self):

        from preferences import Profile
        self.longMessage = True
        committeesize = 4

        profile = Profile(6)
        preflist = [[0, 4, 5], [0], [1, 4, 5], [1],
                    [2, 4, 5], [2], [3, 4, 5], [3]]
        profile.add_preferences(preflist)

        tests1 = {
            "seqpav": [[0, 1, 4, 5], [0, 2, 4, 5], [0, 3, 4, 5],
                       [1, 2, 4, 5], [1, 3, 4, 5], [2, 3, 4, 5]],
            "av": [[0, 1, 4, 5], [0, 2, 4, 5], [0, 3, 4, 5],
                   [1, 2, 4, 5], [1, 3, 4, 5], [2, 3, 4, 5]],
            "sav": [[0, 1, 2, 3], [0, 1, 2, 4], [0, 1, 2, 5], [0, 1, 3, 4],
                    [0, 1, 3, 5], [0, 1, 4, 5], [0, 2, 3, 4], [0, 2, 3, 5],
                    [0, 2, 4, 5], [0, 3, 4, 5], [1, 2, 3, 4], [1, 2, 3, 5],
                    [1, 2, 4, 5], [1, 3, 4, 5], [2, 3, 4, 5]],
            "pav-ilp": [[0, 1, 4, 5], [0, 2, 4, 5], [0, 3, 4, 5],
                        [1, 2, 4, 5], [1, 3, 4, 5], [2, 3, 4, 5]],
            "pav-noilp": [[0, 1, 4, 5], [0, 2, 4, 5], [0, 3, 4, 5],
                          [1, 2, 4, 5], [1, 3, 4, 5], [2, 3, 4, 5]],
            "revseqpav": [[0, 1, 4, 5], [0, 2, 4, 5], [0, 3, 4, 5],
                          [1, 2, 4, 5], [1, 3, 4, 5], [2, 3, 4, 5]],
            "minimaxav-noilp": [[0, 1, 2, 3], [0, 1, 2, 4], [0, 1, 2, 5],
                                [0, 1, 3, 4], [0, 1, 3, 5], [0, 1, 4, 5],
                                [0, 2, 3, 4], [0, 2, 3, 5], [0, 2, 4, 5],
                                [0, 3, 4, 5], [1, 2, 3, 4], [1, 2, 3, 5],
                                [1, 2, 4, 5], [1, 3, 4, 5], [2, 3, 4, 5]],
            "minimaxav-ilp": [[0, 1, 2, 3], [0, 1, 2, 4], [0, 1, 2, 5],
                              [0, 1, 3, 4], [0, 1, 3, 5], [0, 1, 4, 5],
                              [0, 2, 3, 4], [0, 2, 3, 5], [0, 2, 4, 5],
                              [0, 3, 4, 5], [1, 2, 3, 4], [1, 2, 3, 5],
                              [1, 2, 4, 5], [1, 3, 4, 5], [2, 3, 4, 5]],
            "phrag": [[0, 1, 4, 5], [0, 2, 4, 5], [0, 3, 4, 5],
                      [1, 2, 4, 5], [1, 3, 4, 5], [2, 3, 4, 5]],
            "optphrag": [[0, 1, 2, 3]],
            "cc-ilp": [[0, 1, 2, 3]],
            "cc-noilp": [[0, 1, 2, 3]],
            "seqcc": [[0, 1, 2, 4], [0, 1, 2, 5], [0, 1, 3, 4], [0, 1, 3, 5],
                      [0, 2, 3, 4], [0, 2, 3, 5], [1, 2, 3, 4], [1, 2, 3, 5]],
            "revseqcc": [[0, 1, 2, 3]],
            "monroe-ilp": [[0, 1, 2, 3]],
            "monroe-noilp": [[0, 1, 2, 3]],
            "greedy-monroe": [[0, 2, 3, 4]],
            "slav-ilp": [[0, 1, 2, 3],
                         [0, 1, 2, 4], [0, 1, 2, 5],
                         [0, 1, 3, 4], [0, 1, 3, 5],
                         [0, 2, 3, 4], [0, 2, 3, 5],
                         [1, 2, 3, 4], [1, 2, 3, 5]],
            "slav-noilp": [[0, 1, 2, 3],
                           [0, 1, 2, 4], [0, 1, 2, 5],
                           [0, 1, 3, 4], [0, 1, 3, 5],
                           [0, 2, 3, 4], [0, 2, 3, 5],
                           [1, 2, 3, 4], [1, 2, 3, 5]],
            "seqslav": [[0, 1, 2, 4], [0, 1, 2, 5],
                        [0, 1, 3, 4], [0, 1, 3, 5],
                        [0, 2, 3, 4], [0, 2, 3, 5],
                        [1, 2, 3, 4], [1, 2, 3, 5]],
            "rule-x": [[0, 1, 4, 5], [0, 2, 4, 5],
                       [0, 3, 4, 5], [1, 2, 4, 5],
                       [1, 3, 4, 5], [2, 3, 4, 5]],
            "phragmen-enestroem": [[0, 1, 4, 5], [0, 2, 4, 5],
                                   [0, 3, 4, 5], [1, 2, 4, 5],
                                   [1, 3, 4, 5], [2, 3, 4, 5]],
        }

        run_test_instance(self, profile, committeesize, tests1)

        # and now with reversed preflist
        preflist.reverse()
        for p in preflist:
            p.reverse()
        profile = Profile(6)
        profile.add_preferences(preflist)

        run_test_instance(self, profile, committeesize, tests1)

    def test_mwrules_correct_advanced_2(self):

        from preferences import Profile
        self.longMessage = True

        # and another profile
        profile = Profile(5)
        committeesize = 3
        preflist = [[0, 1, 2], [0, 1, 2], [0, 1, 2], [0, 1, 2],
                    [0, 1, 2], [0, 1], [3, 4], [3, 4], [3]]
        profile.add_preferences(preflist)

        tests2 = {
            "seqpav": [[0, 1, 3]],
            "av": [[0, 1, 2]],
            "sav": [[0, 1, 3]],
            "pav-ilp": [[0, 1, 3]],
            "pav-noilp": [[0, 1, 3]],
            "revseqpav": [[0, 1, 3]],
            "minimaxav-noilp": [[0, 1, 3], [0, 2, 3], [1, 2, 3]],
            "minimaxav-ilp": [[0, 1, 3], [0, 2, 3], [1, 2, 3]],
            "phrag": [[0, 1, 3]],
            "optphrag": [[0, 1, 3], [0, 2, 3], [1, 2, 3]],
            "cc-ilp": [[0, 1, 3], [0, 2, 3], [0, 3, 4],
                       [1, 2, 3], [1, 3, 4]],
            "cc-noilp": [[0, 1, 3], [0, 2, 3], [0, 3, 4],
                         [1, 2, 3], [1, 3, 4]],
            "seqcc": [[0, 1, 3], [0, 2, 3], [0, 3, 4],
                      [1, 2, 3], [1, 3, 4]],
            "revseqcc": [[0, 1, 3], [0, 2, 3], [0, 3, 4],
                         [1, 2, 3], [1, 3, 4]],
            "monroe-ilp": [[0, 1, 3], [0, 2, 3], [1, 2, 3]],
            "monroe-noilp": [[0, 1, 3], [0, 2, 3], [1, 2, 3]],
            "greedy-monroe": [[0, 1, 3]],
            "seqslav": [[0, 1, 3]],
            "slav-ilp": [[0, 1, 3]],
            "slav-noilp": [[0, 1, 3]],
            "rule-x": [[0, 1, 3]],
            "phragmen-enestroem": [[0, 1, 3]],
        }

        run_test_instance(self, profile, committeesize, tests2)

    def test_mwrules_correct_advanced_3(self):

        from preferences import Profile
        self.longMessage = True

        # and a third profile
        profile = Profile(6)
        committeesize = 4
        preflist = [[0, 3, 4, 5], [1, 2], [0, 2, 5], [2],
                    [0, 1, 2, 3, 4], [0, 3, 4], [0, 2, 4], [0, 1]]
        profile.add_preferences(preflist)

        tests3 = {
            "seqpav": [[0, 1, 2, 4]],
            "av": [[0, 1, 2, 4], [0, 2, 3, 4]],
            "sav": [[0, 1, 2, 4]],
            "pav-ilp": [[0, 1, 2, 4]],
            "pav-noilp": [[0, 1, 2, 4]],
            "revseqpav": [[0, 1, 2, 4]],
            "minimaxav-noilp": [[0, 1, 2, 3], [0, 1, 2, 4],
                                [0, 2, 3, 4], [0, 2, 3, 5],
                                [0, 2, 4, 5]],
            "minimaxav-ilp": [[0, 1, 2, 3], [0, 1, 2, 4],
                              [0, 2, 3, 4], [0, 2, 3, 5],
                              [0, 2, 4, 5]],
            "phrag": [[0, 1, 2, 4]],
            "optphrag": [[0, 1, 2, 3], [0, 1, 2, 4],
                         [0, 1, 2, 5], [0, 2, 3, 4],
                         [0, 2, 3, 5], [0, 2, 4, 5],
                         [1, 2, 3, 4], [1, 2, 3, 5],
                         [1, 2, 4, 5]],
            "cc-ilp": [[0, 1, 2, 3], [0, 1, 2, 4],
                       [0, 1, 2, 5], [0, 2, 3, 4],
                       [0, 2, 3, 5], [0, 2, 4, 5],
                       [1, 2, 3, 4], [1, 2, 3, 5],
                       [1, 2, 4, 5]],
            "cc-noilp": [[0, 1, 2, 3], [0, 1, 2, 4],
                         [0, 1, 2, 5], [0, 2, 3, 4],
                         [0, 2, 3, 5], [0, 2, 4, 5],
                         [1, 2, 3, 4], [1, 2, 3, 5],
                         [1, 2, 4, 5]],
            "seqcc": [[0, 1, 2, 3], [0, 1, 2, 4],
                      [0, 1, 2, 5], [0, 2, 3, 4],
                      [0, 2, 3, 5], [0, 2, 4, 5]],
            "revseqcc": [[0, 1, 2, 3], [0, 1, 2, 4],
                         [0, 1, 2, 5], [0, 2, 3, 4],
                         [0, 2, 3, 5], [0, 2, 4, 5],
                         [1, 2, 3, 4], [1, 2, 3, 5],
                         [1, 2, 4, 5]],
            "monroe-ilp": [[0, 1, 2, 3], [0, 1, 2, 4],
                           [0, 1, 2, 5], [0, 2, 3, 4],
                           [0, 2, 3, 5], [0, 2, 4, 5],
                           [1, 2, 3, 4], [1, 2, 3, 5],
                           [1, 2, 4, 5]],
            "monroe-noilp": [[0, 1, 2, 3], [0, 1, 2, 4],
                             [0, 1, 2, 5], [0, 2, 3, 4],
                             [0, 2, 3, 5], [0, 2, 4, 5],
                             [1, 2, 3, 4], [1, 2, 3, 5],
                             [1, 2, 4, 5]],
            "greedy-monroe": [[0, 1, 2, 3]],
            "seqslav": [[0, 1, 2, 4]],
            "slav-ilp": [[0, 1, 2, 4]],
            "slav-noilp": [[0, 1, 2, 4]],
            "rule-x": [[0, 1, 2, 4]],
            "phragmen-enestroem": [[0, 1, 2, 4]],
        }

        run_test_instance(self, profile, committeesize, tests3)

    def test_monroescore(self):
        from preferences import Profile
        from score_functions import monroescore_flowbased, monroescore_matching
        self.longMessage = True

        # and a third profile
        profile = Profile(6)
        preflist = [[0, 1], [1], [1, 3], [4], [2], [1, 5, 3]]
        profile.add_preferences(preflist)

        self.assertEqual(monroescore_flowbased(profile, [1, 3, 2]), 5)
        self.assertEqual(monroescore_matching(profile, [1, 3, 2]), 5)
        self.assertEqual(monroescore_flowbased(profile, [2, 1, 5]), 4)
        self.assertEqual(monroescore_matching(profile, [2, 1, 5]), 4)
        self.assertEqual(monroescore_flowbased(profile, [2, 4, 5]), 3)
        self.assertEqual(monroescore_matching(profile, [2, 5, 4]), 3)


if __name__ == '__main__':
    unittest.main()

[((363, 4, 363, 19), 'unittest.main', 'unittest.main', ({}, {}), '()', False, 'import unittest\n'), ((16, 17, 18, 60), 'rules_approval.compute_rule', 'rules_approval.compute_rule', (), '', False, 'import rules_approval\n'), ((21, 17, 22, 56), 'rules_approval.compute_rule', 'rules_approval.compute_rule', (), '', False, 'import rules_approval\n'), ((36, 15, 36, 32), 'preferences.Profile', 'Profile', ({(36, 23, 36, 31): 'num_cand'}, {}), '(num_cand)', False, 'from preferences import Profile\n'), ((49, 13, 49, 46), 'preferences.DichotomousPreferences', 'DichotomousPreferences', ({(49, 36, 49, 45): '[0, 4, 5]'}, {}), '([0, 4, 5])', False, 'from preferences import DichotomousPreferences\n'), ((50, 13, 50, 43), 'preferences.DichotomousPreferences', 'DichotomousPreferences', ({(50, 36, 50, 42): '[1, 2]'}, {}), '([1, 2])', False, 'from preferences import DichotomousPreferences\n'), ((60, 18, 60, 28), 'preferences.Profile', 'Profile', ({(60, 26, 60, 27): '5'}, {}), '(5)', False, 'from preferences import Profile\n'), ((65, 20, 65, 49), 'rules_approval.MWRULES.keys', 'rules_approval.MWRULES.keys', ({}, {}), '()', False, 'import rules_approval\n'), ((79, 18, 79, 28), 'preferences.Profile', 'Profile', ({(79, 26, 79, 27): '3'}, {}), '(3)', False, 'from preferences import Profile\n'), ((86, 20, 86, 49), 'rules_approval.MWRULES.keys', 'rules_approval.MWRULES.keys', ({}, {}), '()', False, 'import rules_approval\n'), ((100, 18, 100, 28), 'preferences.Profile', 'Profile', ({(100, 26, 100, 27): '4'}, {}), '(4)', False, 'from preferences import Profile\n'), ((104, 20, 104, 49), 'rules_approval.MWRULES.keys', 'rules_approval.MWRULES.keys', ({}, {}), '()', False, 'import rules_approval\n'), ((111, 20, 111, 49), 'rules_approval.MWRULES.keys', 'rules_approval.MWRULES.keys', ({}, {}), '()', False, 'import rules_approval\n'), ((123, 18, 123, 28), 'preferences.Profile', 'Profile', ({(123, 26, 123, 27): '4'}, {}), '(4)', False, 'from preferences import Profile\n'), ((142, 18, 142, 28), 'preferences.Profile', 'Profile', ({(142, 26, 142, 27): '6'}, {}), '(6)', False, 'from preferences import Profile\n'), ((158, 18, 158, 28), 'preferences.Profile', 'Profile', ({(158, 26, 158, 27): '6'}, {}), '(6)', False, 'from preferences import Profile\n'), ((227, 18, 227, 28), 'preferences.Profile', 'Profile', ({(227, 26, 227, 27): '6'}, {}), '(6)', False, 'from preferences import Profile\n'), ((238, 18, 238, 28), 'preferences.Profile', 'Profile', ({(238, 26, 238, 27): '5'}, {}), '(5)', False, 'from preferences import Profile\n'), ((281, 18, 281, 28), 'preferences.Profile', 'Profile', ({(281, 26, 281, 27): '6'}, {}), '(6)', False, 'from preferences import Profile\n'), ((350, 18, 350, 28), 'preferences.Profile', 'Profile', ({(350, 26, 350, 27): '6'}, {}), '(6)', False, 'from preferences import Profile\n'), ((53, 29, 53, 67), 'preferences.DichotomousPreferences', 'DichotomousPreferences', ({(53, 52, 53, 61): '[0, 4, 5]', (53, 63, 53, 66): '(2.4)'}, {}), '([0, 4, 5], 2.4)', False, 'from preferences import DichotomousPreferences\n'), ((80, 32, 80, 59), 'preferences.DichotomousPreferences', 'DichotomousPreferences', ({(80, 55, 80, 58): '[0]'}, {}), '([0])', False, 'from preferences import DichotomousPreferences\n'), ((81, 32, 81, 59), 'preferences.DichotomousPreferences', 'DichotomousPreferences', ({(81, 55, 81, 58): '[0]'}, {}), '([0])', False, 'from preferences import DichotomousPreferences\n'), ((82, 32, 82, 62), 'preferences.DichotomousPreferences', 'DichotomousPreferences', ({(82, 55, 82, 58): '[1]', (82, 60, 82, 61): '(5)'}, {}), '([1], 5)', False, 'from preferences import DichotomousPreferences\n'), ((83, 32, 83, 59), 'preferences.DichotomousPreferences', 'DichotomousPreferences', ({(83, 55, 83, 58): '[0]'}, {}), '([0])', False, 'from preferences import DichotomousPreferences\n'), ((90, 21, 90, 78), 'rules_approval.compute_rule', 'rules_approval.compute_rule', ({(90, 49, 90, 53): 'rule', (90, 55, 90, 62): 'profile', (90, 64, 90, 77): 'committeesize'}, {}), '(rule, profile, committeesize)', False, 'import rules_approval\n'), ((354, 25, 354, 66), 'score_functions.monroescore_flowbased', 'monroescore_flowbased', ({(354, 47, 354, 54): 'profile', (354, 56, 354, 65): '[1, 3, 2]'}, {}), '(profile, [1, 3, 2])', False, 'from score_functions import monroescore_flowbased, monroescore_matching\n'), ((355, 25, 355, 65), 'score_functions.monroescore_matching', 'monroescore_matching', ({(355, 46, 355, 53): 'profile', (355, 55, 355, 64): '[1, 3, 2]'}, {}), '(profile, [1, 3, 2])', False, 'from score_functions import monroescore_flowbased, monroescore_matching\n'), ((356, 25, 356, 66), 'score_functions.monroescore_flowbased', 'monroescore_flowbased', ({(356, 47, 356, 54): 'profile', (356, 56, 356, 65): '[2, 1, 5]'}, {}), '(profile, [2, 1, 5])', False, 'from score_functions import monroescore_flowbased, monroescore_matching\n'), ((357, 25, 357, 65), 'score_functions.monroescore_matching', 'monroescore_matching', ({(357, 46, 357, 53): 'profile', (357, 55, 357, 64): '[2, 1, 5]'}, {}), '(profile, [2, 1, 5])', False, 'from score_functions import monroescore_flowbased, monroescore_matching\n'), ((358, 25, 358, 66), 'score_functions.monroescore_flowbased', 'monroescore_flowbased', ({(358, 47, 358, 54): 'profile', (358, 56, 358, 65): '[2, 4, 5]'}, {}), '(profile, [2, 4, 5])', False, 'from score_functions import monroescore_flowbased, monroescore_matching\n'), ((359, 25, 359, 65), 'score_functions.monroescore_matching', 'monroescore_matching', ({(359, 46, 359, 53): 'profile', (359, 55, 359, 64): '[2, 5, 4]'}, {}), '(profile, [2, 5, 4])', False, 'from score_functions import monroescore_flowbased, monroescore_matching\n'), ((38, 12, 38, 45), 'preferences.DichotomousPreferences', 'DichotomousPreferences', ({(38, 35, 38, 44): '[0, 4, 5]'}, {}), '([0, 4, 5])', False, 'from preferences import DichotomousPreferences\n'), ((41, 33, 41, 67), 'preferences.DichotomousPreferences', 'DichotomousPreferences', ({(41, 56, 41, 66): '[num_cand]'}, {}), '([num_cand])', False, 'from preferences import DichotomousPreferences\n'), ((43, 33, 43, 61), 'preferences.DichotomousPreferences', 'DichotomousPreferences', ({(43, 56, 43, 60): '[-1]'}, {}), '([-1])', False, 'from preferences import DichotomousPreferences\n'), ((67, 16, 67, 73), 'rules_approval.compute_rule', 'rules_approval.compute_rule', ({(67, 44, 67, 48): 'rule', (67, 50, 67, 57): 'profile', (67, 59, 67, 72): 'committeesize'}, {}), '(rule, profile, committeesize)', False, 'import rules_approval\n'), ((69, 16, 70, 73), 'rules_approval.compute_rule', 'rules_approval.compute_rule', (), '', False, 'import rules_approval\n'), ((130, 16, 131, 70), 'rules_approval.compute_monroe', 'rules_approval.compute_monroe', (), '', False, 'import rules_approval\n'), ((148, 20, 149, 48), 'rules_approval.compute_rule', 'compute_rule', (), '', False, 'from rules_approval import compute_rule\n'), ((107, 33, 108, 75), 'rules_approval.compute_rule', 'rules_approval.compute_rule', ({(107, 61, 107, 65): 'rule', (107, 67, 107, 74): 'profile', (108, 61, 108, 74): 'committeesize'}, {}), '(rule, profile, committeesize)', False, 'import rules_approval\n'), ((112, 33, 114, 75), 'rules_approval.compute_rule', 'rules_approval.compute_rule', (), '', False, 'import rules_approval\n')]