Skip to content

Commit

Permalink
fixed tests
Browse files Browse the repository at this point in the history
  • Loading branch information
Sven Eggimann committed Jan 24, 2018
1 parent ffe6a2d commit 44874f3
Show file tree
Hide file tree
Showing 6 changed files with 25 additions and 29 deletions.
11 changes: 6 additions & 5 deletions energy_demand/read_write/write_data.py
Original file line number Diff line number Diff line change
Expand Up @@ -308,30 +308,31 @@ def create_txt_shapes(
shape_peak_yd_factor,
shape_non_peak_yd
):
"""Function collecting functions to write out txt files
"""Function collecting functions to write out arrays
to txt files
"""
write_array_to_txt(
os.path.join(
path_txt_shapes,
str(end_use) + str("__") + str('shape_peak_dh') + str('.txt')),
shape_peak_dh)
shape_peak_dh)

write_array_to_txt(
os.path.join(
path_txt_shapes,
str(end_use) + str("__") + str('shape_non_peak_y_dh') + str('.txt')),
shape_non_peak_y_dh)
shape_non_peak_y_dh)

write_array_to_txt(
os.path.join(
path_txt_shapes,
str(end_use) + str("__") + str('shape_peak_yd_factor') + str('.txt')),
np.array([shape_peak_yd_factor]))
np.array([shape_peak_yd_factor]))

write_array_to_txt(
os.path.join(
path_txt_shapes,
str(end_use) + str("__") + str('shape_non_peak_yd') + str('.txt')),
shape_non_peak_yd)
shape_non_peak_yd)

return
2 changes: 1 addition & 1 deletion energy_demand/scripts/s_rs_raw_shapes.py
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ def assign_hes_data_to_year(nr_of_appliances, hes_data, base_yr):
year_raw_values : array
Energy data for every day in the base year for every appliances
"""
year_raw_values = np.zeros((365, 24, nr_of_appliances), dtype=float)
year_raw_values = np.zeros((365, 24, nr_of_appliances), dtype=float) #yeardays, houry, appliances

# Create list with all dates of a whole year
list_dates = date_prop.fullyear_dates(
Expand Down
2 changes: 1 addition & 1 deletion run.py
Original file line number Diff line number Diff line change
Expand Up @@ -272,7 +272,7 @@ def simulate(self, timestep, data=None):
key: name defined in sector models
value: np.zeros((len(reg), len(intervals)) )
"""
time_start = datetime.datetime.now()
time_start = datetime.datetime.now()

# Convert data to default dict
data = defaultdict(dict, data)
Expand Down
14 changes: 7 additions & 7 deletions tests/scripts/test_s_rs_raw_shapes.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
def test_assign_hes_data_to_year():

hes_data = {
'holiday': {
'working_day': {
0: np.zeros((24, 2)) + 10,
1: np.zeros((24, 2)) + 20,
2: np.zeros((24, 2)) + 30,
Expand All @@ -18,10 +18,9 @@ def test_assign_hes_data_to_year():
8: np.zeros((24, 2)) + 90,
9: np.zeros((24, 2)) + 100,
10: np.zeros((24, 2)) + 110,
11: np.zeros((24, 2)) + 120
},
11: np.zeros((24, 2)) + 120},

'workday' : {
'holiday' : {
0: np.zeros((24, 2)) + 1,
1: np.zeros((24, 2)) + 2,
2: np.zeros((24, 2)) + 3,
Expand All @@ -39,7 +38,8 @@ def test_assign_hes_data_to_year():
result = s_rs_raw_shapes.assign_hes_data_to_year(
nr_of_appliances=2,
hes_data=hes_data,
base_yr=2017)
base_yr=2015)

assert result['holiday'][0][0] == 10 #daytype, month_python, appliances
assert result['workday'][0][0] == 1
#daytype, month_python, appliances
assert result[10][0][1] == 1 # yearday, hour, appliance_nr--> sun
assert result[11][0][1] == 10 # yearday, hour, appliance_nr--> mon
4 changes: 0 additions & 4 deletions tests/scripts/test_s_shared_functions.py

This file was deleted.

21 changes: 10 additions & 11 deletions tests/test_enduse_func.py
Original file line number Diff line number Diff line change
Expand Up @@ -78,11 +78,10 @@ def test_service_switch():

tot_service_yh_cy = np.full((365, 24), 1.0) #constant share of 1 in every hour
service_tech_by_p = {"boilerA": share_boilerA_by, "boilerB": share_boilerB_by}
tech_increase_service = {"boilerA": 0.001}
tech_decrease_service = {"boilerB": 0.001}
tech_increase_service = {"boilerA": share_boilerA_by}
tech_decrease_service = {"boilerB": share_boilerB_by}
tech_constant_service = []

enduse = "heating"
sig_param_tech = {
"boilerA": {
'midpoint': fit_parameter[0],
Expand Down Expand Up @@ -134,11 +133,11 @@ def test_service_switch():

tot_service_yh_cy = np.full((365, 24), 1.0) #constant share of 1 in every hour
service_tech_by_p = {"boilerA": share_boilerA_by, "boilerB": share_boilerB_by}
tech_increase_service = {"boilerA": 0.001}
tech_decrease_service = {"boilerB": 0.001}

tech_increase_service = {"boilerA": share_boilerA_by}
tech_decrease_service = {"boilerB": share_boilerB_by}
tech_constant_service = []

enduse = "heating"
sig_param_tech = {
"boilerA": {
'midpoint': fit_parameter[0],
Expand Down Expand Up @@ -192,8 +191,9 @@ def test_service_switch():

tot_service_yh_cy = np.full((365, 24), 1.0) #constant share of 1 in every hour
service_tech_by_p = {"boilerA": share_boilerA_by, "boilerB": share_boilerB_by}
tech_increase_service = {"boilerA": 0.001}
tech_decrease_service = {"boilerB": 0.001}

tech_increase_service = {"boilerA": share_boilerA_by}
tech_decrease_service = {"boilerB": share_boilerB_by}
tech_constant_service = []

enduse = "heating"
Expand Down Expand Up @@ -265,8 +265,8 @@ def test_calc_lf_improvement():
loadfactor_yd_cy[1][1] = 0.3
yr_until_change = 2020

result, crit = enduse_func.calc_lf_improvement(
'heating',
result = enduse_func.calc_lf_improvement(
'demand_management_improvement__heating',
base_yr,
curr_yr,
loadfactor_yd_cy,
Expand All @@ -275,7 +275,6 @@ def test_calc_lf_improvement():

expected = loadfactor_yd_cy + 0.25

assert crit == True
assert result[0][0] == expected[0][0]
assert result[0][1] == expected[0][1]
assert result[1][0] == expected[1][0]
Expand Down

0 comments on commit 44874f3

Please sign in to comment.