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 76ef6abd4a76021c6dfa76908f3f608141f72e83 Author: Greg Stein <[email protected]> AuthorDate: Tue Jun 7 21:07:36 2022 -0500 switch to stv.tally() along with custom NAMES ordering --- v3/test/run_stv.py | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) diff --git a/v3/test/run_stv.py b/v3/test/run_stv.py index c33dcd6..fbde0b7 100755 --- a/v3/test/run_stv.py +++ b/v3/test/run_stv.py @@ -31,9 +31,11 @@ THIS_DIR = os.path.realpath(os.path.dirname(__file__)) sys.path.insert(0, os.path.dirname(THIS_DIR)) import steve.vtypes.stv -stv_tool = steve.vtypes.stv.load_stv() +# The stv module loads the stv_tool module. Tweak it. +stv_tool = steve.vtypes.stv.stv_tool stv_tool.VERBOSE = True + def main(mtgdir): rawfile = os.path.join(mtgdir, 'raw_board_votes.txt') labelfile = os.path.join(mtgdir, 'board_nominations.ini') @@ -42,14 +44,21 @@ def main(mtgdir): assert os.path.exists(labelfile) labelmap = stv_tool.read_labelmap(labelfile) + votes = stv_tool.read_votefile(rawfile).values() + # Construct a label-sorted list of names from the labelmap. names = [name for _, name in sorted(labelmap.items())] - # Turn votes using labels into by-name. - votes_by_label = stv_tool.read_votefile(rawfile).values() - votes = [[labelmap[l] for l in vote] for vote in votes_by_label] + kv = { + 'labelmap': labelmap, + 'seats': 9, + } + + # NOTE: for backwards-compat, the tally() function accepts a + # list of names with caller-defined sorting. + human, data = steve.vtypes.stv.tally(votes, kv, names) - candidates = stv_tool.run_stv(names, votes, 9) + candidates = data['raw'] candidates.print_results() ### ugh. for comparison, do it:
