Slice 37's per-cert pin refactor pinned PE residuals against `result.primary_energy_kwh_per_m2` from the rating cascade (UK-avg climate). But per SAP10.2 Appendix U + the codebase's own SAP_CALCULATOR.md docs, the EPC's published `energy_consumption_current` is a postcode-climate value — same as CO2. The CO2 pin was already correct; PE was an oversight. Fix: use the public `calculate_sap_from_inputs` entry point twice — once with `cert_to_inputs` (rating cascade) for SAP, once with `cert_to_demand_inputs` (demand cascade) for PE + CO2. This drops the four section-helper imports and reads everything off SapResult, keeping the test surface minimal. PE residuals shift on every fixture (sometimes toward zero, sometimes away — the rating cascade was masking the real gap): cert old PE new PE Δ 0240-0200-5706-2365-8010 +0.74 +5.58 worse — known RR gap 0300-2747-7640-2526-2135 +17.34 +4.45 tighter 0390-2254-6420-2126-5561 (LN12) -3.14 +0.18 tighter ← bread-and-butter cert now within 0.2 kWh/m² 0390-2954-3640-2196-4175 -27.64 -26.68 ~same 2130-1033-4050-5007-8395 (DE22) -61.25 -65.89 worse — PV PE-offset now correctly accounted 6035-7729-2309-0879-2296 +34.62 +45.05 worse — known wall-insulation + RR gap 7536-3827-0600-0600-0276 -27.45 -17.98 tighter 8135-1728-8500-0511-3296 -14.37 -9.50 tighter The "worse" certs (0240, 6035, DE22) were never close — the rating cascade had been coincidentally masking the real PE gap on the certs with documented mapper gaps. Demand cascade now exposes the real residual for each; the documented gaps' fixes will close them. LN12 (bread-and-butter, gas combi, no PV) now reads: SAP resid +0 (exact match) PE resid +0.18 (within 0.2 kWh/m² of lodged 241) CO2 resid +0.04 (within 0.05 t/yr of lodged 3.5) First cert in the cohort within target ±0.5 on SAP and ±1 on PE/CO2. 930/930 Elmhurst cascade unchanged. 14/14 golden cohort + PCDB chain green. Pyright net-zero (2 errors before and after). Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com> |
||
|---|---|---|
| .devcontainer | ||
| .github/workflows | ||
| .idea | ||
| .vscode | ||
| asset_list | ||
| backend | ||
| backlog | ||
| datatypes | ||
| docs | ||
| epr_data_exports | ||
| etl | ||
| infrastructure/terraform | ||
| model_data/requirements | ||
| packages | ||
| recommendations | ||
| scripts | ||
| services | ||
| sfr/principal_pitch | ||
| survey_report | ||
| utils | ||
| .coveragerc | ||
| .dockerignore | ||
| .gitignore | ||
| __init__.py | ||
| AGENTS.md | ||
| ara_backend_design.md | ||
| BaseUtility.py | ||
| CLAUDE.md | ||
| conftest.py | ||
| CONTEXT.md | ||
| devcontainer.sh | ||
| Dockerfile.test | ||
| Dockerfile.test.dockerignore | ||
| Makefile | ||
| MEMORY.md | ||
| package-lock.json | ||
| package.json | ||
| pyproject.toml | ||
| pyrightconfig.json | ||
| pytest.ini | ||
| README.md | ||
| run_backlog.sh | ||
| run_lambda_local.sh | ||
| serverless.yml | ||
| test.requirements.txt | ||
| tox.ini | ||
| UBIQUITOUS_LANGUAGE.md | ||
Model Repository
This repository contains the code pertaining to the development of the data science and machine learning products being utilised by Hestia.
The different folders in this repository relate to services that can be used independently, or can be imported and used as part of a larger application
Getting Started
Prerequisites
Dev Container Setup
This repo uses a Docker Compose-based dev container. The model-backend service joins a shared-dev Docker network so it can communicate with other local services (e.g. a frontend container) running on your machine.
VS Code users: The initializeCommand in devcontainer.json creates the shared-dev network automatically before the container starts. No manual step required — just open the repo and select Reopen in Container.
Non-VS Code / CI workflows: Run the following once before starting the container:
make dev-setup
This is idempotent and safe to re-run if the network already exists.
Folders
backend/
This folder contains the code for the fastapi backend service, which provides an interface to much of the functionality in this repository, for the frontend
model_data/
This folder contains related to the reading and preparation of assessment model data, including pulling out epc attributes
Testing
All tests can be run, against the configuration in pytest.ini running
pytest
This will run the complete panel of tests and report on coverage in the locations specified by the pytest.ini file.
To run tests in a specific service, e.g. inside of model_data, simply run
pytest --cov-config=model_data/.coveragerc --cov=model_data
This will produce the test results and coverage reports