mirror of
https://github.com/Hestia-Homes/Model.git
synced 2026-06-08 11:17:27 +00:00
Wholesale rename of the Baseline aggregate to PropertyBaseline for clarity /
to disambiguate from baselines that appear elsewhere in Modelling. Scoped to
this aggregate only — the distinct Rebaselining term (rebaseline_reason,
StubRebaseliner, RebaselineNotImplemented) is deliberately untouched.
- domain/baseline → domain/property_baseline; BaselinePerformance →
PropertyBaselinePerformance.
- repositories/baseline → repositories/property_baseline; BaselineRepository
/ BaselinePostgresRepository → PropertyBaseline*.
- orchestration/baseline_orchestrator.py → property_baseline_orchestrator.py;
BaselineOrchestrator → PropertyBaselineOrchestrator. BaselineStage →
PropertyBaselineStage.
- infrastructure/postgres: baseline_performance_table.py →
property_baseline_performance_table.py; table `baseline_performance` →
`property_baseline_performance`; Model renamed.
- UnitOfWork attribute `.baseline` → `.property_baseline`.
- Docs: ADR-0004 references + migration doc (renamed to
property-baseline-performance-table.md) updated.
CONTEXT.md glossary term ("Baseline Performance") left as-is pending a
ubiquitous-language call (raised on the PR). 123 tests pass; pyright strict
clean (only the unrelated pre-existing moto import errors remain).
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
53 lines
1.8 KiB
Python
53 lines
1.8 KiB
Python
from __future__ import annotations
|
|
|
|
from dataclasses import dataclass
|
|
from typing import Optional, TypeVar
|
|
|
|
from datatypes.epc.domain.epc import Epc
|
|
from datatypes.epc.domain.epc_property_data import EpcPropertyData
|
|
|
|
_T = TypeVar("_T")
|
|
|
|
|
|
@dataclass(frozen=True)
|
|
class Performance:
|
|
"""One half of a Baseline Performance — a single set of SAP10 figures.
|
|
|
|
The four quantities a Property is rated on (CONTEXT.md: Lodged / Effective
|
|
Performance): SAP score, EPC Band, carbon emissions, and Primary Energy
|
|
Intensity. Used for both the Lodged half (off the gov register) and the
|
|
Effective half (what the modelling pipeline scored against).
|
|
"""
|
|
|
|
sap_score: int
|
|
epc_band: Epc
|
|
co2_emissions: float
|
|
primary_energy_intensity: int
|
|
|
|
|
|
def _require(value: Optional[_T], field: str) -> _T:
|
|
if value is None:
|
|
raise ValueError(
|
|
f"EPC is missing recorded performance field {field!r}; "
|
|
"cannot establish Lodged Performance"
|
|
)
|
|
return value
|
|
|
|
|
|
def lodged_performance(epc: EpcPropertyData) -> Performance:
|
|
"""The Lodged Performance recorded on an EPC — what the gov register says.
|
|
|
|
Reads the four rated quantities straight off the EPC's recorded fields
|
|
(CONTEXT.md: Primary Energy Intensity is recorded as `energy_consumption_current`).
|
|
Unmodified by modelling.
|
|
"""
|
|
return Performance(
|
|
sap_score=_require(epc.energy_rating_current, "energy_rating_current"),
|
|
epc_band=_require(
|
|
epc.current_energy_efficiency_band, "current_energy_efficiency_band"
|
|
),
|
|
co2_emissions=_require(epc.co2_emissions_current, "co2_emissions_current"),
|
|
primary_energy_intensity=_require(
|
|
epc.energy_consumption_current, "energy_consumption_current"
|
|
),
|
|
)
|