Pre-slice every off-peak callsite in `cert_to_inputs.py` — `_space_heating_fuel_cost_gbp_per_kwh`, `_hot_water_fuel_cost_gbp_per_kwh`, `_secondary_fuel_cost_gbp_per_kwh`, `_pv_dwelling_import_price_gbp_per_kwh` — hardcoded `prices.e7_low_rate_p_per_kwh = 5.50` p/kWh (Table 32 code 31, the 7-hour low rate) regardless of the cert's actual tariff. Every 18-hour cert was thereby under-charged 1.91 p/kWh × off-peak kWh on its space-heating, hot-water, and secondary-heating cost rows. Per RdSAP 10 §19 Table 32 (p.95): > "Electricity ... 7-hour tariff (low rate / off-peak) — code 31 5.50 p/kWh > ... 10-hour tariff (low rate) — code 33 7.50 p/kWh > ... 18-hour tariff (low rate) — code 40 7.41 p/kWh > ... 24-hour tariff — code 35 6.61 p/kWh" The fix routes through a new `_off_peak_low_rate_gbp_per_kwh(tariff)` helper that reads the existing per-tariff Table 32 lookup (`_TARIFF_HIGH_LOW_RATES_P_PER_KWH`). A companion `_off_peak_low_rate_gbp_per_kwh_via_meter_heuristic(meter_type)` covers the secondary / PV paths that detect off-peak via the `_is_off_peak_meter` heuristic (RdSAP meter code 3 = Unknown is treated as off-peak for electric end-uses), falling back to the SEVEN_HOUR rate when the meter resolves to STANDARD — codifying the heuristic that the literal 5.50 constant used to embed. Per [[feedback-zero-error-strict]] the now-dead `PriceTable.e7_low_rate_p_per_kwh` field is deleted (no fallback can silently re-introduce the 5.50 hardcode); the field's docstring + RDSAP_10_TABLE_32_PRICES instantiation update to point at the new helpers. Corpus closure (all 18-hour cohort): - 8 electric variants — SAP +5.85..+9.64 → -0.10..-2.76; cost -£135..-£222 → +£2..+£64 - ashp +5.67 → +0.24 SAP (-£131 → -£5.57) - gshp +5.16 → +1.15 SAP (-£119 → -£26) - solid fuel 4..11 — SAP +1.59..+2.04 → ±0.45 (cost ±£10) Golden 0240 PV path also closes (was raising UnmappedSapCode on Unknown-meter probe — surfaced an unreachable PV literal that the meter-heuristic helper now resolves). Tests: - new AAA test `test_space_heating_off_peak_fallback_uses_actual_tariff_low_rate_not_e7` exercising the EIGHTEEN_HOUR fallback at the helper level - 19 corpus pins re-tightened (8 electric + ashp + gshp + 8 solid-fuel + golden 0240's implicit pin) Extended handover suite: 881 pass (was 880; +1 new test), 0 fail. Pyright net-zero on touched files (43 → 43 errors, all pre-existing). Per [[feedback-spec-citation-in-commits]] + [[feedback-worksheet-not-api-reference]] + [[reference-unmapped-sap-code]]. Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com> |
||
|---|---|---|
| .devcontainer | ||
| .github/workflows | ||
| .idea | ||
| .vscode | ||
| applications | ||
| asset_list | ||
| backend | ||
| backlog | ||
| datatypes | ||
| deployment/terraform | ||
| docs/adr | ||
| domain | ||
| epr_data_exports | ||
| etl | ||
| infrastructure | ||
| model_data/requirements | ||
| orchestration | ||
| recommendations | ||
| repositories | ||
| scripts | ||
| sfr/principal_pitch | ||
| survey_report | ||
| tests | ||
| utilities | ||
| utils | ||
| .coveragerc | ||
| .dockerignore | ||
| .gitignore | ||
| __init__.py | ||
| 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_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