Skip to content

Commit 6c3d17f

Browse files
authored
Fix error when simulated data is a float and not a matrix (#140)
1 parent 3e2751c commit 6c3d17f

3 files changed

Lines changed: 12 additions & 9 deletions

File tree

pipt/misc_tools/data_tools.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,10 @@ def en_pred_to_pred_data(en_pred):
124124
if has_data:
125125
member_list = []
126126
for el in en_pred:
127-
member_data = el[ind][typ][:, np.newaxis]
127+
if not isinstance(el[ind][typ],np.ndarray):
128+
member_data = np.array([el[ind][typ]])[:, np.newaxis]
129+
else:
130+
member_data = el[ind][typ][:, np.newaxis]
128131
member_list.append(member_data)
129132

130133
data_type_dict[typ] = np.concatenate(tuple(member_list), axis=1)

popt/cost_functions/ecalc_npv.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -71,10 +71,10 @@ def ecalc_npv(pred_data, **kwargs):
7171
Qgp.append([])
7272
Qwp.append([])
7373
Qwi.append([])
74-
Qop[l].append(np.squeeze(pred_data[i][l]['fopt']) - np.squeeze(pred_data[i - 1][l]['fopt']))
75-
Qgp[l].append(np.squeeze(pred_data[i][l]['fgpt']) - np.squeeze(pred_data[i - 1][l]['fgpt']))
76-
Qwp[l].append(np.squeeze(pred_data[i][l]['fwpt']) - np.squeeze(pred_data[i - 1][l]['fwpt']))
77-
Qwi[l].append(np.squeeze(pred_data[i][l]['fwit']) - np.squeeze(pred_data[i - 1][l]['fwit']))
74+
Qop[l].append(np.squeeze(pred_data[i][l]['FOPT']) - np.squeeze(pred_data[i - 1][l]['FOPT']))
75+
Qgp[l].append(np.squeeze(pred_data[i][l]['FGPT']) - np.squeeze(pred_data[i - 1][l]['FGPT']))
76+
Qwp[l].append(np.squeeze(pred_data[i][l]['FWPT']) - np.squeeze(pred_data[i - 1][l]['FWPT']))
77+
Qwi[l].append(np.squeeze(pred_data[i][l]['FWIT']) - np.squeeze(pred_data[i - 1][l]['FWIT']))
7878
Dd.append((report[1][i] - report[1][i - 1]).days)
7979
T.append((report[1][i] - report[1][0]).days)
8080

popt/cost_functions/npv.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -42,10 +42,10 @@ def npv(pred_data, **kwargs):
4242

4343
values = []
4444
for i in np.arange(1, len(pred_data)):
45-
Qop = np.squeeze(pred_data[i]['fopt']) - np.squeeze(pred_data[i - 1]['fopt'])
46-
Qgp = np.squeeze(pred_data[i]['fgpt']) - np.squeeze(pred_data[i - 1]['fgpt'])
47-
Qwp = np.squeeze(pred_data[i]['fwpt']) - np.squeeze(pred_data[i - 1]['fwpt'])
48-
Qwi = np.squeeze(pred_data[i]['fwit']) - np.squeeze(pred_data[i - 1]['fwit'])
45+
Qop = np.squeeze(pred_data[i]['FOPT']) - np.squeeze(pred_data[i - 1]['FOPT'])
46+
Qgp = np.squeeze(pred_data[i]['FGPT']) - np.squeeze(pred_data[i - 1]['FGPT'])
47+
Qwp = np.squeeze(pred_data[i]['FWPT']) - np.squeeze(pred_data[i - 1]['FWPT'])
48+
Qwi = np.squeeze(pred_data[i]['FWIT']) - np.squeeze(pred_data[i - 1]['FWIT'])
4949
delta_days = (report[1][i] - report[1][0]).days
5050

5151
val = (Qop * npv_const['wop'] + Qgp * npv_const['wgp'] - Qwp * npv_const['wwp'] - Qwi * npv_const['wwi']) / (

0 commit comments

Comments
 (0)