diff --git a/html/index.js b/html/index.js index 8ea8bfe..3a38a89 100644 --- a/html/index.js +++ b/html/index.js @@ -213,9 +213,12 @@ async function clickCount() { if (countCard.state === py.pyRCV2.model.CandidateState.WITHDRAWN) { elTd.classList.add('excluded'); elTd.innerText = 'WD'; - } else if (countCard.state === py.pyRCV2.model.CandidateState.EXCLUDED || countCard.state === py.pyRCV2.model.CandidateState.EXCLUDING) { + } else if (countCard.state === py.pyRCV2.model.CandidateState.EXCLUDED) { elTd.classList.add('excluded'); elTd.innerText = 'Ex'; + } else if (countCard.state === py.pyRCV2.model.CandidateState.EXCLUDING) { + elTd.classList.add('excluded'); + elTd.innerText = countCard.votes; } else { elTd.innerText = countCard.votes; } diff --git a/html/worker.js b/html/worker.js index 14aa8ba..b0e2d76 100644 --- a/html/worker.js +++ b/html/worker.js @@ -34,6 +34,8 @@ onmessage = function(evt) { py.pyRCV2.numbers.set_dps(evt.data.fixedDPs); } + let ppDP = evt.data.fixedDPs > 2 ? 2 : evt.data.fixedDPs; + let election = py.pyRCV2.blt.readBLT(evt.data.data); postMessage({'type': 'init', 'election': { 'candidates': election.candidates.map(c => c.py_name) @@ -63,20 +65,20 @@ onmessage = function(evt) { postMessage({'type': 'result', 'result': { 'comment': result.comment, 'candidates': result.candidates.py_items().map(([c, cc]) => [c.py_name, { - 'transfers': cc.transfers.pp(2), - 'votes': cc.votes.pp(2), + 'transfers': cc.transfers.pp(ppDP), + 'votes': cc.votes.pp(ppDP), 'state': cc.state }]), 'exhausted': { - 'transfers': result.exhausted.transfers.pp(2), - 'votes': result.exhausted.votes.pp(2) + 'transfers': result.exhausted.transfers.pp(ppDP), + 'votes': result.exhausted.votes.pp(ppDP) }, 'loss_fraction': { - 'transfers': result.loss_fraction.transfers.pp(2), - 'votes': result.loss_fraction.votes.pp(2) + 'transfers': result.loss_fraction.transfers.pp(ppDP), + 'votes': result.loss_fraction.votes.pp(ppDP) }, - 'total': result.total.pp(2), - 'quota': result.quota.pp(2) + 'total': result.total.pp(ppDP), + 'quota': result.quota.pp(ppDP) }}); // Step election @@ -89,20 +91,20 @@ onmessage = function(evt) { postMessage({'type': 'result', 'result': { 'comment': result.comment, 'candidates': result.candidates.py_items().map(([c, cc]) => [c.py_name, { - 'transfers': cc.transfers.pp(2), - 'votes': cc.votes.pp(2), + 'transfers': cc.transfers.pp(ppDP), + 'votes': cc.votes.pp(ppDP), 'state': cc.state }]), 'exhausted': { - 'transfers': result.exhausted.transfers.pp(2), - 'votes': result.exhausted.votes.pp(2) + 'transfers': result.exhausted.transfers.pp(ppDP), + 'votes': result.exhausted.votes.pp(ppDP) }, 'loss_fraction': { - 'transfers': result.loss_fraction.transfers.pp(2), - 'votes': result.loss_fraction.votes.pp(2) + 'transfers': result.loss_fraction.transfers.pp(ppDP), + 'votes': result.loss_fraction.votes.pp(ppDP) }, - 'total': result.total.pp(2), - 'quota': result.quota.pp(2) + 'total': result.total.pp(ppDP), + 'quota': result.quota.pp(ppDP) }}); } } diff --git a/pyRCV2/method/base_stv.py b/pyRCV2/method/base_stv.py index 38183af..36b90aa 100644 --- a/pyRCV2/method/base_stv.py +++ b/pyRCV2/method/base_stv.py @@ -157,9 +157,7 @@ class BaseSTVCounter: # Are there just enough candidates to fill all the seats? if self.options['bulk_elect']: - if self.num_elected + sum(1 for c, cc in self.candidates.items() if cc.state == CandidateState.HOPEFUL) <= self.election.seats: - # TODO: Sort by size - + if self.num_elected + sum(1 for c, cc in self.candidates.items() if cc.state == CandidateState.HOPEFUL or cc.state == CandidateState.EXCLUDING) <= self.election.seats: # Declare elected all remaining candidates for candidate, count_card in self.candidates.items(): if count_card.state == CandidateState.HOPEFUL: