From 0722acb1b85d581adc199c30878ea3575bc69171 Mon Sep 17 00:00:00 2001 From: Berj Chilingirian Date: Wed, 14 Sep 2016 14:14:26 -0400 Subject: [PATCH] Fix RNG seed setting; Fix small spelling mistakes; Remove extra newline in audit round file --- aus_senate_audit/audit_recorder.py | 2 +- aus_senate_audit/audits/bayesian_audit.py | 4 ++-- aus_senate_audit/senate_election/real_senate_election.py | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/aus_senate_audit/audit_recorder.py b/aus_senate_audit/audit_recorder.py index 533ceff..b6daeeb 100644 --- a/aus_senate_audit/audit_recorder.py +++ b/aus_senate_audit/audit_recorder.py @@ -139,7 +139,7 @@ def record_selected_ballots(self, audit_stage, sample, quick): f.write('\n'.join([ballot if quick else self.remove_preferences_from_ballot(ballot) for ballot in sample]) + '\n') # Write the new ballots in the sample to the audit round file. with open(self.get_file_path(AUDIT_ROUND_FILE_NAME.format(ROUND_DIR_NAME, audit_stage)), 'w') as f: - f.write('{}\n'.format(','.join(COLUMN_HEADERS + MATCH_HEADERS)) + '\n') + f.write('{}\n'.format(','.join(COLUMN_HEADERS + MATCH_HEADERS))) f.write('\n'.join([ballot for ballot in sample]) + '\n') def record_current_audit_round_match_records(self, match_records): diff --git a/aus_senate_audit/audits/bayesian_audit.py b/aus_senate_audit/audits/bayesian_audit.py index 4014a01..038a993 100644 --- a/aus_senate_audit/audits/bayesian_audit.py +++ b/aus_senate_audit/audits/bayesian_audit.py @@ -51,7 +51,7 @@ def audit(election, seed, unpopular_freq_threshold, stage_counter=0, alpha=0.05, print( 'Audit of {} election.\n'.format(election.get_type()), ' Election ID: {}\n'.format(election.get_election_id()), - ' Canadidates: {}\n'.format(election.get_candidates()), + ' Candidates: {}\n'.format(election.get_candidates()), ' Number of ballots cast: {}\n'.format( election.get_num_cast_ballots(), ), @@ -160,5 +160,5 @@ def audit(election, seed, unpopular_freq_threshold, stage_counter=0, alpha=0.05, ' {}'.format(candidate_to_ballots_map[cid]), ) - print('Elasped time: {} seconds.'.format(time() - start_time)) + print('Elapsed time: {} seconds.'.format(time() - start_time)) return done diff --git a/aus_senate_audit/senate_election/real_senate_election.py b/aus_senate_audit/senate_election/real_senate_election.py index 1d67d29..da73a50 100644 --- a/aus_senate_audit/senate_election/real_senate_election.py +++ b/aus_senate_audit/senate_election/real_senate_election.py @@ -66,7 +66,7 @@ def __init__(self, seed, state, data_file_path, max_ballots=None): self._data = sc.get_data(input_cls, '', contest_config, **data_options) # Build remaining ticket data structure from tickets and randomly shuffle for sampling. - for ticket, weight in self._data.tickets_for_count: + for ticket, weight in sorted(self._data.tickets_for_count): self.add_ballot(ticket, weight) # Get candidate data.