Skip to content

Commit

Permalink
Added vote_matrix to smith_minimax output. Fixed STAR voting logic.
Browse files Browse the repository at this point in the history
  • Loading branch information
johnh865 committed Feb 27, 2021
1 parent f09d72c commit e5e30ef
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 6 deletions.
3 changes: 2 additions & 1 deletion votesim/votemethods/condorcet.py
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,8 @@ def smith_minimax(ranks=None, numwin=1, matrix=None):

output = {}
if m is not None:
output['margin_matrix'] = m
output['margin_matrix'] = win_losses
output['vote_matrix'] = m
output['tally'] = min_losses
return winners, ties, output

Expand Down
6 changes: 3 additions & 3 deletions votesim/votemethods/score.py
Original file line number Diff line number Diff line change
Expand Up @@ -353,16 +353,16 @@ def star(data, numwin=1):

# Calculate winner
# jwinners, jties = tools.winner_check(vote_array, numwin=1)
winner = runoff_candidates[jwinner]
ties = runoff_candidates[jties]
winners2 = runoff_candidates[jwinner]
ties2 = runoff_candidates[jties]

details = {}
details['tally'] = sums
details['runoff_candidates'] = runoff_candidates
details['runoff_matrix'] = matrix
# details['runoff_tally'] = j_runoff_tally

return winners, ties, details
return winners2, ties2, details



Expand Down
7 changes: 5 additions & 2 deletions votesim/votemethods/tests/test_score.py
Original file line number Diff line number Diff line change
Expand Up @@ -155,6 +155,9 @@ def test_tally(self):
np.random.seed(0)
data = np.random.randint(0, 5, size=(100, 4))
w, t, d = score.star(data)

self.assertTrue(len(w) == 1)
self.assertTrue(w[0] == 3)
return


Expand Down Expand Up @@ -182,9 +185,9 @@ def test_result(self):
# unittest.main(exit=False)
t = TestStar()
# t.test_tie()
t.test_tie3()
# t.test_tie3()
# t.test_wiki()
t.test_zeros()
# t.test_zeros()
t.test_tally()

# t = TestStar()
Expand Down

0 comments on commit e5e30ef

Please sign in to comment.