Voter Satisfaction Efficiency simulation tools for voting systems.
Project description
Voter Satisfaction Efficiency
These are some methods for running VSE (Voter Satisfaction Efficiency) simulations for various voting systems.
See Voter Satisfaction Efficiency FAQ for an explanation of the methods and results.
Installing the code
Requirements: Python 3.10+, NumPy, SciPy.
For notebook and library-style usage, install the package into the active environment:
python -m pip install .
To install directly from GitHub:
python -m pip install "vse-sim @ git+https://github.com/wclark/vse-sim.git@main"
That exposes the modern vse_sim package namespace:
from vse_sim import CsvBatch, Mav, PolyaModel, Score, baseRuns, medianRuns
The legacy top-level modules remain installed and importable for existing scripts and examples:
from vse import CsvBatch
from voterModels import PolyaModel
See Notebook and GitHub installation for Jupyter examples, GitHub install variants, and the future PyPI install path.
Testing uses doctests, which should make most things pretty self-documenting. For development, install the project in editable mode with the test, lint, and publishing helpers:
python -m pip install -e ".[dev,publish]"
Optionally install the local Git hooks:
pre-commit install
The main local readiness checks can also be run through Nox:
nox
Then run the legacy doctest examples:
python3 -m doctest methods.py
python3 -m doctest voterModels.py
python3 -m doctest dataClasses.py
python3 vse.py
Run the full test and coverage gate:
python -m pytest --doctest-modules --cov=. --cov-fail-under=100
To generate the same local coverage artifacts that CI uploads:
python -m pytest --doctest-modules --cov=. --cov-fail-under=100 --cov-report=term-missing:skip-covered --cov-report=xml:coverage.xml --cov-report=html:htmlcov --junitxml=pytest-results.xml
To run lint and style checks locally:
validate-pyproject pyproject.toml
python -m ruff check .
python -m ruff format --check .
To build and check package distributions locally:
python -m build
python -m twine check dist/*
check-wheel-contents dist/*.whl
To audit runtime dependencies for known vulnerabilities:
python -m pip_audit --skip-editable --progress-spinner off .
The GitHub Actions workflow runs the same coverage check on pushes, pull requests, and manual dispatches. It uploads the HTML coverage report plus machine-readable coverage and JUnit XML files as workflow artifacts.
The same workflow also builds the wheel and source distribution, installs the wheel into a clean environment, checks the distributions with Twine, and uploads the package artifacts.
The Lint and Style workflow validates pyproject.toml, then runs Ruff
formatting and lint checks on pushes, pull requests, and manual dispatches.
Security automation
GitHub Actions also runs CodeQL code scanning for Python on pushes, pull
requests, a weekly schedule, and manual dispatches. Dependabot checks Python and
GitHub Actions dependencies weekly. Dependency review blocks pull requests that
introduce moderate or higher vulnerabilities, and the dependency audit workflow
runs pip-audit against the project dependencies.
Running simulations
Try
$ python3
>>> from vse import CsvBatch, baseRuns, Mav, medianRuns, Score
>>> from voterModels import PolyaModel
>>> csvs = CsvBatch(PolyaModel(), [[Score(), baseRuns], [Mav(), medianRuns]], nvot=5, ncand=4, niter=3)
>>> csvs.saveFile()
and look for the results in SimResults1.csv
Repository layout
The root directory keeps the importable Python modules and common entry points so
older examples and direct imports keep working. Reference output snapshots live
in data/.
New code should prefer the vse_sim package namespace. The root-level modules
are kept for backward compatibility and as a useful regression target during the
packaging migration.
See Publishing checklist for the remaining steps before a
public pip install vse-sim release.
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.0.tar.gz.
File metadata
- Download URL: vse_sim-0.1.0.tar.gz
- Upload date:
- Size: 42.9 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
85f4d38f72f9a5ac516bbcb9d56cb5feb97397d3894904dc6ee70a94c92b3e2e
|
|
| MD5 |
04d75b5b40a05a760e831beb0d3fc83d
|
|
| BLAKE2b-256 |
c6f215ac8c0104214da5368f83842753902054085330813b35cd17e22b2fada1
|
Provenance
The following attestation bundles were made for vse_sim-0.1.0.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.0.tar.gz -
Subject digest:
85f4d38f72f9a5ac516bbcb9d56cb5feb97397d3894904dc6ee70a94c92b3e2e - Sigstore transparency entry: 1562777935
- Sigstore integration time:
-
Permalink:
wclark/vse-sim@e0c4b7fd80d95b8daf7d241b931ae3a9364a7007 -
Branch / Tag:
refs/tags/v0.1.0 - Owner: https://github.com/wclark
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
python-publish.yml@e0c4b7fd80d95b8daf7d241b931ae3a9364a7007 -
Trigger Event:
release
-
Statement type:
File details
Details for the file vse_sim-0.1.0-py3-none-any.whl.
File metadata
- Download URL: vse_sim-0.1.0-py3-none-any.whl
- Upload date:
- Size: 34.7 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 |
f844b3358e0496d9f07c2c3e6bba2c36ef9bd1590745cfaa638f930479fd2143
|
|
| MD5 |
4344554ae02dad6d7f0ed5ac659ef3cf
|
|
| BLAKE2b-256 |
f4a0339c39e637aef1c17c18c940f98da74d68c55848ddc83722f5fc2b0ec1ff
|
Provenance
The following attestation bundles were made for vse_sim-0.1.0-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.0-py3-none-any.whl -
Subject digest:
f844b3358e0496d9f07c2c3e6bba2c36ef9bd1590745cfaa638f930479fd2143 - Sigstore transparency entry: 1562777945
- Sigstore integration time:
-
Permalink:
wclark/vse-sim@e0c4b7fd80d95b8daf7d241b931ae3a9364a7007 -
Branch / Tag:
refs/tags/v0.1.0 - Owner: https://github.com/wclark
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
python-publish.yml@e0c4b7fd80d95b8daf7d241b931ae3a9364a7007 -
Trigger Event:
release
-
Statement type: