From d8ba667c98d44867059d5d5f4d65f31544bfec3c Mon Sep 17 00:00:00 2001 From: Stanislav Khrapov Date: Tue, 28 Jul 2026 19:12:00 +0200 Subject: [PATCH 01/12] refactor: convert docstrings to raw strings to support LaTeX math notation in model_ct.py --- src/affidiff/model_ct.py | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/affidiff/model_ct.py b/src/affidiff/model_ct.py index ef86ba1..c9964ae 100644 --- a/src/affidiff/model_ct.py +++ b/src/affidiff/model_ct.py @@ -48,7 +48,7 @@ def get_start(self): @staticmethod def coef_big_as(param, aggh): - """Coefficient A^\sigma_h in exact discretization of volatility. + r"""Coefficient A^\sigma_h in exact discretization of volatility. Parameters ---------- @@ -66,7 +66,7 @@ def coef_big_as(param, aggh): return np.exp(-param.kappa_s * aggh) def coef_big_bs(self, param, aggh): - """Coefficient B^\sigma_h in exact discretization of volatility. + r"""Coefficient B^\sigma_h in exact discretization of volatility. Parameters ---------- @@ -214,7 +214,7 @@ def coef_small_ay(self, param, aggh): return (1 - self.coef_big_ay(param, aggh)) / param.kappa_y / aggh def roots(self, param, aggh): - """Roots of the polynomial in moment restrictions. + r"""Roots of the polynomial in moment restrictions. .. math:: @@ -537,7 +537,7 @@ def unc_mean_ct2(param): def unc_mean_sigma2(param): - """Unconditional second moment of volatility, E[\sigma_t**4]. + r"""Unconditional second moment of volatility, E[\sigma_t**4]. Parameters ---------- @@ -571,7 +571,7 @@ def unc_var_ct(param): def unc_var_sigma(param): - """Unconditional variance of volatility, V[\sigma_t**2]. + r"""Unconditional variance of volatility, V[\sigma_t**2]. Parameters ---------- @@ -587,7 +587,7 @@ def unc_var_sigma(param): def unc_var_error(param, aggh): - """Unconditional variance of aggregated volatility error, + r"""Unconditional variance of aggregated volatility error, :math:`V\left[\frac{1}{H}\int_{0}^{H}\epsilon_{t,s}^{\sigma}ds\right]` Derived symbolically in symbolic.py From 5e1b3255d23b20ab29afa09bdba7f1eb0d58cbd8 Mon Sep 17 00:00:00 2001 From: Stanislav Khrapov Date: Tue, 28 Jul 2026 19:44:03 +0200 Subject: [PATCH 02/12] Fix prek issues --- .coveragerc | 11 + .github/workflows/workflow.yaml | 22 +- .pre-commit-config.yaml | 28 ++ .rtk/filters.toml | 13 + CLAUDE.md | 138 ++++++ docs/source/conf.py | 185 ++++---- docs/source/index.rst | 2 +- examples/load_real_data.py | 30 +- examples/try_centtend.py | 497 +++++++++++----------- examples/try_cir.py | 49 +-- examples/try_gbm.py | 80 ++-- examples/try_heston.py | 445 ++++++++++---------- examples/try_vasicek.py | 53 ++- models.lyx | 576 ++++++++++++------------- pyproject.toml | 64 ++- setup.py | 78 ++-- src/affidiff/__init__.py | 40 +- src/affidiff/helper_functions.py | 181 ++++---- src/affidiff/model_cir.py | 31 +- src/affidiff/model_ct.py | 313 ++++++++------ src/affidiff/model_gbm.py | 192 +++++---- src/affidiff/model_generic.py | 310 +++++++++----- src/affidiff/model_heston.py | 130 +++--- src/affidiff/model_vasicek.py | 31 +- src/affidiff/param_cir.py | 56 +-- src/affidiff/param_ct.py | 200 +++++---- src/affidiff/param_gbm.py | 60 +-- src/affidiff/param_generic.py | 92 ++-- src/affidiff/param_heston.py | 163 ++++---- src/affidiff/param_vasicek.py | 56 +-- src/affidiff/symbolic.py | 53 --- tests/test_ajd.py | 124 +++--- tests/test_generic.py | 20 +- tests/test_helpers.py | 45 +- tests/test_param_cir.py | 25 +- tests/test_param_ct.py | 600 ++++++++++++++------------ tests/test_param_gbm.py | 33 +- tests/test_param_heston.py | 305 ++++++-------- tests/test_param_vasicek.py | 21 +- tests/test_rmoms_ct.py | 697 ++++++++++++++++++------------- tests/test_rmoms_gbm.py | 19 +- tests/test_rmoms_heston.py | 420 +++++++++---------- uv.lock | 85 +++- 43 files changed, 3619 insertions(+), 2954 deletions(-) create mode 100644 .coveragerc create mode 100644 .pre-commit-config.yaml create mode 100644 .rtk/filters.toml create mode 100644 CLAUDE.md delete mode 100644 src/affidiff/symbolic.py diff --git a/.coveragerc b/.coveragerc new file mode 100644 index 0000000..0688e97 --- /dev/null +++ b/.coveragerc @@ -0,0 +1,11 @@ +[run] +branch = True +source = affidiff +omit = */__init__.py + +[paths] +source = + src/ + +[report] +show_missing = True diff --git a/.github/workflows/workflow.yaml b/.github/workflows/workflow.yaml index b01c87c..6ce1e68 100644 --- a/.github/workflows/workflow.yaml +++ b/.github/workflows/workflow.yaml @@ -30,9 +30,29 @@ jobs: - name: Run test suite run: uv run pytest + code-quality: + name: Code quality checks + runs-on: ubuntu-latest + steps: + - name: Check out repository code + uses: actions/checkout@v6 + - name: Install uv + uses: astral-sh/setup-uv@v7 + with: + enable-cache: true + cache-dependency-glob: "uv.lock" + - name: Setup Python + uses: actions/setup-python@v6 + with: + python-version-file: ".python-version" + - name: Install dependencies + run: uv sync group --dev + - name: Run pre-commit + run: uv run prek run -v --show-diff-on-failure --all-files + publish: name: Build and publish wheels - needs: [ test ] + needs: [ test, code-quality ] runs-on: ubuntu-latest environment: name: pypi diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml new file mode 100644 index 0000000..c818495 --- /dev/null +++ b/.pre-commit-config.yaml @@ -0,0 +1,28 @@ +repos: + - repo: builtin + hooks: + - id: trailing-whitespace + - id: check-added-large-files + - id: end-of-file-fixer + - id: forbid-new-submodules + - id: mixed-line-ending + - id: check-json + - id: pretty-format-json + args: ["--autofix"] + - id: check-yaml + - id: detect-private-key + + - repo: https://github.com/charliermarsh/ruff-pre-commit + rev: v0.16.0 + hooks: + - id: ruff + args: [ --config, pyproject.toml, --fix, --exit-non-zero-on-fix ] + types_or: [ python ] + - id: ruff-format + args: [ --config, pyproject.toml ] + types_or: [ python ] + + - repo: https://github.com/astral-sh/ty-pre-commit + rev: v0.0.64 + hooks: + - id: ty diff --git a/.rtk/filters.toml b/.rtk/filters.toml new file mode 100644 index 0000000..d9bd43f --- /dev/null +++ b/.rtk/filters.toml @@ -0,0 +1,13 @@ +# Project-local RTK filters — commit this file with your repo. +# Filters here override user-global and built-in filters. +# Docs: https://github.com/rtk-ai/rtk#custom-filters +schema_version = 1 + +# Example: suppress build noise from a custom tool +# [filters.my-tool] +# description = "Compact my-tool output" +# match_command = "^my-tool\\s+build" +# strip_ansi = true +# strip_lines_matching = ["^\\s*$", "^Downloading", "^Installing"] +# max_lines = 30 +# on_empty = "my-tool: ok" diff --git a/CLAUDE.md b/CLAUDE.md new file mode 100644 index 0000000..a3e6b3f --- /dev/null +++ b/CLAUDE.md @@ -0,0 +1,138 @@ + +# RTK (Rust Token Killer) - Token-Optimized Commands + +## Golden Rule + +**Always prefix commands with `rtk`**. If RTK has a dedicated filter, it uses it. If not, it passes through unchanged. This means RTK is always safe to use. + +**Important**: Even in command chains with `&&`, use `rtk`: +```bash +# ❌ Wrong +git add . && git commit -m "msg" && git push + +# ✅ Correct +rtk git add . && rtk git commit -m "msg" && rtk git push +``` + +## RTK Commands by Workflow + +### Build & Compile (80-90% savings) +```bash +rtk cargo build # Cargo build output +rtk cargo check # Cargo check output +rtk cargo clippy # Clippy warnings grouped by file (80%) +rtk tsc # TypeScript errors grouped by file/code (83%) +rtk lint # ESLint/Biome violations grouped (84%) +rtk prettier --check # Files needing format only (70%) +rtk next build # Next.js build with route metrics (87%) +``` + +### Test (60-99% savings) +```bash +rtk cargo test # Cargo test failures only (90%) +rtk go test # Go test failures only (90%) +rtk jest # Jest failures only (99.5%) +rtk vitest # Vitest failures only (99.5%) +rtk playwright test # Playwright failures only (94%) +rtk pytest # Python test failures only (90%) +rtk rake test # Ruby test failures only (90%) +rtk rspec # RSpec test failures only (60%) +rtk test # Generic test wrapper - failures only +``` + +### Git (59-80% savings) +```bash +rtk git status # Compact status +rtk git log # Compact log (works with all git flags) +rtk git diff # Compact diff (80%) +rtk git show # Compact show (80%) +rtk git add # Ultra-compact confirmations (59%) +rtk git commit # Ultra-compact confirmations (59%) +rtk git push # Ultra-compact confirmations +rtk git pull # Ultra-compact confirmations +rtk git branch # Compact branch list +rtk git fetch # Compact fetch +rtk git stash # Compact stash +rtk git worktree # Compact worktree +``` + +Note: Git passthrough works for ALL subcommands, even those not explicitly listed. + +### GitHub (26-87% savings) +```bash +rtk gh pr view # Compact PR view (87%) +rtk gh pr checks # Compact PR checks (79%) +rtk gh run list # Compact workflow runs (82%) +rtk gh issue list # Compact issue list (80%) +rtk gh api # Compact API responses (26%) +``` + +### JavaScript/TypeScript Tooling (70-90% savings) +```bash +rtk pnpm list # Compact dependency tree (70%) +rtk pnpm outdated # Compact outdated packages (80%) +rtk pnpm install # Compact install output (90%) +rtk npm run