mirror of
https://github.com/Hestia-Homes/Model.git
synced 2026-07-12 13:29:04 +00:00
Adding unit tests, made floor recommendations code simpler
This commit is contained in:
parent
8b3e8710c9
commit
3f43ef3ee9
3 changed files with 39 additions and 40 deletions
|
|
@ -70,6 +70,8 @@ def handler():
|
||||||
|
|
||||||
local_authorities = {p.data['local-authority'] for p in input_properties}
|
local_authorities = {p.data['local-authority'] for p in input_properties}
|
||||||
|
|
||||||
|
# TODO: Create a more balanced sample where we grab more properties across different properties
|
||||||
|
# types, as e.g. we're pulling many more flats than houses
|
||||||
data = []
|
data = []
|
||||||
for la in tqdm(local_authorities):
|
for la in tqdm(local_authorities):
|
||||||
data.extend(
|
data.extend(
|
||||||
|
|
|
||||||
|
|
@ -86,7 +86,8 @@ class FloorRecommendations(BaseUtility):
|
||||||
FLOOR_LEVELS = {
|
FLOOR_LEVELS = {
|
||||||
"Ground": 0,
|
"Ground": 0,
|
||||||
# We don't know what floor level, we just make sure it's not 0
|
# We don't know what floor level, we just make sure it's not 0
|
||||||
"mid floor": 1
|
"mid floor": 1,
|
||||||
|
"NODATA!": None
|
||||||
}
|
}
|
||||||
|
|
||||||
def __init__(self, property_instance: Property, uvalue_estimates: UvalueEstimations):
|
def __init__(self, property_instance: Property, uvalue_estimates: UvalueEstimations):
|
||||||
|
|
@ -219,49 +220,31 @@ class FloorRecommendations(BaseUtility):
|
||||||
else:
|
else:
|
||||||
raise NotImplementedError("Implement me")
|
raise NotImplementedError("Implement me")
|
||||||
|
|
||||||
|
if insulation_thickness == "none":
|
||||||
|
|
||||||
|
region_str, age_band = self.property.data["construction-age-band"].split(":")
|
||||||
|
region_str = region_str.strip()
|
||||||
|
age_band = age_band.strip()
|
||||||
|
region = self.REGION_LOOKUP[region_str]
|
||||||
|
|
||||||
|
u_value = self._estimate_suspended_floor_u_value(
|
||||||
|
floor_area=total_floor_area / num_floors,
|
||||||
|
number_of_rooms=number_of_rooms / num_floors,
|
||||||
|
insulation_thickness=0,
|
||||||
|
wall_type=wall_type,
|
||||||
|
region=region,
|
||||||
|
age_band=age_band,
|
||||||
|
)
|
||||||
|
else:
|
||||||
|
u_value = self._get_floors_uvalue_estimate()
|
||||||
|
|
||||||
|
self.estimated_u_value = u_value
|
||||||
|
|
||||||
if is_suspended:
|
if is_suspended:
|
||||||
|
|
||||||
if insulation_thickness == "none":
|
|
||||||
|
|
||||||
region_str, age_band = self.property.data["construction-age-band"].split(":")
|
|
||||||
region_str = region_str.strip()
|
|
||||||
age_band = age_band.strip()
|
|
||||||
region = self.REGION_LOOKUP[region_str]
|
|
||||||
|
|
||||||
u_value = self._estimate_suspended_floor_u_value(
|
|
||||||
floor_area=total_floor_area / num_floors,
|
|
||||||
number_of_rooms=number_of_rooms / num_floors,
|
|
||||||
insulation_thickness=0,
|
|
||||||
wall_type=wall_type,
|
|
||||||
region=region,
|
|
||||||
age_band=age_band,
|
|
||||||
)
|
|
||||||
else:
|
|
||||||
u_value = self._get_floors_uvalue_estimate()
|
|
||||||
|
|
||||||
# Given the U-value, we recommend underfloor insulation
|
# Given the U-value, we recommend underfloor insulation
|
||||||
self.recommend_floor_insulation(u_value=u_value, parts=suspended_floor_insulation_parts)
|
self.recommend_floor_insulation(u_value=u_value, parts=suspended_floor_insulation_parts)
|
||||||
|
|
||||||
if is_solid:
|
if is_solid:
|
||||||
|
|
||||||
if insulation_thickness == "none":
|
|
||||||
|
|
||||||
region_str, age_band = self.property.data["construction-age-band"].split(":")
|
|
||||||
region_str = region_str.strip()
|
|
||||||
age_band = age_band.strip()
|
|
||||||
region = self.REGION_LOOKUP[region_str]
|
|
||||||
|
|
||||||
u_value = self._estimate_suspended_floor_u_value(
|
|
||||||
floor_area=total_floor_area / num_floors,
|
|
||||||
number_of_rooms=number_of_rooms / num_floors,
|
|
||||||
insulation_thickness=0,
|
|
||||||
wall_type=wall_type,
|
|
||||||
region=region,
|
|
||||||
age_band=age_band,
|
|
||||||
)
|
|
||||||
else:
|
|
||||||
u_value = self._get_floors_uvalue_estimate()
|
|
||||||
|
|
||||||
# Given the U-value, we recommend solid floor insulation options which are usually solid foam
|
# Given the U-value, we recommend solid floor insulation options which are usually solid foam
|
||||||
self.recommend_floor_insulation(u_value=u_value, parts=solid_floor_insulation_parts)
|
self.recommend_floor_insulation(u_value=u_value, parts=solid_floor_insulation_parts)
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -50,6 +50,20 @@ class TestWallRecommendations:
|
||||||
assert obj.property
|
assert obj.property
|
||||||
assert obj.uvalue_estimates
|
assert obj.uvalue_estimates
|
||||||
|
|
||||||
def test_premises_below(self, input_properties, uvalue_estimates):
|
def test_other_premises_below(self, input_properties, uvalue_estimates):
|
||||||
recommender = FloorRecommendations(property_instance=input_properties[0], uvalue_estimates=uvalue_estimates)
|
recommender = FloorRecommendations(property_instance=input_properties[0], uvalue_estimates=uvalue_estimates)
|
||||||
recommender.recommend()
|
recommender.recommend()
|
||||||
|
assert recommender.property.floor["another_property_below"]
|
||||||
|
|
||||||
|
assert not recommender.recommendations
|
||||||
|
|
||||||
|
def test_suspended_no_insulation(self, input_properties, uvalue_estimates):
|
||||||
|
"""
|
||||||
|
For a suspended floor without insulation, we use the rdsap methogology to estimate a U-value for the floor
|
||||||
|
:return:
|
||||||
|
"""
|
||||||
|
recommender = FloorRecommendations(property_instance=input_properties[2], uvalue_estimates=uvalue_estimates)
|
||||||
|
recommender.recommend()
|
||||||
|
assert recommender.property.floor["is_suspended"]
|
||||||
|
assert recommended.es
|
||||||
|
assert recommender.recommendations
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue