def test_unitweights(num_cand):
    profile = Profile(num_cand)
    profile.add_voters([])
    profile.add_voter(Voter([0, 4, 5]))
    profile.add_voter([0, 4, 5])
    p1 = Voter([0, 4, 5])
    p2 = Voter([1, 2])
    profile.add_voters([p1, p2])
    assert profile.has_unit_weights()

    profile.add_voter(Voter([0, 4, 5], 2.4))
    assert not profile.has_unit_weights()

    assert profile.totalweight() == 6.4
Esempio n. 2
0
def test_unitweights(num_cand):
    profile = Profile(num_cand)
    profile.add_preferences([])
    profile.add_preferences(DichotomousPreferences([0, 4, 5]))
    profile.add_preferences([0, 4, 5])
    p1 = DichotomousPreferences([0, 4, 5])
    p2 = DichotomousPreferences([1, 2])
    profile.add_preferences([p1, p2])
    assert profile.has_unit_weights()

    profile.add_preferences(DichotomousPreferences([0, 4, 5], 2.4))
    assert not profile.has_unit_weights()

    assert profile.totalweight() == 6.4