Skip to content

Commit

Permalink
black isort
Browse files Browse the repository at this point in the history
  • Loading branch information
the-Bruce committed Mar 5, 2024
1 parent a5a6f2c commit 21be289
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 12 deletions.
10 changes: 6 additions & 4 deletions votes/stv.py
Original file line number Diff line number Diff line change
Expand Up @@ -256,7 +256,9 @@ def full_election(self):
pass

def winners(self):
return list(map(
attrgetter("id"),
filter(lambda x: x.status == States.ELECTED, self.candidates),
))
return list(
map(
attrgetter("id"),
filter(lambda x: x.status == States.ELECTED, self.candidates),
)
)
16 changes: 8 additions & 8 deletions votes/tests/test_stv.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,19 +59,19 @@ def test_two_available_three():
def test_corner_case():
c = {1, 2, 3, 4, 5, 6, 7, 8}
v = (
[(1, 2, 3, 4, 5, 6, 7, 8)] +
[(3, 4, 5, 6, 7, 8, 1, 2)] * 36 +
[(4, 5, 6, 7, 8, 1, 2, 3)] * 6 +
[(5, 6, 7, 8, 1, 2, 3, 4)] * 13 +
[(6, 7, 8, 1, 2, 3, 4, 5)] * 4 +
[(7, 8, 1, 2, 3, 4, 5, 6)] * 2 +
[(8, 1, 2, 3, 4, 5, 6, 7)] * 4
[(1, 2, 3, 4, 5, 6, 7, 8)]
+ [(3, 4, 5, 6, 7, 8, 1, 2)] * 36
+ [(4, 5, 6, 7, 8, 1, 2, 3)] * 6
+ [(5, 6, 7, 8, 1, 2, 3, 4)] * 13
+ [(6, 7, 8, 1, 2, 3, 4, 5)] * 4
+ [(7, 8, 1, 2, 3, 4, 5, 6)] * 2
+ [(8, 1, 2, 3, 4, 5, 6, 7)] * 4
)
e = Election(c, v, 2)
e.full_election()
# Bug caused the second round to erroneously tiebreak between all people after electing 3.
# Check this isn't reintroduced
assert e.actlog[2]['type'] != "tiebreak"
assert e.actlog[2]["type"] != "tiebreak"
assert sorted(e.winners()) == [3, 5]


Expand Down

0 comments on commit 21be289

Please sign in to comment.