Skip to content

Commit 8532a15

Browse files
committed
migrating from setup.py to pyproject.toml
1 parent b1809d0 commit 8532a15

9 files changed

Lines changed: 168 additions & 104 deletions

File tree

.github/workflows/python-tests.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ jobs:
2121
strategy:
2222
fail-fast: false
2323
matrix:
24-
python-version: ["3.8", "3.9", "3.10", "3.11", "3.12"]
24+
python-version: ["3.9", "3.10", "3.11", "3.12"]
2525

2626
steps:
2727
- uses: actions/checkout@v3

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ build/
1010
*.egg-info/
1111

1212
.coverage
13+
.tox
1314

1415
# Documentation artifacts
1516
_build/

error_parity/_version.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
"""File to keep the package version in one place."""
2-
__version__ = "0.3.11"
2+
__version__ = "0.3.12"
33
__version_info__ = tuple(__version__.split("."))

error_parity/cvxpy_utils.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -416,6 +416,14 @@ def group_positive_prediction_rate(group_idx: int):
416416

417417
# Run solver
418418
prob.solve(solver=cp.ECOS, abstol=SOLUTION_TOLERANCE, feastol=SOLUTION_TOLERANCE)
419+
420+
# NOTE: ECOS solver has been deprecated in favor of CLARABEL in cvxpy 1.3.2+
421+
# https://www.cvxpy.org/updates/index.html?h=ecos#ecos-deprecation
422+
# prob.solve(
423+
# solver=cp.CLARABEL,
424+
# tol_gap_abs=SOLUTION_TOLERANCE,
425+
# tol_feas=SOLUTION_TOLERANCE,
426+
# )
419427
# NOTE: these tolerances are supposed to be smaller than the default np.isclose tolerances
420428
# (useful when comparing if two points are the same, within the cvxpy accuracy tolerance)
421429

pyproject.toml

Lines changed: 152 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,152 @@
1+
[build-system]
2+
requires = ["setuptools>=77.0", "wheel"]
3+
build-backend = "setuptools.build_meta"
4+
5+
[project]
6+
name = "error-parity"
7+
description = "Achieve error-rate parity between protected groups for any predictor"
8+
license = "MIT"
9+
license-files = ["LICENSE"]
10+
authors = [
11+
{ name = "AndreFCruz" },
12+
]
13+
14+
# Keywords to be used by PyPI search
15+
keywords = ["ml", "optimization", "fairness", "error-parity", "equal-odds"]
16+
17+
# PyPI classifiers, see https://pypi.org/classifiers/
18+
classifiers = [
19+
"Development Status :: 3 - Alpha",
20+
"Intended Audience :: Science/Research",
21+
"Topic :: Scientific/Engineering :: Artificial Intelligence",
22+
"Programming Language :: Python :: 3",
23+
"Programming Language :: Python :: 3.9",
24+
"Programming Language :: Python :: 3.10",
25+
"Programming Language :: Python :: 3.11",
26+
"Programming Language :: Python :: 3.12",
27+
]
28+
29+
requires-python = ">=3.9"
30+
31+
# These are defined below dynamically:
32+
dynamic = [
33+
"version",
34+
"readme",
35+
"dependencies",
36+
"optional-dependencies",
37+
]
38+
39+
40+
[tool.setuptools.packages.find]
41+
include = ["error_parity*"]
42+
exclude = ["tests*"]
43+
44+
[tool.setuptools.dynamic]
45+
version = { attr = "error_parity._version.__version__" }
46+
readme = { file = "README.md", content-type = "text/markdown" }
47+
48+
# Main package dependencies
49+
dependencies = {file = "requirements/main.txt"}
50+
51+
# Optional dependencies
52+
[tool.setuptools.dynamic.optional-dependencies]
53+
test = {file = "requirements/test.txt"}
54+
dev = {file = "requirements/dev.txt"}
55+
docs = {file = "requirements/docs.txt"}
56+
all = {file = [
57+
"requirements/dev.txt",
58+
"requirements/test.txt",
59+
"requirements/docs.txt",
60+
]}
61+
62+
[project.urls]
63+
homepage = "https://github.com/socialfoundations/error-parity"
64+
65+
# flake8
66+
[tool.flake8]
67+
max-complexity = 10
68+
max-line-length = 120
69+
70+
per-file-ignores = """
71+
# imported but unused
72+
**/__init__.py: F401
73+
"""
74+
75+
exclude = [
76+
"docs/",
77+
".tox/",
78+
"build/",
79+
"dist/",
80+
]
81+
82+
[tool.pytest.ini_options]
83+
minversion = "8.0"
84+
testpaths = [
85+
"tests",
86+
]
87+
88+
# isort
89+
[tool.isort]
90+
profile = "hug"
91+
force_single_line = false
92+
src_paths = ["error_parity", "tests"]
93+
94+
# Coverage
95+
[tool.coverage.run]
96+
branch = true
97+
source = ["error_parity"]
98+
omit = ["error_parity/_version.py", "tests"]
99+
100+
[tool.coverage.report]
101+
show_missing = true
102+
103+
# MyPy
104+
[tool.mypy]
105+
ignore_missing_imports = true
106+
no_implicit_optional = false
107+
strict_optional = false
108+
exclude = [
109+
"build",
110+
"doc",
111+
"tests",
112+
"notebooks",
113+
]
114+
python_version = "3.11"
115+
116+
# Tox
117+
[tool.tox]
118+
legacy_tox_ini = """
119+
[tox]
120+
env_list =
121+
py39
122+
py310
123+
py311
124+
py312
125+
lint
126+
type
127+
128+
[testenv]
129+
description = run unit tests
130+
deps =
131+
pytest>=8
132+
coverage>=7
133+
commands =
134+
coverage erase
135+
coverage run -m pytest {posargs:tests}
136+
coverage report -m
137+
138+
[testenv:type]
139+
description = run type checks
140+
basepython = python3.11
141+
deps =
142+
mypy>=1.0
143+
commands = mypy {posargs:error_parity}
144+
145+
[testenv:lint]
146+
description = run linters
147+
skip_install = true
148+
deps =
149+
flake8>=7.0
150+
flake8-pyproject
151+
commands = flake8 {posargs:error_parity tests}
152+
"""

requirements/main.txt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
pandas
2-
numpy
2+
numpy<2.0.0
33
scipy
44
tqdm
55
scikit-learn>=1.2
6-
cvxpy>=1.3.2
6+
cvxpy[ecos,clarabel]~=1.3.2
77
matplotlib
88
seaborn

requirements/test.txt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
pytest
2-
coverage
1+
pytest>=8.0
2+
coverage>=7.0
33
folktables
44
tqdm
55
mypy

setup.py

Lines changed: 0 additions & 97 deletions
This file was deleted.

tests/test_evaluation.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,5 +68,5 @@ def test_equalized_odds_relaxation_costs(
6868
higher_p_cost = results[higher_p_norm]
6969

7070
# Assert lower-p costs are higher (accuracy is lower)
71-
assert lower_p_cost > higher_p_cost - SOLUTION_TOLERANCE, \
71+
assert lower_p_cost > higher_p_cost - 2 * SOLUTION_TOLERANCE, \
7272
f"l-{lower_p_norm} cost: {lower_p_cost} < l-{higher_p_norm} cost: {higher_p_cost}"

0 commit comments

Comments
 (0)