Skip to content

Commit

Permalink
some quality of life improvements
Browse files Browse the repository at this point in the history
  • Loading branch information
Mathias Methlie Nilsen authored and KriFos1 committed Dec 22, 2023
1 parent 81aff91 commit fb6eeaf
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 5 deletions.
1 change: 0 additions & 1 deletion popt/cost_functions/ren_npv.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,6 @@ def ren_npv(pred_data, keys_opt, report):
Qwi = np.sum(Qwi, axis=0)

delta_days = (report[1][i] - report[1][i - 1]).days

val = (Qop * npv_const['wop'] + Qgp * npv_const['wgp'] - Qwp * npv_const['wwp'] - Qwi * npv_const['wwi'] -
Qrenwi * npv_const['wrenwi']) / (
(1 + npv_const['disc']) ** (delta_days / 365))
Expand Down
4 changes: 2 additions & 2 deletions popt/loop/ensemble.py
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ def __set__variable(var_name=None, defalut=None):
self.bounds = []
self.cov = np.array([])
for name in self.prior_info.keys():
self.state[name] = self.prior_info[name]['mean']
self.state[name] = np.asarray(self.prior_info[name]['mean'])
num_state_var = len(self.state[name])
value_cov = self.prior_info[name]['variance'] * np.ones((num_state_var,))
if 'limits' in self.prior_info[name].keys():
Expand Down Expand Up @@ -204,7 +204,7 @@ def function(self, x, *args):
self.state_func_values = func_values
else:
self.ens_func_values = func_values

return func_values

def gradient(self, x, *args):
Expand Down
3 changes: 1 addition & 2 deletions popt/misc_tools/optim_tools.py
Original file line number Diff line number Diff line change
Expand Up @@ -291,7 +291,6 @@ def save_optimize_results(intermediate_result):
intermediate_result : scipy.optimize.OptimizeResult
An instance of an OptimizeResult class
"""

# Cast to OptimizeResult if a ndarray is passed as argument
if type(intermediate_result) is np.ndarray:
intermediate_result = OptimizeResult({'x': intermediate_result})
Expand All @@ -300,7 +299,7 @@ def save_optimize_results(intermediate_result):
if 'save_folder' in intermediate_result:
save_folder = intermediate_result['save_folder']
if not os.path.exists(save_folder):
os.mkdir(save_folder)
os.makedirs(save_folder)
else:
save_folder = './'

Expand Down

0 comments on commit fb6eeaf

Please sign in to comment.