Skip to content

Commit

Permalink
Merge remote-tracking branch 'cf/optimization' into optimization
Browse files Browse the repository at this point in the history
  • Loading branch information
dzalkind committed Sep 19, 2024
2 parents 2531e20 + 6aea63d commit 7ef0f32
Showing 1 changed file with 20 additions and 13 deletions.
33 changes: 20 additions & 13 deletions weis/glue_code/runWEIS.py
Original file line number Diff line number Diff line change
Expand Up @@ -231,19 +231,26 @@ def run_weis(fname_wt_input, fname_modeling_options, fname_opt_options, geometry
desvar_opts=["lower", "upper",],
cons_opts=["lower", "upper", "equals",],
)
# clean up the problem_var_dict that we extracted for output
for k in problem_var_dict.keys():
if not problem_var_dict.get(k): continue
for idx in range(len(problem_var_dict[k])):
for kk in problem_var_dict[k][idx][1].keys():
if isinstance(problem_var_dict[k][idx][1][kk], np.ndarray):
problem_var_dict[k][idx][1][kk] = problem_var_dict[k][idx][1][kk].tolist()
if isinstance(problem_var_dict[k][idx][1][kk], np.int32):
problem_var_dict[k][idx][1][kk] = int(problem_var_dict[k][idx][1][kk])
if isinstance(problem_var_dict[k][idx][1][kk], np.float64):
problem_var_dict[k][idx][1][kk] = float(problem_var_dict[k][idx][1][kk])

save_yaml(folder_output, "problem_vars.yaml", simple_types(problem_var_dict))
def simple_types_temp(indict : dict) -> dict: # DEBUG!!!!!
"""
until the changes to WISDEM go through...
"""
def convert(value):
if isinstance(value, np.ndarray):
return convert(value.tolist())
elif isinstance(value, dict):
return {key: convert(value) for key, value in value.items()}
elif isinstance(value, (list, tuple, set)):
return [convert(item) for item in value] # treat all as list
elif isinstance(value, (np.generic)):
return value.item() # convert numpy primatives to python primative underlying
elif isinstance(value, (float, int, bool, str)):
return value # this should be the end case
else:
return ""
return convert(indict)
save_yaml(folder_output, "problem_vars.yaml", simple_types_temp(problem_var_dict))
# save_yaml(folder_output, "problem_vars.yaml", simple_types(problem_var_dict))

# Save data to numpy and matlab arrays
fileIO.save_data(froot_out, wt_opt)
Expand Down

0 comments on commit 7ef0f32

Please sign in to comment.