Skip to content

Development

Environment with uv

The project uses uv for dependency and environment management. The dev dependency group includes the tooling needed to work on the project (linting, type checking, docs).

Sync the environment, including dev dependencies:

uv sync

Run any project command inside the managed environment with uv run:

uv run python -m technoeconomics

Pre-commit hooks

If you want to contribute to this repository, please set up pre-commit.

uv run pre-commit install --install-hooks
uv run pre-commit install --hook-type commit-msg

The hooks run automatically on every commit. To run them against the whole repository on demand:

uv run pre-commit run --all-files

Testing

Tests live in tests/, one file per module (test_data.py, test_weather.py, ...), and run with pytest:

uv run pytest

Warnings are errors.

By default, only fast, local tests are ran.

To run tests that require network access (e.g. downloading weather data), use the network tag:

uv run pytest -m network

To run slow tests (e.g. solving large complex plants), use the slow tag:

uv run pytest -m slow

Binary test fixtures (e.g. a small atlite cutout) go under tests/fixtures/, one subdirectory per dataset, alongside the script that regenerates them.

Style

Documentation

All docstrings follow the Google docstring convention. Example docstring:

def lcoe(capex: float, opex: float, energy: float, rate: float = 0.07):
  """Compute levelised cost of energy.

    Args:
        capex: Capital expenditure (EUR)
        opex: Annual operating expenditure (EUR/yr)
        energy: Annual energy yield (MWh/yr)
        rate: Discount rate as a decimal fraction (_)

    Returns:
        LCOE (EUR/Mwh)

    Raises:
        ValueError: If ``energy`` is negative

For an exhaustive specification of this docstring style, see the Google Python Style Guide.

Documentation

Local

We use zensical for documentation. To build it the docs, simply run:

uv run zensical build

And to serve them and inspect locally:

uv run zensical serve --dev-addr localhost:CHOSEN_PORT

Online

Online docs are built by a GitHub CI, .github/workflows/docs.yml and published under https://mrmorawski.github.io/technoeconomics.