Voter Satisfaction Efficiency simulation tools for voting systems.
Project description
VSE Sim
VSE Sim provides Python tools for running Voter Satisfaction Efficiency (VSE) simulations for voting methods.
The package is published as vse-sim and imports as vse_sim. The original
top-level modules, such as vse and voterModels, are still installed for
older scripts and examples.
For background on the metric and published simulation results, see the Voter Satisfaction Efficiency FAQ.
Install
Install the released package from PyPI:
python -m pip install vse-sim
In a notebook, use %pip so the package is installed into the active kernel:
%pip install vse-sim
For reproducible notebooks or environments, pin a released version:
python -m pip install "vse-sim==0.1.4"
To install the latest code from GitHub instead of PyPI:
python -m pip install "vse-sim @ git+https://github.com/wclark/vse-sim.git@main"
Basic Usage
Prefer the modern vse_sim namespace for new code:
import vse_sim as vse
from vse_sim import Mav, PolyaModel, Score, baseRuns, medianRuns
from vse_sim.debug_dump import setDebug
setDebug(False)
results = vse.run_simulation(
PolyaModel(),
[[Score(), baseRuns], [Mav(), medianRuns]],
nvot=5,
ncand=4,
niter=3,
seed="quickstart",
)
results.df.head()
Work with results using pandas-native helpers and DataFrame aliases:
frame = results.dataframe
summary = results.summarize(group_by="method")
leaderboard = results.leaderboard()
report_tables = results.report()
axes = results.plot_vse(group_by="method", kind="barh")
Use the convenience helpers when you want DataFrames directly:
frame = vse.run_simulation_dataframe(
PolyaModel(),
[[Score(), baseRuns]],
nvot=5,
ncand=4,
niter=3,
seed="quickstart-frame",
)
voters = PolyaModel()(5, 4)
voter_utilities = voters.to_dataframe(wide=True)
ballots = Score().ballots_dataframe(voters)
scores = Score().results_dataframe(ballots)
For notebook work, the recommended starting point is the copy-paste template in Jupyter notebook template. It has one setup cell with imports, reusable report helpers, and plotting functions, followed by a larger simulation/reporting cell that produces summary tables, a heatmap, distribution plots, and method-level scoring tables.
CsvBatch remains available when you want the legacy batch object or metadata
CSV writer:
from vse_sim import CsvBatch
csvs = CsvBatch(
PolyaModel(),
[[Score(), baseRuns], [Mav(), medianRuns]],
nvot=5,
ncand=4,
niter=3,
seed="quickstart",
)
csvs.saveFile("quickstart-results")
Legacy imports remain supported:
from vse import CsvBatch
from voterModels import PolyaModel
See Installation and notebook usage for environment setup, including GitHub installs and notebook workflow notes.
Development
Create or activate a Python 3.10+ environment, then install the project in editable mode with development tools:
python -m pip install -e ".[dev,publish]"
Install local Git hooks if you want pre-commit checks:
pre-commit install
Run the default local quality gate:
nox
The default Nox gate validates metadata, runs Ruff format/lint checks, runs the Python 3.10 test and coverage suite, builds the package, validates distribution metadata and wheel contents, and audits dependencies.
Run Python 3.12 tests explicitly when that interpreter is available:
nox -s tests-3.12
Useful direct commands:
python -m pytest --doctest-modules --cov=. --cov-fail-under=100
python -m ruff format --check .
python -m ruff check .
python -m build
python -m twine check dist/*
check-wheel-contents dist/*.whl
python -m pip_audit --skip-editable --progress-spinner off .
Coverage reports are written to htmlcov/, coverage.xml, and
pytest-results.xml when the full coverage command is run.
Repository Layout
vse_sim/: modern package facade for new imports.- Root Python modules: legacy-compatible modules that remain importable.
test/: coverage and compatibility tests.data/: retained legacy/reference data artifacts.docs/: GitHub Pages content plus install and release notes.
See Release process for the PyPI publishing workflow.
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file vse_sim-0.1.4.tar.gz.
File metadata
- Download URL: vse_sim-0.1.4.tar.gz
- Upload date:
- Size: 53.0 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
3eb1cc7cde985288fa94ea3ad01ef62d376dbcb45ea474a93c21f35e5424a777
|
|
| MD5 |
954f5a7e331d3fc0a49b8a454b615d15
|
|
| BLAKE2b-256 |
4d97e91d34e33112114106fa0cbf2adc40eaed5a3e183592b7e019df7a84e375
|
Provenance
The following attestation bundles were made for vse_sim-0.1.4.tar.gz:
Publisher:
python-publish.yml on wclark/vse-sim
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
vse_sim-0.1.4.tar.gz -
Subject digest:
3eb1cc7cde985288fa94ea3ad01ef62d376dbcb45ea474a93c21f35e5424a777 - Sigstore transparency entry: 1564155363
- Sigstore integration time:
-
Permalink:
wclark/vse-sim@16f6b5a11f22d734f3bc93af62fe8b7308bcea9c -
Branch / Tag:
refs/tags/v0.1.4 - Owner: https://github.com/wclark
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
python-publish.yml@16f6b5a11f22d734f3bc93af62fe8b7308bcea9c -
Trigger Event:
release
-
Statement type:
File details
Details for the file vse_sim-0.1.4-py3-none-any.whl.
File metadata
- Download URL: vse_sim-0.1.4-py3-none-any.whl
- Upload date:
- Size: 40.0 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
275b8c5a90377a6be10acadb52e8cb98950db6ab3adeb39e37eb457817e30f01
|
|
| MD5 |
2c1aebc6c5c61f3e4207832d2affde37
|
|
| BLAKE2b-256 |
4240b9c8d706e1527c2bdc4eedbfa1e42401f16baa4966231876dab6b706d9cb
|
Provenance
The following attestation bundles were made for vse_sim-0.1.4-py3-none-any.whl:
Publisher:
python-publish.yml on wclark/vse-sim
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
vse_sim-0.1.4-py3-none-any.whl -
Subject digest:
275b8c5a90377a6be10acadb52e8cb98950db6ab3adeb39e37eb457817e30f01 - Sigstore transparency entry: 1564155376
- Sigstore integration time:
-
Permalink:
wclark/vse-sim@16f6b5a11f22d734f3bc93af62fe8b7308bcea9c -
Branch / Tag:
refs/tags/v0.1.4 - Owner: https://github.com/wclark
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
python-publish.yml@16f6b5a11f22d734f3bc93af62fe8b7308bcea9c -
Trigger Event:
release
-
Statement type: