Skip to content

Commit

Permalink
BUG: change logic for parsing Dominion ranks, fix minor bugs in super…
Browse files Browse the repository at this point in the history
…majority
  • Loading branch information
pbstark committed Nov 12, 2024
1 parent bb8b8a3 commit f9bee74
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 8 deletions.
5 changes: 4 additions & 1 deletion examples/ONEAudit-demo.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,7 @@
"+ Read manual interpretations of the cards (MVRs)\n",
"+ Calculate attained risk for each assorter\n",
" - Use ~2EZ to deal with phantom CVRs or cards; the treatment depends on whether `use_style == True`\n",
" - If a sampled card cannot be found/retrieved, use the phantom-to-zombie transformation for it\n",
" - Use the pooled assorter means for cards in pooled batches\n",
"+ Report\n",
"+ Estimate incremental sample size if any assorter nulls have not been rejected\n",
Expand Down Expand Up @@ -1006,7 +1007,9 @@
"cell_type": "markdown",
"metadata": {},
"source": [
"## Read the audited sample data"
"# Read the audited sample data.\n",
"\n",
"## Any ballot that cannot be retrieved should be marked as a \"zombie\" (treated in the least favorable way for every contest it might contain)."
]
},
{
Expand Down
9 changes: 5 additions & 4 deletions shangrla/core/Audit.py
Original file line number Diff line number Diff line change
Expand Up @@ -1931,7 +1931,8 @@ def make_plurality_assertions(
@classmethod
def make_supermajority_assertion(
cls,
contest,
contest: object=None,
share_to_win: float = 1/2,
winner: str = None,
loser: list = None,
test: callable = None,
Expand Down Expand Up @@ -1962,12 +1963,12 @@ def make_supermajority_assertion(
-----------
contest:
contest object instance to which the assertion applies
share_to_win: float
fraction of the valid votes the winner must get to win
winner:
identifier of winning candidate
loser: list
list of identifiers of losing candidate(s)
share_to_win: float
fraction of the valid votes the winner must get to win
test: instance of NonnegMean
risk function for the contest
estim: an estimation method of NonnegMean
Expand Down Expand Up @@ -2218,7 +2219,7 @@ def set_all_margins_from_cvrs(
`assertion.contest.audit_type==Audit.AUDIT_TYPE.POLLING`
or `assertion.contest.audit_type in [Audit.AUDIT_TYPE.CARD_COMPARISON, Audit.AUDIT_TYPE.ONEAUDIT]`
"""
min_margin = np.infty
min_margin = np.inf
for c, con in contests.items():
con.margins = {}
for a, asn in con.assertions.items():
Expand Down
5 changes: 2 additions & 3 deletions shangrla/formats/Dominion.py
Original file line number Diff line number Diff line change
Expand Up @@ -154,9 +154,8 @@ def read_cvrs(
for con in _selector:
contest_votes = {}
for mark in con["Marks"]:
contest_votes[str(mark["CandidateId"])] = (
mark["Rank"] if (mark["IsVote"] or not enforce_rules) else 0
)
if (mark["IsVote"] or not enforce_rules):
contest_votes[str(mark["CandidateId"])] = mark["Rank"]
votes[str(con["Id"])] = contest_votes
# If RecordId is obfuscated, extract it from the ImageMask
record_id = c["RecordId"]
Expand Down

0 comments on commit f9bee74

Please sign in to comment.