mirror of
https://github.com/Hestia-Homes/Model.git
synced 2026-06-08 11:17:27 +00:00
new model data pickle
This commit is contained in:
parent
a62ddf4ddc
commit
4dfa32ca1f
4 changed files with 51 additions and 1 deletions
|
|
@ -1,3 +1,4 @@
|
|||
import pickle
|
||||
import pandas as pd
|
||||
import numpy as np
|
||||
from model_data.EpcClean import EpcClean
|
||||
|
|
@ -195,3 +196,12 @@ class UvalueEstimations:
|
|||
# Classify new values based on decile definitions
|
||||
classifications = pd.cut(new_values, bins=decile_boundaries, labels=decile_labels, include_lowest=True)
|
||||
return classifications.tolist()
|
||||
|
||||
def _save(self, filename):
|
||||
"""
|
||||
Useful utility function to store this object, which is particularly handy for unit testing
|
||||
:return:
|
||||
"""
|
||||
with open(filename, 'wb') as f:
|
||||
pickle.dump(self, f)
|
||||
|
||||
Binary file not shown.
40
model_data/tests/test_floor_recommendations.py
Normal file
40
model_data/tests/test_floor_recommendations.py
Normal file
|
|
@ -0,0 +1,40 @@
|
|||
import pickle
|
||||
import pytest
|
||||
import os
|
||||
from unittest.mock import Mock
|
||||
from model_data.recommendations.FloorRecommendations import FloorRecommendations
|
||||
|
||||
|
||||
class TestWallRecommendations:
|
||||
|
||||
@pytest.fixture
|
||||
def input_properties(self):
|
||||
with open(
|
||||
os.path.abspath(os.path.dirname(__file__)) + "/test_data/input_properties.pkl", "rb"
|
||||
) as f:
|
||||
return pickle.load(f)
|
||||
|
||||
@pytest.fixture
|
||||
def uvalue_estimates(self):
|
||||
with open(
|
||||
os.path.abspath(os.path.dirname(__file__)) + "/test_data/uvalue_estimates.pkl", "rb"
|
||||
) as f:
|
||||
return pickle.load(f)
|
||||
|
||||
@pytest.fixture
|
||||
def mock_floor_rec_instance(self):
|
||||
# Creating a mock instance of WallRecommendations with the necessary attributes
|
||||
property_mock = Mock()
|
||||
property_mock.full_sap_epc = {"lodgement-date": "2000-01-01"} # or any date you want
|
||||
property_mock.data = {"construction-age-band": "1950"} # or any other data that fits your tests
|
||||
|
||||
uvalue_estimates_mock = Mock()
|
||||
|
||||
mock_wall_rec_instance = FloorRecommendations(property_mock, uvalue_estimates_mock)
|
||||
return mock_wall_rec_instance
|
||||
|
||||
def test_init(self, input_properties, uvalue_estimates):
|
||||
obj = FloorRecommendations(property_instance=input_properties[0], uvalue_estimates=uvalue_estimates)
|
||||
assert obj
|
||||
assert obj.property
|
||||
assert obj.uvalue_estimates
|
||||
|
|
@ -23,7 +23,7 @@ class TestWallRecommendations:
|
|||
@pytest.fixture
|
||||
def uvalue_estimates(self):
|
||||
with open(
|
||||
os.path.abspath(os.path.dirname(__file__)) + "/test_data/uvalue_estimates_walls.pkl", "rb"
|
||||
os.path.abspath(os.path.dirname(__file__)) + "/test_data/uvalue_estimates.pkl", "rb"
|
||||
) as f:
|
||||
return pickle.load(f)
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue