Skip to main content

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.1"

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.frame.head()

Work with results using pandas-native helpers:

summary = results.summarize(group_by="method")
leaderboard = results.leaderboard()
report_tables = results.report()
axes = results.plot_vse(group_by="method", kind="barh")

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. For a broader copy-paste cookbook that exercises the package surface from Jupyter, see Jupyter notebook examples.

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

vse_sim-0.1.1.tar.gz (50.6 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

vse_sim-0.1.1-py3-none-any.whl (37.9 kB view details)

Uploaded Python 3

File details

Details for the file vse_sim-0.1.1.tar.gz.

File metadata

  • Download URL: vse_sim-0.1.1.tar.gz
  • Upload date:
  • Size: 50.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for vse_sim-0.1.1.tar.gz
Algorithm Hash digest
SHA256 a552c98291b66125c683e47229b49c52090913da0fd76fdd5d7bae5959df9c1a
MD5 a73f5f5407612c2647de986ef9c3a45d
BLAKE2b-256 725811f7df252771e3d2cb12fd80738c2ad4c771de56640d2502498989374633

See more details on using hashes here.

Provenance

The following attestation bundles were made for vse_sim-0.1.1.tar.gz:

Publisher: python-publish.yml on wclark/vse-sim

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file vse_sim-0.1.1-py3-none-any.whl.

File metadata

  • Download URL: vse_sim-0.1.1-py3-none-any.whl
  • Upload date:
  • Size: 37.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for vse_sim-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 d2f08fc31ff3c0f7f3efe2d082cfc7e35ac9501ed4eef4c17a421dd506d8d0e1
MD5 eb175221d8e0ca06aa85eb03b6a9db16
BLAKE2b-256 014d01643117840fd82e81d74fd1a412d69a1ef21ff863d14e26e3b03d056976

See more details on using hashes here.

Provenance

The following attestation bundles were made for vse_sim-0.1.1-py3-none-any.whl:

Publisher: python-publish.yml on wclark/vse-sim

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page