votekit 0.0.0__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- votekit-0.0.0/PKG-INFO +33 -0
- votekit-0.0.0/README.md +11 -0
- votekit-0.0.0/pyproject.toml +32 -0
- votekit-0.0.0/src/votekit/__init__.py +0 -0
- votekit-0.0.0/src/votekit/ballot.py +45 -0
- votekit-0.0.0/src/votekit/ballot_generator.py +641 -0
- votekit-0.0.0/src/votekit/cleaning.py +174 -0
- votekit-0.0.0/src/votekit/cvr_loaders.py +159 -0
- votekit-0.0.0/src/votekit/election_state.py +151 -0
- votekit-0.0.0/src/votekit/election_types.py +476 -0
- votekit-0.0.0/src/votekit/graphs/__init__.py +0 -0
- votekit-0.0.0/src/votekit/graphs/models.py +326 -0
- votekit-0.0.0/src/votekit/graphs/pairwise_comparison_graph.py +144 -0
- votekit-0.0.0/src/votekit/models.py +56 -0
- votekit-0.0.0/src/votekit/plots/__init__.py +0 -0
- votekit-0.0.0/src/votekit/plots/profile_plots.py +46 -0
- votekit-0.0.0/src/votekit/plotting/__init__.py +0 -0
- votekit-0.0.0/src/votekit/plotting/profile_plots.py +46 -0
- votekit-0.0.0/src/votekit/profile.py +201 -0
- votekit-0.0.0/src/votekit/utils.py +207 -0
votekit-0.0.0/PKG-INFO
ADDED
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
Metadata-Version: 2.1
|
|
2
|
+
Name: votekit
|
|
3
|
+
Version: 0.0.0
|
|
4
|
+
Summary: A Swiss Army Knife for computational social choice research
|
|
5
|
+
Author: MGGG
|
|
6
|
+
Author-email: engineering@mggg.org
|
|
7
|
+
Requires-Python: >=3.9,<3.12
|
|
8
|
+
Classifier: Programming Language :: Python :: 3
|
|
9
|
+
Classifier: Programming Language :: Python :: 3.9
|
|
10
|
+
Classifier: Programming Language :: Python :: 3.10
|
|
11
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
12
|
+
Requires-Dist: jinja2 (>=3.1.2,<4.0.0)
|
|
13
|
+
Requires-Dist: matplotlib (>=3.7.2,<4.0.0)
|
|
14
|
+
Requires-Dist: mypy (>=1.4.1,<2.0.0)
|
|
15
|
+
Requires-Dist: networkx (>=3.1,<4.0)
|
|
16
|
+
Requires-Dist: pandas (>=2.0.2,<3.0.0)
|
|
17
|
+
Requires-Dist: pandas-stubs (>=2.0.2.230605,<3.0.0.0)
|
|
18
|
+
Requires-Dist: pydantic (>=1.10.9,<2.0.0)
|
|
19
|
+
Requires-Dist: scipy (>=1.11.1,<2.0.0)
|
|
20
|
+
Description-Content-Type: text/markdown
|
|
21
|
+
|
|
22
|
+
## Development
|
|
23
|
+
|
|
24
|
+
This project requires [`poetry`](https://python-poetry.org/docs/#installation), and Python >= 3.9. (This version chosen somewhat arbitrarily.)
|
|
25
|
+
|
|
26
|
+
To get up and running, run `poetry install` from within the project directory to install all dependencies. This will create a `.venv` directory that will contain dependencies. You can interact with this virtualenv by running your commands prefixed with `poetry run`, or use `poetry shell` to activate the virtualenv.
|
|
27
|
+
|
|
28
|
+
Once you've run `poetry install`, if you run `poetry run pre-commit install` it will install code linting hooks that will run on every commit. This helps ensure code quality.
|
|
29
|
+
|
|
30
|
+
To run tests run `poetry run pytest` or `./run_tests.sh` (the latter will generate a coverage report).
|
|
31
|
+
|
|
32
|
+
To release, run `poetry publish --build`
|
|
33
|
+
|
votekit-0.0.0/README.md
ADDED
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
## Development
|
|
2
|
+
|
|
3
|
+
This project requires [`poetry`](https://python-poetry.org/docs/#installation), and Python >= 3.9. (This version chosen somewhat arbitrarily.)
|
|
4
|
+
|
|
5
|
+
To get up and running, run `poetry install` from within the project directory to install all dependencies. This will create a `.venv` directory that will contain dependencies. You can interact with this virtualenv by running your commands prefixed with `poetry run`, or use `poetry shell` to activate the virtualenv.
|
|
6
|
+
|
|
7
|
+
Once you've run `poetry install`, if you run `poetry run pre-commit install` it will install code linting hooks that will run on every commit. This helps ensure code quality.
|
|
8
|
+
|
|
9
|
+
To run tests run `poetry run pytest` or `./run_tests.sh` (the latter will generate a coverage report).
|
|
10
|
+
|
|
11
|
+
To release, run `poetry publish --build`
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
[tool.poetry]
|
|
2
|
+
name = "votekit"
|
|
3
|
+
version = "0.0.0"
|
|
4
|
+
description = "A Swiss Army Knife for computational social choice research"
|
|
5
|
+
authors = ["MGGG <engineering@mggg.org>"]
|
|
6
|
+
readme = "README.md"
|
|
7
|
+
|
|
8
|
+
[tool.poetry.dependencies]
|
|
9
|
+
python = "^3.9,<3.12"
|
|
10
|
+
scipy = "^1.11.1"
|
|
11
|
+
pandas = "^2.0.2"
|
|
12
|
+
mypy = "^1.4.1"
|
|
13
|
+
pydantic = "^1.10.9"
|
|
14
|
+
pandas-stubs = "^2.0.2.230605"
|
|
15
|
+
networkx = "^3.1"
|
|
16
|
+
jinja2 = "^3.1.2"
|
|
17
|
+
matplotlib = "^3.7.2"
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
[tool.poetry.group.dev.dependencies]
|
|
21
|
+
ruff = "^0.0.275"
|
|
22
|
+
black = "^23.3.0"
|
|
23
|
+
pytest = "^7.4.0"
|
|
24
|
+
pytest-cov = "^4.1.0"
|
|
25
|
+
pre-commit = "^3.3.3"
|
|
26
|
+
|
|
27
|
+
[build-system]
|
|
28
|
+
requires = ["poetry-core"]
|
|
29
|
+
build-backend = "poetry.core.masonry.api"
|
|
30
|
+
|
|
31
|
+
[tool.ruff]
|
|
32
|
+
line-length = 100
|
|
File without changes
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
from pydantic import BaseModel
|
|
2
|
+
from typing import Optional
|
|
3
|
+
from fractions import Fraction
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
class Ballot(BaseModel):
|
|
7
|
+
"""
|
|
8
|
+
id (optional string): assigned ballot id
|
|
9
|
+
ranking (list): list of candidate ranking
|
|
10
|
+
weight (float/fraction): weight assigned to a given a ballot
|
|
11
|
+
voters (optional list): list of voters who cast a given a ballot
|
|
12
|
+
"""
|
|
13
|
+
|
|
14
|
+
id: Optional[str] = None
|
|
15
|
+
ranking: list[set]
|
|
16
|
+
weight: Fraction
|
|
17
|
+
voters: Optional[set[str]] = None
|
|
18
|
+
|
|
19
|
+
class Config:
|
|
20
|
+
arbitrary_types_allowed = True
|
|
21
|
+
|
|
22
|
+
def __eq__(self, other):
|
|
23
|
+
# Check type
|
|
24
|
+
if not isinstance(other, Ballot):
|
|
25
|
+
return False
|
|
26
|
+
|
|
27
|
+
# Check id
|
|
28
|
+
if self.id is not None:
|
|
29
|
+
if self.id != other.id:
|
|
30
|
+
return False
|
|
31
|
+
|
|
32
|
+
# Check ranking
|
|
33
|
+
if self.ranking != other.ranking:
|
|
34
|
+
return False
|
|
35
|
+
|
|
36
|
+
# Check weight
|
|
37
|
+
if self.weight != other.weight:
|
|
38
|
+
return False
|
|
39
|
+
|
|
40
|
+
# Check voters
|
|
41
|
+
if self.voters is not None:
|
|
42
|
+
if self.voters != other.voters:
|
|
43
|
+
return False
|
|
44
|
+
|
|
45
|
+
return True
|