This is an automated email from the ASF dual-hosted git repository.

gstein pushed a commit to branch trunk
in repository https://gitbox.apache.org/repos/asf/steve.git

commit 9d905cb877c9892b0323d48e6b5229b4bf417218
Author: Greg Stein <[email protected]>
AuthorDate: Thu Mar 5 00:37:24 2026 -0600

    Improve the trimming of empty votes in an STV Issue.
---
 v3/steve/vtypes/stv.py | 9 ++++++---
 1 file changed, 6 insertions(+), 3 deletions(-)

diff --git a/v3/steve/vtypes/stv.py b/v3/steve/vtypes/stv.py
index a225594..03f85a1 100644
--- a/v3/steve/vtypes/stv.py
+++ b/v3/steve/vtypes/stv.py
@@ -49,6 +49,9 @@ def tally(votestrings, kv):
         - 'seats': Integer number of seats to elect.
     """
 
+    # Trim the incoming votestrings: no empty strings:
+    trimmed = [ s for vs in votestrings if (s := vs.strip()) ]
+
     # kv['labelmap'] should be: LABEL: NAME
     # for example: { 'a': 'John Doe', }
     labelmap = kv['labelmap']
@@ -59,8 +62,8 @@ def tally(votestrings, kv):
     # Remap all votestrings from comma-separated label strings into sequences 
of NAMEs.
     # Split on commas, strip whitespace, and filter out empty parts.
     votes = [
-        [labelmap[label.strip()] for label in v.split(',') if label.strip()]
-        for v in votestrings
+        [labelmap[l] for label in vs.split(',') if (l := label.strip())]
+        for vs in trimmed
     ]
 
     # Use sorted names for reproducible ordering.
@@ -79,6 +82,6 @@ def tally(votestrings, kv):
         # Carry the input configuration and votestrings into the result.
         'labelmap': labelmap,
         'seats': seats,
-        'votestrings': [ vs for vs in votestrings if vs ],  # Eliminate empty
+        'votestrings': trimmed,
     }
     return human, data

Reply via email to