Skip to content

Commit

Permalink
Oneaudit (#98)
Browse files Browse the repository at this point in the history
* WIP: improving Dominion support, progress towards ONEAudit integration

* WIP: Dominion tools

* Dominion "multiple card" fix, Testcase Regression Fixes (#91)

* This commit fixes issues with the record_id not always set, and the use_current flag never being used

* Fix earlier issue where only the first 'Card' in the Dominion output was parsed, added associated unit tests

---------

Co-authored-by: Philip B. Stark <[email protected]>

* WIP: ONEAudit integration. Dominion mvr retrieval improvements

* WIP: Dominion card numbering, construct pool_means only for pool==True CVRs

* WIP: working but sample size estimation needs to be improved

* ENH: ONEAudit seems to be working, including sample size estimation.

* ENH: improve documentation in ONEAudit notebook; minor bug fixes

* improving ability to test sample sizes (#97)

* Oneaudit (#92)

* WIP: improving Dominion support, progress towards ONEAudit integration

* WIP: Dominion tools

* Dominion "multiple card" fix, Testcase Regression Fixes (#91)

* This commit fixes issues with the record_id not always set, and the use_current flag never being used

* Fix earlier issue where only the first 'Card' in the Dominion output was parsed, added associated unit tests

---------

Co-authored-by: Philip B. Stark <[email protected]>

* WIP: ONEAudit integration. Dominion mvr retrieval improvements

* WIP: Dominion card numbering, construct pool_means only for pool==True CVRs

* WIP: working but sample size estimation needs to be improved

* ENH: ONEAudit seems to be working, including sample size estimation.

* ENH: improve documentation in ONEAudit notebook; minor bug fixes

---------

Co-authored-by: bsheehan-SF-RLA <[email protected]>

* Added missing parameter in supermajority assertion and changed np.infty (no longer supported) to np.inf (#93)

* Dominion (#94)

* BUG: change logic for parsing Dominion ranks, fix minor bugs in supermajority

* BUG: revise unit test for Dominion to match new mark processing

* ENH: logic for SF treatment of multiple ranks assigned to same candidate in IRV

* ENH: logic for SF treatment of multiple ranks assigned to same candidate in IRV

* ENH: logic for SF treatment of multiple ranks assigned to same candidate in IRV

* ENH: logic for SF treatment of multiple ranks assigned to same candidate in IRV

* Optimizations for Dominion.sample_from_cvrs and CVR.consistent_sampling (#95)

* Speed optimizations for Dominion.sample_from_cvrs() and CVR.consistent_sampling()

* Unit tests for optimzations in last commit, should pass on original and optimized code

---------

Co-authored-by: bsheehan-SF-RLA <[email protected]>
Co-authored-by: Alexander Ek <[email protected]>

---------

Co-authored-by: bsheehan-SF-RLA <[email protected]>
Co-authored-by: Alexander Ek <[email protected]>
  • Loading branch information
3 people authored Nov 28, 2024
1 parent 42f27ea commit 895cca1
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 81 deletions.
9 changes: 3 additions & 6 deletions shangrla/core/Audit.py
Original file line number Diff line number Diff line change
Expand Up @@ -2636,7 +2636,7 @@ def __init__(

def __str__(self):
return str(self.__dict__)

def find_sample_size(
self,
audit: object = None,
Expand Down Expand Up @@ -2675,7 +2675,7 @@ def find_sample_size(
if mvr_sample is not None: # process the MVRs/CVRs to get data appropriate to each assertion
data, u = a.mvrs_to_data(mvr_sample, cvr_sample)
elif self.audit_type == Audit.AUDIT_TYPE.ONEAUDIT:
data, u = a.mvrs_to_data(cvr_sample, cvr_sample)
data, u = a.mvrs_to_data(cvr_sample, cvr_sample)
self.sample_size = max(
self.sample_size,
a.find_sample_size(
Expand Down Expand Up @@ -2737,8 +2737,7 @@ def check_cards(cls, contests: Collection["Contest"], cvrs: Collection["CVR"], f
if not force:
raise ValueError(f'{found} cards contain contest {c} but upper bound is {con.cards}')
else:
warnings.warn(f'{found} cards contain contest {c} but upper bound is {con.cards}')

warnings.warn(f'{found} cards contain contest {c} but upper bound is {con.cards}')
con.cards = max(con.cards, found) if force else con.cards


Expand All @@ -2748,8 +2747,6 @@ def tally(cls, con_dict: dict = None, cvr_list: "Collection[CVR]" = None, enforc
Tally the votes in the contests in con_dict from a collection of CVRs.
Only tallies plurality, multi-winner plurality, supermajority, and approval contests.
If
Parameters
----------
con_dict: dict
Expand Down
77 changes: 2 additions & 75 deletions tests/formats/test_Dominion.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,8 +62,8 @@ def test_read_cvrs_old_format_rules_enforced(self):
# get_vote_for("111", "1") is now False.
assert cvr_1.votes["111"] == {"6": 1}
assert cvr_1.get_vote_for("111", "6")
assert cvr_1.get_vote_for("111", "1") is False
assert cvr_1.get_vote_for("111", "999") is False
assert not cvr_1.get_vote_for("111", "1")
assert not cvr_1.get_vote_for("111", "999")
assert cvr_2.id == "60009_3_21"
assert cvr_2.tally_pool == "60009_3"
assert not cvr_2.pool, f"{cvr_2.pool=}"
Expand Down Expand Up @@ -274,79 +274,6 @@ def test_sample_from_cvrs(self):
'12-102-15',
]

# def test_make_contest_dict(self):
# cvr_dir = Path("data/SF_CVR_Export_20240311150227")
# contest_manifest = cvr_dir / "ContestManifest.json"
# candidate_manifest = cvr_dir / "CandidateManifest.json"

# cvr_list = Dominion.read_cvrs_directory(
# cvr_dir, use_current=True, include_groups=(2,)
# )

# c = make_contest_dict(
# cvr_list,
# contest_manifest,
# candidate_manifest,
# {},
# )

# assert c["8"]["name"] == "DEM CCC DISTRICT 17"
# assert c["8"]["risk_limit"] == pytest.approx(0.05)
# assert c["8"]["cards"] == 82019
# assert c["8"]["choice_function"] == Contest.SOCIAL_CHOICE_FUNCTION.PLURALITY
# assert c["8"]["n_winners"] == 14
# assert c["8"]["candidates"] == [
# "24",
# "25",
# "26",
# "27",
# "28",
# "29",
# "30",
# "31",
# "32",
# "33",
# "34",
# "35",
# "36",
# "37",
# "38",
# "39",
# "40",
# "41",
# "42",
# "43",
# "44",
# "45",
# "46",
# "47",
# "48",
# "49",
# "50",
# "51",
# "52",
# "53",
# "241",
# ]
# assert c["8"]["winner"] == [
# "49",
# "30",
# "27",
# "52",
# "36",
# "26",
# "32",
# "45",
# "28",
# "51",
# "39",
# "29",
# "44",
# "35",
# ]
# assert c["8"]["assertion_file"] is None
# assert c["8"]["audit_type"] == "CARD_COMPARISON"


##########################################################################################
if __name__ == "__main__":
Expand Down

0 comments on commit 895cca1

Please sign in to comment.