mirror of
https://github.com/Hestia-Homes/Model.git
synced 2026-06-08 11:17:27 +00:00
The SAP 10.2 worksheet computes each existing-dwelling metric in two
distinct blocks:
1. "ENERGY RATING" block — uses Table 12 regulated prices + UK-
average climate. Produces SAP score (Block 11a), total fuel
cost (255), total CO2 (272).
2. "EPC COSTS, EMISSIONS AND PRIMARY ENERGY" block — uses Table 32
prices + postcode-specific climate. Produces total CO2 (272)
again with different value, total PE (286).
The two blocks operate on different space-heating demand kWh per
SAP 10.2 §13 (e.g. solid fuel 8: 21097 kWh in rating block vs
16813 kWh in EPC block for London W6).
The corpus regression test was extracting all four pins and asserting
against the cascade's rating-mode result (`cert_to_inputs`). That was
apples-to-apples for SAP/cost/CO2 (the first `(255)` and `(272)`
matches the regex finds ARE in the rating block) but apples-to-
oranges for PE: the `(286)` Total PE only exists in the EPC block,
so every PE pin was comparing rating-mode cascade output against
EPC-block worksheet output. The mismatch inflated every PE residual
by 10-15% of total PE.
The fix runs both cascade modes in the Act phase and assigns:
- rating-mode result → SAP / cost / CO2 residuals
- demand-mode result (`cert_to_demand_inputs`) → PE residual
25 corpus _CorpusExpectation entries re-pinned. Some closed
dramatically (apples-to-apples reveals the cascade was actually
correct):
ashp +1467.90 → -11.80 ← effectively closed
oil pcdb 1/2 +2086.75 → -83.82
oil pcdb 3 +1897.43 → -271.44
electric 1 +2837.14 → +164.91
electric 8 +2113.83 → -224.46
solid fuel 5 +2359.85 → -330.84
Others surfaced larger demand-mode gaps that the block mismatch had
been hiding — these are real cascade gaps the next slices will
address:
electric 3 -850.93 → -3189.22
electric 5/6 +540/+568 → -1797.96 / -1769.84
pcdb 1 -171.70 → -3135.30
solid fuel 2/3 +440.75 / +1451.79 → -2292.47 / -2496.20
The corpus test docstring + per-block-attribution comment now make
the rating-vs-EPC block distinction explicit so future reviewers
don't repeat the same conflation.
Extended handover suite at HEAD post-slice: 876 pass / 0 fail
(unchanged — no test count change, just per-pin value updates).
Pyright net-zero on touched file (0 → 0).
No cascade behaviour change. No golden / unit-test impact (the bug
was specific to the corpus test's pin-extraction logic).
Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
|
||
|---|---|---|
| .. | ||
| handler | ||
| tests | ||
| __init__.py | ||
| db_writer.py | ||
| elmhurst_extractor.py | ||
| extractor.py | ||
| local_runner.py | ||
| parser.py | ||
| pdf.py | ||