You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@steve.apache.org by gs...@apache.org on 2026/02/03 06:03:21 UTC

(steve) branch trunk updated (ff8981d -> c1510a8)

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

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


    from ff8981d  Expand election data for EZT rendering.
     new 652dcb7  feat: update STV tally for comma-separated votestrings and kv versioning
     new c1510a8  ignore aider stuffs

The 2 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.


Summary of changes:
 .gitignore             |  1 +
 v3/steve/vtypes/stv.py | 40 +++++++++++++++++++++-------------------
 2 files changed, 22 insertions(+), 19 deletions(-)


(steve) 01/02: feat: update STV tally for comma-separated votestrings and kv versioning

Posted by gs...@apache.org.
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 652dcb7a02fea4dbd56d16e8b03c6104afb460b5
Author: Greg Stein <gs...@gmail.com>
AuthorDate: Mon Feb 2 23:54:02 2026 -0600

    feat: update STV tally for comma-separated votestrings and kv versioning
    
    Co-authored-by: aider (openrouter/x-ai/grok-code-fast-1) <ai...@aider.chat>
---
 v3/steve/vtypes/stv.py | 40 +++++++++++++++++++++-------------------
 1 file changed, 21 insertions(+), 19 deletions(-)

diff --git a/v3/steve/vtypes/stv.py b/v3/steve/vtypes/stv.py
index f82f891..72755bb 100644
--- a/v3/steve/vtypes/stv.py
+++ b/v3/steve/vtypes/stv.py
@@ -37,30 +37,32 @@ def load_stv():
 stv_tool = load_stv()
 
 
-def tally(votestrings, kv, names=None):
-    "Run the STV tally process."
-
-    # NOTE: the NAMES parameter is usually not passed, but is available
-    # to compare operation against custom ordering of NAMES in the
-    # LABELMAP. This function takes a specific approach, which differs
-    # from historical orderings.
-
+def tally(votestrings, kv):
+    """
+    Run the STV tally process.
+    
+    votestrings: List of strings, each representing a voter's preferences as comma-separated labels
+                 (e.g., 'a,b,c' for votes in order of preference). Labels must match keys in kv['labelmap'].
+    kv: Dict containing STV configuration.
+        - 'version': Integer version of the kv format (currently 1).
+        - 'labelmap': Dict mapping single-character labels to candidate names (e.g., {'a': 'Alice'}).
+        - 'seats': Integer number of seats to elect.
+    """
+    
     # kv['labelmap'] should be: LABEL: NAME
     # for example: { 'a': 'John Doe', }
     labelmap = kv['labelmap']
-
+    
     seats = kv['seats']
-
-    # Remap all votestrings from a string sequence of label characters,
-    # into a sequence of NAMEs.
-    votes = [[labelmap[c] for c in v] for v in votestrings]
-
-    # NOTE: it is important that the names are sorted, to create a
-    # reproducible list of names. Callers may specify a custom ordering.
-    if names is None:
-        names = sorted(labelmap.values())
+    
+    # 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]
+    
+    # Use sorted names for reproducible ordering.
+    names = sorted(labelmap.values())
     results = stv_tool.run_stv(names, votes, seats)
-
+    
     human = '\n'.join(
         f'{c.name:40}{" " if c.status == stv_tool.ELECTED else " not "}elected'
         for c in results.l


(steve) 02/02: ignore aider stuffs

Posted by gs...@apache.org.
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 c1510a8b4a7d55aa7445b6f2367a13ec3c70f1fe
Author: Greg Stein <gs...@gmail.com>
AuthorDate: Mon Feb 2 23:54:42 2026 -0600

    ignore aider stuffs
---
 .gitignore | 1 +
 1 file changed, 1 insertion(+)

diff --git a/.gitignore b/.gitignore
index 630104f..44c1a49 100644
--- a/.gitignore
+++ b/.gitignore
@@ -55,3 +55,4 @@ pip-log.txt
 target/
 output/
 .DS_Store
+.aider*