Development#
This page explains how to run the test suite, configure pre-commit hooks, and build the documentation locally.
For environment setup and installation instructions see the Installation page.
Running the tests#
The test suite uses pytest with coverage support. The full configuration lives in pyproject.toml under [tool.pytest.ini_options].
Run all tests#
python -m pytest
pytest is configured with -v (verbose), --strict-markers, and --disable-warnings by default, so you will see one line per test case.
Run a single test#
Specify the file, class, and method separated by :::
python -m pytest tests/test_altx.py::TestTrain::test_train_populates_ps_for_all_rlk
Run with coverage#
python -m pytest --cov
Coverage is measured over the altx/ package (configured under [tool.coverage.run]). The tests/ directory is excluded from the report.
Test structure#
File |
What it tests |
|---|---|
|
All public methods of |
|
All extraction methods in |
Pre-commit hooks#
Pre-commit hooks run automatically on every git commit and enforce code quality. They are configured in .pre-commit-config.yaml.
Install the hooks#
Run this once after cloning the repository:
pre-commit install
After that, git commit will trigger all hooks automatically on the staged files.
Run hooks manually#
On specific files:
pre-commit run --files altx/altx.py altx/extract_methods.py
On the entire repository:
pre-commit run --all-files
Hooks that are configured#
Hook |
Tool |
What it checks / fixes |
|---|---|---|
|
pre-commit-hooks |
Trims trailing whitespace from every line |
|
pre-commit-hooks |
Ensures files end with exactly one newline |
|
pre-commit-hooks |
Validates YAML syntax |
|
pre-commit-hooks |
Validates JSON syntax |
|
pre-commit-hooks |
Blocks committing unresolved merge conflict markers |
|
pre-commit-hooks |
Rejects files larger than 5 MB |
|
pre-commit-hooks |
Prevents direct commits to |
|
Black |
Auto-formats Python files to 88-character lines |
|
nbQA + Black |
Applies Black formatting to Jupyter notebooks |
|
Ruff |
Applies Ruff’s formatter (compatible with Black) |
|
Ruff |
Lints and auto-fixes import ordering, bugbear rules, docstring style, and more (see below) |
|
nbQA + Ruff |
Applies Ruff linting to Jupyter notebooks |
|
Mypy |
Strict type checking (Python 3.12 target, |
|
pydocstyle |
Enforces NumPy docstring convention |
Ruff rule groups#
The following Ruff rule groups are active (see [tool.ruff.lint] in pyproject.toml):
Code |
Group |
Purpose |
|---|---|---|
|
pycodestyle |
Style errors (line length, whitespace, etc.) |
|
pyflakes |
Undefined names, unused imports |
|
isort |
Import ordering |
|
pep8-naming |
Class, function, and variable naming |
|
pydocstyle |
Docstring presence and formatting |
|
pyupgrade |
Modernise Python syntax |
|
flake8-bugbear |
Common bugs and design issues |
|
flake8-comprehensions |
Idiomatic comprehensions |
|
flake8-simplify |
Unnecessarily complex code |
|
Ruff-specific |
Ruff’s own additional rules |
Ignored rules: E741 (ambiguous names), N802/N803/N806/N814 (non-lowercase identifiers and camelcase constants). Test files additionally ignore all D rules.
Branch protection#
The no-commit-to-branch hook blocks direct commits to main and master. Always create a feature branch first:
git switch -c feature/my-change
Building the documentation#
The documentation is built with Sphinx using the pydata_sphinx_theme. The source files live in docs/source/ and the built HTML is written to docs/_build/html/.
Install documentation dependencies#
pip install -e ".[docs]"
This installs:
Package |
Purpose |
|---|---|
|
Core documentation builder |
|
HTML theme |
|
Allows writing documentation pages in Markdown ( |
|
Renders Python type annotations in the API reference |
|
NumPy docstring support |
|
Adds a copy button to code blocks |
|
Additional layout components (grids, cards, tabs) |
Build HTML locally#
The quickest way is to use the Makefile that ships in the docs/ directory:
cd docs
make html
The output is written to docs/build/html/. Open docs/build/html/index.html in a browser to view the result. Run make clean first if you want to discard the cached build and start from scratch.
Alternatively, call sphinx-build directly from the repository root (this is what CI uses and writes to a different output directory):
sphinx-build -b html docs/source docs/_build/html
To treat all warnings as errors (mirrors CI behaviour):
sphinx-build -W -T -b html docs/source docs/_build/html
Documentation structure#
docs/
├── source/
│ ├── conf.py ← Sphinx configuration (theme, extensions, version)
│ ├── index.rst ← Top-level table of contents
│ ├── installation.md ← Installation instructions
│ ├── usage.md ← Usage guide and examples
│ ├── development.md ← This page
│ └── api/
│ ├── modules.rst ← Auto-generated module list
│ └── altx.rst ← API reference (autodoc directives)
└── _build/
└── html/ ← Generated HTML output (not committed)
conf.py derives the package version from the latest git tag via setuptools-scm. If no tag is found, it falls back to the installed package version, and then to "0.0.0".
Continuous integration#
The documentation is built automatically on every push via the .github/workflows/build-docs.yml workflow. The workflow:
Builds the HTML documentation.
Uploads it as a GitHub Actions artifact (
html-docs).On pushes to
masteror version tags (v*), deploys the artifact to GitHub Pages via thepeaceiris/actions-gh-pagesaction.
Continuous integration overview#
Workflow |
File |
Trigger |
What it does |
|---|---|---|---|
Python tests |
|
Every push and PR |
Runs pytest with coverage on Python 3.12, 3.13, and 3.14; uploads a coverage badge on pushes to |
Pre-commit check |
|
Every push and PR |
Runs all pre-commit hooks ( |
Build and Deploy Docs |
|
Every push, PRs to main/master |
Builds Sphinx HTML; deploys to GitHub Pages on |
All CI jobs run in the custom Docker image ghcr.io/halmosb/docker-builder/python:3.14-cpu-v0.3.4, which pre-installs the required Python version and PyTorch CPU build, see github.com/halmosb/docker-builder for more details.