Skip to content

Commit 7a4bb7b

Browse files
authored
Merge pull request #2 from acceleratescience/feature/stylometry
Add stylometry package
2 parents 3dd5de1 + 4993972 commit 7a4bb7b

28 files changed

Lines changed: 6456 additions & 117 deletions

.coverage

52 KB
Binary file not shown.

.coveragerc

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
[run]
2+
omit =
3+
*/plotting.py

.github/workflows/tests.yaml

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
name: tests
2+
3+
on:
4+
push:
5+
pull_request:
6+
7+
jobs:
8+
pytest:
9+
runs-on: ubuntu-latest
10+
strategy:
11+
matrix:
12+
python-version: ["3.12"]
13+
14+
steps:
15+
- uses: actions/checkout@v4
16+
17+
- name: Set up Python
18+
uses: actions/setup-python@v5
19+
with:
20+
python-version: ${{ matrix.python-version }}
21+
22+
- name: Install uv
23+
run: |
24+
curl -LsSf https://astral.sh/uv/install.sh | sh
25+
echo "$HOME/.cargo/bin" >> $GITHUB_PATH
26+
27+
- name: Create venv
28+
run: uv venv
29+
30+
- name: Install dependencies
31+
run: uv pip install -e .[dev]
32+
33+
- name: Run tests (push)
34+
if: github.event_name == 'push'
35+
run: uv run pytest
36+
37+
- name: Run tests + coverage gate (PR into main)
38+
if: github.event_name == 'pull_request' && github.base_ref == 'main'
39+
run: uv run pytest --cov=voice --cov-report=term-missing --cov-fail-under=90

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,3 +52,6 @@ htmlcov/
5252
# Local configs
5353
.env
5454
*.local
55+
56+
# Notebooks
57+
**.ipynb

.pre-commit-config.yaml

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -58,25 +58,31 @@ repos:
5858
hooks:
5959
- id: isort
6060

61-
# Type checking
61+
# Type checking (keep for src; exclude tests)
6262
- repo: https://github.com/pre-commit/mirrors-mypy
6363
rev: v1.13.0
6464
hooks:
6565
- id: mypy
6666
args: ["--config-file", "pyproject.toml"]
67+
exclude: ^tests/
6768

68-
# Docstring correctness (sphinx convention)
69+
# Docstring correctness (sphinx convention) (keep for src; exclude tests)
6970
- repo: https://github.com/jsh9/pydoclint
7071
rev: 0.7.6
7172
hooks:
7273
- id: pydoclint
7374
args: ["--config=pyproject.toml"]
75+
exclude: ^tests/
7476

75-
# Cognitive complexity limit via flake8-cognitive-complexity
77+
# Cognitive complexity limit via flake8-cognitive-complexity (keep for src; exclude tests)
7678
- repo: https://github.com/pycqa/flake8
7779
rev: 7.3.0
7880
hooks:
7981
- id: flake8
8082
additional_dependencies:
8183
- flake8-cognitive-complexity
82-
args: ["--max-cognitive-complexity=10"]
84+
args:
85+
- --max-line-length=79
86+
- --extend-ignore=E203
87+
- --max-cognitive-complexity=10
88+
exclude: ^tests/

cspell.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@
2828
"cspell/**",
2929
"LICENSE",
3030
".secrets.baseline",
31-
"*.egg-info/"
31+
"*.egg-info/",
32+
"**/*.ipynb"
3233
]
3334
}

cspell/library-words.txt

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
huggingface
2+
resp
3+
passthrough
4+
figsize
5+
whitegrid
6+
kdeplot
7+
xlabel
8+
ylabel
9+
frameon
10+
allclose

cspell/project-words.txt

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
hapax
2+
dis
3+
tri
4+
legomenon
5+
legomena
6+
MATTR
7+
TTR
8+
ngram
9+
prov
10+
wasserstein
11+
bonf
12+
bonferroni
13+
aeiou

pyproject.toml

Lines changed: 45 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,14 @@ version = "0.1.0"
44
description = "Fine-tuning for stylistic fidelity"
55
readme = "README.md"
66
requires-python = ">=3.12"
7-
dependencies = []
7+
dependencies = [
8+
"datasets>=4.5.0",
9+
"dotenv>=0.9.9",
10+
"huggingface-hub>=1.4.1",
11+
"matplotlib>=3.10.8",
12+
"scipy>=1.17.0",
13+
"seaborn>=0.13.2",
14+
]
815

916
[build-system]
1017
requires = ["setuptools>=68", "wheel"]
@@ -20,15 +27,19 @@ dev = [
2027
"flake8-cognitive-complexity>=0.1.0",
2128
"isort>=7.0.0",
2229
"mypy>=1.19.1",
30+
"notebook>=7.5.3",
2331
"pre-commit>=4.5.1",
2432
"pydoclint>=0.8.3",
33+
"pytest>=9.0.2",
34+
"pytest-cov>=7.0.0",
2535
"ruff>=0.14.14",
2636
]
2737

2838
[tool.ruff]
29-
line-length = 88
39+
line-length = 79
3040
target-version = "py312"
3141
force-exclude = true
42+
extend-ignore = ["D107"]
3243

3344
[tool.ruff.lint]
3445
select = [
@@ -49,25 +60,53 @@ select = [
4960
"C901",
5061
]
5162

52-
ignore = [
53-
"ANN101", "ANN102",
54-
]
63+
ignore = []
5564

5665
[tool.ruff.lint.mccabe]
5766
max-complexity = 12
5867

5968
[tool.ruff.lint.pydocstyle]
6069
convention = "pep257"
6170

71+
[tool.ruff.lint.per-file-ignores]
72+
"tests/**/*.py" = [
73+
"D",
74+
"ANN",
75+
"ARG001",
76+
"ARG005",
77+
"B007",
78+
]
79+
6280
[tool.mypy]
6381
python_version = "3.12"
6482
strict = true
6583
warn_unused_configs = true
6684
no_implicit_optional = true
6785

86+
[[tool.mypy.overrides]]
87+
module = ["tests.*"]
88+
ignore_errors = true
89+
90+
[[tool.mypy.overrides]]
91+
module = [
92+
"datasets",
93+
"datasets.*",
94+
"huggingface_hub",
95+
"huggingface_hub.*",
96+
"numpy",
97+
"numpy.*",
98+
"scipy.stats",
99+
"scipy.stats.*",
100+
"seaborn",
101+
"seaborn.*",
102+
"matplotlib",
103+
"matplotlib.*",
104+
]
105+
ignore_missing_imports = true
106+
68107
[tool.isort]
69108
profile = "black"
70-
line_length = 88
109+
line_length = 79
71110

72111
[tool.pydoclint]
73112
style = "sphinx"

src/voice/__init__.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,3 +4,13 @@
44
This package provides tools for fine-tuning and evaluating
55
LLMs for stylistic fidelity.
66
"""
7+
8+
from voice.datasets import DatasetSpec, get_dataset
9+
from voice.stylometry import get_metrics, make_comparison
10+
11+
__all__: list[str] = [
12+
"DatasetSpec",
13+
"get_metrics",
14+
"get_dataset",
15+
"make_comparison",
16+
]

0 commit comments

Comments
 (0)