mirror of
https://github.com/Hestia-Homes/Model.git
synced 2026-07-27 23:35:01 +00:00
Band a continuous SAP score on its published rating 🟩
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
parent
08abd3131b
commit
07a71ad504
1 changed files with 9 additions and 1 deletions
|
|
@ -1,3 +1,4 @@
|
|||
from decimal import ROUND_HALF_UP, Decimal
|
||||
from enum import Enum
|
||||
|
||||
|
||||
|
|
@ -34,7 +35,14 @@ class Epc(Enum):
|
|||
|
||||
@classmethod
|
||||
def from_sap_continuous(cls, score: float) -> "Epc":
|
||||
raise NotImplementedError
|
||||
"""The band an un-rounded SAP rating is *published* in.
|
||||
|
||||
A dwelling is banded on the integer published on its EPC, which rounds
|
||||
half up (SAP 10.2 §13) — so this is `from_sap_score` over that rounding
|
||||
rather than over Python's half-to-even `round`, which would drop an
|
||||
exact x.5 at a band floor into the band below."""
|
||||
published: int = int(Decimal(score).quantize(Decimal("1"), rounding=ROUND_HALF_UP))
|
||||
return cls.from_sap_score(published)
|
||||
|
||||
def sap_lower_bound(self) -> int:
|
||||
"""The minimum SAP rating in this band — the inverse of
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue