Skip to content

Commit 3dc6089

Browse files
committed
feat(fptp): adding notice when ranked ballots counted with FPTP
1 parent 4ab9977 commit 3dc6089

2 files changed

Lines changed: 15 additions & 1 deletion

File tree

abiflib/fptp_tally.py

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ def FPTP_result_from_abifmodel(abifmodel):
6464

6565
top_pct = (maxtop / total_valid_votes) * 100 if total_valid_votes > 0 else 0
6666

67-
return {
67+
result = {
6868
'toppicks': toppicks,
6969
'winners': winners,
7070
'top_qty': maxtop,
@@ -74,6 +74,19 @@ def FPTP_result_from_abifmodel(abifmodel):
7474
'invalid_ballots': invalid_ballots
7575
}
7676

77+
# Add notice if this election uses ranked ballots
78+
notices = []
79+
if abifmodel.get('metadata', {}).get('ballot_type') == 'ranked':
80+
notices.append({
81+
'notice_type': 'note',
82+
'short': 'Only using first-choices on ranked ballots'
83+
})
84+
85+
if notices:
86+
result['notices'] = notices
87+
88+
return result
89+
7790

7891
def get_FPTP_report(abifmodel):
7992
"""Generate FPTP report from the ABIF model."""

docs/TODO.org

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,4 +13,5 @@ This is a very incomplete list of incomplete tasks for abiftool
1313
- [ ] Create bifhub and merge fetchmgr.py into it (see awt/docs/bifhub.md)
1414
- [ ] Set ballot_type/tally_method when converting real elections to ABIF
1515
e.g. sftxt_fmt.py, preflib_fmt.py, nycdem_fmt.py, debvote_fmt.py, etc.
16+
- [ ] Update fetchmgr.py to automatically set ballot_type metadata during import
1617
- Moar [[Code hygiene]] (see above)

0 commit comments

Comments
 (0)