Skip to content

Commit

Permalink
fixed the checking of ranked ballots
Browse files Browse the repository at this point in the history
  • Loading branch information
Ben Adida authored and Ben Adida committed Nov 4, 2009
1 parent 1d8207b commit f13c959
Showing 1 changed file with 13 additions and 4 deletions.
17 changes: 13 additions & 4 deletions data.py
Expand Up @@ -115,10 +115,19 @@ def __remove_minus_one_on(array):


def _RANK_verify_symbols(ballot_symbols, p_table_symbols, question): def _RANK_verify_symbols(ballot_symbols, p_table_symbols, question):
mx = question.max_num_answers mx = question.max_num_answers
p_table_symbols = __remove_minus_one_on(p_table_symbols) # p_table_symbols_processed = __remove_minus_one_on(p_table_symbols)
for symbol in ballot_symbols: for symbol in ballot_symbols:
if p_table_symbols[symbol % mx] != symbol / mx: try:
return False if p_table_symbols[symbol % mx] != symbol / mx:
return False
except:
import pdb; pdb.set_trace()

# check that the number of symbols that are not -1 is equal to the number of symbols
if len([p for p in p_table_symbols if p != -1]) != len(ballot_symbols):
import pdb; pdb.set_trace()
return False

return True return True


def _SINGLE_verify_symbols(ballot_symbols, p_table_symbols, question): def _SINGLE_verify_symbols(ballot_symbols, p_table_symbols, question):
Expand Down Expand Up @@ -463,7 +472,7 @@ def verify_encodings(self, election, p_table):
if not VERIFY_SYMBOLS[q_info.type_answer_choice](ballot_symbols, p_table_symbols, q_info): if not VERIFY_SYMBOLS[q_info.type_answer_choice](ballot_symbols, p_table_symbols, q_info):
import pdb;pdb.set_trace() import pdb;pdb.set_trace()
return False return False

return True return True


def verify_code_openings(self, open_ballot, constant, code_callback_func = None): def verify_code_openings(self, open_ballot, constant, code_callback_func = None):
Expand Down

0 comments on commit f13c959

Please sign in to comment.