def test_4_easy(): """ Generate election 4-easy using syn2 then run audit on it with multi. """ with warnings.catch_warnings(record=True): # Generate election from object storing pseudo command-line arguments. e = multi.Election() syn_args = Args() syn_args.election_dirname = '4-easy' syn_args.syn_type = '2' cli_syn.dispatch(e, syn_args) # Audit election e = multi.Election() multi_args = Args() multi_args.election_dirname = '4-easy' multi_args.election_name = '4-easy' multi_args.elections_root = './elections' multi_args.set_audit_seed = 42 multi_args.read_election_spec = False multi_args.read_reported = False multi_args.make_audit_orders = False multi_args.read_audited = False multi_args.audit = True multi_args.pause = False cli_multi.dispatch(e, multi_args)
def test_4_easy(): """ Generate election 4-easy using syn2 then run audit on it with OpenAuditTool. """ with warnings.catch_warnings(record=True): # Generate election from object storing pseudo command-line arguments. e = OpenAuditTool.Election() syn_args = Args() syn_args.election_dirname = '4-easy' syn_args.syn_type = '2' cli_syn.dispatch(e, syn_args) # Audit election e = OpenAuditTool.Election() OpenAuditTool_args = Args() OpenAuditTool_args.election_dirname = '4-easy' OpenAuditTool_args.election_name = '4-easy' OpenAuditTool_args.elections_root = './elections' OpenAuditTool_args.set_audit_seed = 42 OpenAuditTool_args.read_election_spec = False OpenAuditTool_args.read_reported = False OpenAuditTool_args.make_audit_orders = False OpenAuditTool_args.read_audited = False OpenAuditTool_args.audit = True OpenAuditTool_args.pause = False # added for new planner code: OpenAuditTool_args.num_winners = 2 OpenAuditTool_args.max_num_it = 100 OpenAuditTool_args.sample_by_size = False OpenAuditTool_args.use_discrete_rm = False OpenAuditTool_args.pick_county_func = "round_robin" cli_OpenAuditTool.dispatch(e, OpenAuditTool_args)
def irv_edge(election_dirname, config_dirname=None): """ Generate election 8-irv1 using syn2 then run audit on it with OpenAuditTool. """ with warnings.catch_warnings(record=True): # Generate election from object storing pseudo command-line arguments. e = OpenAuditTool.Election() syn_args = Args() syn_args.election_dirname = election_dirname syn_args.config_dirname = config_dirname syn_args.syn_type = '3' cli_syn.dispatch(e, syn_args) # Audit election e = OpenAuditTool.Election() OpenAuditTool_args = Args() OpenAuditTool_args.election_dirname = election_dirname OpenAuditTool_args.election_name = election_dirname OpenAuditTool_args.elections_root = './elections' OpenAuditTool_args.set_audit_seed = int(time.clock() * 100000) OpenAuditTool_args.read_election_spec = False OpenAuditTool_args.read_reported = False OpenAuditTool_args.make_audit_orders = False OpenAuditTool_args.read_audited = False OpenAuditTool_args.audit = True OpenAuditTool_args.pause = False # added for new planner code: OpenAuditTool_args.num_winners = 1 OpenAuditTool_args.max_num_it = 100 OpenAuditTool_args.sample_by_size = False OpenAuditTool_args.use_discrete_rm = False OpenAuditTool_args.pick_county_func = "round_robin" cli_OpenAuditTool.dispatch(e, OpenAuditTool_args)
def generate_segments(e, syn, low, high): """ Return list of random segments (r, s) where low <= r < s <= high. Number of segments returned is (high-low). Since r<s, does not return segments of the form (k, k). Intent is that cids are integers in range low <= cid <= high, and each segment yields a contest group covering cids r..s (inclusive). The segments "nest" -- given any two segments, either they are disjoint, or they are equal, or one contains the other. """ assert low <= high L = [] if low != high: L.append((low, high)) mid = syn.RandomState.choice(range(low, high)) L.extend(generate_segments(e, syn, low, mid)) L.extend(generate_segments(e, syn, mid + 1, high)) return L if __name__ == "__main__": e = OpenAuditTool.Election() args = cli_syn.parse_args() cli_syn.dispatch(e, args)