How to set up a development environment, run tests, and contribute to pylcm.
Setup¶
pylcm uses pixi for dependency management. Python 3.14+ is required.
# Clone the repository
git clone https://github.com/OpenSourceEconomics/pylcm.git
cd pylcmThe first pixi run command will install dependencies automatically, but you can run
pixi install explicitly if you prefer.
Install pre-commit hooks (requires prek):
pixi global install prek
prek installRunning Tests¶
# All tests
pixi run tests
# Tests with coverage
pixi run tests-with-cov
# Specific test file
pixi run pytest tests/test_specific_module.py
# Specific test function
pixi run pytest tests/test_specific_module.py::test_function_nameCode Quality¶
# Type checking (ty, not mypy)
pixi run -e tests-cpu ty
# Run all pre-commit hooks
prek run --all-filesBuilding Documentation¶
# Build docs
pixi run build-docs
# Live preview (watches for changes)
pixi run view-docsConventions¶
Code Style¶
Ruff for linting and formatting (configured in
pyproject.toml)All functions require type annotations
Google-style docstrings in imperative mood (“Return”, not “Returns”)
Use
# ty: ignore[error-code]for type suppression (never# type: ignore)Never use
from __future__ import annotations
Testing¶
Plain
pytestfunctions — no test classesUse
@pytest.mark.parametrizefor test variations
Naming¶
funcfor callable abbreviations (neverfn)state_names/action_names(notstates_names)arg_names(notargument_names)
Plotting¶
Always use plotly (
plotly.graph_objects,plotly.subplots.make_subplots), never matplotlib
Docstrings¶
MyST syntax (single backticks for code,
$...$for math), not reStructuredTextInline field docstrings (PEP 257) for dataclass attributes
Docstring types must match annotations (
Mappingnot “Dict” when annotation isMapping)
Contributing¶
Report bugs and suggest features on the GitHub issue tracker.