Skip to content

Commit

Permalink
Fix mypy errors
Browse files Browse the repository at this point in the history
  • Loading branch information
peterrrock2 committed Aug 15, 2024
1 parent a06abef commit 35c3afd
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 5 deletions.
10 changes: 6 additions & 4 deletions src/votekit/elections/election_types/ranking/plurality_veto.py
Original file line number Diff line number Diff line change
Expand Up @@ -77,9 +77,11 @@ def __init__(
self.m = m
self.tiebreak = tiebreak

if self.tiebreak is None:
if self.tiebreak is None and profile.ballots is not None:
for ballot in profile.ballots:
if any(len(s) > 1 for s in ballot.ranking):
if ballot.ranking is not None and any(
len(s) > 1 for s in ballot.ranking
):
raise AttributeError(
"Found Ballots with ties but no tiebreak method was specified."
)
Expand Down Expand Up @@ -225,9 +227,9 @@ def _run_step(
if store_states:
eliminated = (frozenset(eliminated_cands),)

score_ballots = [
score_ballots = tuple(
ballot for ballot in new_profile.ballots if ballot.ranking
]
)
score_profile = PreferenceProfile(ballots=score_ballots)

if self.score_function:
Expand Down
2 changes: 1 addition & 1 deletion src/votekit/metrics/distances.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ def lp_dist(
pp2: PreferenceProfile,
p_value: Optional[Union[int, str]] = 1,
) -> int:
"""
r"""
Computes the :math:`L_p` distance between two profiles.
Use 'inf' for infinity norm.
Assumes both elections share the same candidates.
Expand Down

0 comments on commit 35c3afd

Please sign in to comment.