mirror of
https://github.com/Hestia-Homes/Model.git
synced 2026-06-08 11:17:27 +00:00
Slice S0380.38: loosen FEE round-trip tolerance 1e-9 -> 1e-6
test_no_ac_cert_round_trips_fee_equals_space_heating_per_m2 encodes a real SAP 10.2 invariant: when (108) = 0 (no fixed AC) and Appendix H solar is absent (every cohort cert), (109) FEE must equal space_heating_kwh / TFA. The 1e-9 tolerance was too tight. The cascade computes: - FEE: sum_round_per_month(annual_98a) / TFA - space_heating_kwh: sum(monthly_98a_kwh) summed in calculator The two paths sum the same 12 monthlies in different rounding orders and disagree at ~8e-8 (cascade FEE = 95.39072333333334; SH/TFA = 95.39072341347577). 1e-6 is two orders of magnitude tighter than any meaningful path divergence (a stray 4-d.p. rounding step or unintended AC contribution would blow past instantly) and ~12.5x looser than the observed float-arithmetic drift, so the invariant still fires. Also swaps pytest.approx for `abs(a - b) <= tol` per [[feedback-abs-diff-over-pytest-approx]] (strict-pyright flags pytest.approx as partially-unknown; nets -1 error on the file). Test baseline: 712 pass + 0 fails (was 712 + 1). Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
This commit is contained in:
parent
1cea73df7c
commit
883d66ac65
1 changed files with 6 additions and 4 deletions
|
|
@ -334,7 +334,11 @@ def test_no_ac_cert_round_trips_fee_equals_space_heating_per_m2() -> None:
|
||||||
"""For an RdSAP cert without fixed AC, (108) = 0, so SAP 10.2 (109) Fabric
|
"""For an RdSAP cert without fixed AC, (108) = 0, so SAP 10.2 (109) Fabric
|
||||||
Energy Efficiency = (Σ(98a) / TFA) + 0 = annual space heating per m². No
|
Energy Efficiency = (Σ(98a) / TFA) + 0 = annual space heating per m². No
|
||||||
Appendix H solar space heating means Σ(98a) == Σ(98c), so the FEE matches
|
Appendix H solar space heating means Σ(98a) == Σ(98c), so the FEE matches
|
||||||
`space_heating_kwh_per_yr / TFA` to float-equality."""
|
`space_heating_kwh_per_yr / TFA` modulo small float-arithmetic drift —
|
||||||
|
the two paths sum 12 monthlies in different orders / rounding-step
|
||||||
|
sequences, so they disagree at ~1e-7. 1e-6 is loose enough to absorb
|
||||||
|
that drift, tight enough that any meaningful path divergence (e.g. a
|
||||||
|
4-d.p. lodgement step or stray AC contribution) blows past instantly."""
|
||||||
# Arrange
|
# Arrange
|
||||||
epc = _typical_semi_detached_epc()
|
epc = _typical_semi_detached_epc()
|
||||||
assert epc.sap_heating.has_fixed_air_conditioning is False
|
assert epc.sap_heating.has_fixed_air_conditioning is False
|
||||||
|
|
@ -346,9 +350,7 @@ def test_no_ac_cert_round_trips_fee_equals_space_heating_per_m2() -> None:
|
||||||
expected_fee = (
|
expected_fee = (
|
||||||
result.space_heating_kwh_per_yr / result.intermediate["tfa_m2"]
|
result.space_heating_kwh_per_yr / result.intermediate["tfa_m2"]
|
||||||
)
|
)
|
||||||
assert result.fabric_energy_efficiency_kwh_per_m2_yr == pytest.approx(
|
assert abs(result.fabric_energy_efficiency_kwh_per_m2_yr - expected_fee) <= 1e-6
|
||||||
expected_fee, abs=1e-9
|
|
||||||
)
|
|
||||||
assert result.space_cooling_kwh_per_yr == 0.0
|
assert result.space_cooling_kwh_per_yr == 0.0
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue