Skip to content
Snippets Groups Projects
Commit 9aff15b5 authored by David Hendriks's avatar David Hendriks
Browse files

Added the manipulation of the ensemble dictionaries to the grid code

parent b29bf688
No related branches found
No related tags found
No related merge requests found
......@@ -1268,7 +1268,6 @@ def build_q_table(options, m, p, verbosity=0):
Moecache["rinterpolator_q_given_{}_log10{}".format(m, p)].destroy()
gc.collect()
#
if not incache:
# trim and/or expand the table to the range $qmin to $qmax.
......
......@@ -64,8 +64,12 @@ from binarycpython.utils.functions import (
update_dicts,
extract_ensemble_json_from_string,
get_moe_distefano_dataset,
recursive_change_key_to_float,
custom_sort_dict,
recursive_change_key_to_string,
)
# from binarycpython.utils.hpc_functions import (
# get_condor_version,
# get_slurm_version,
......@@ -984,6 +988,30 @@ class Population:
if result_queue.empty():
break
# Extra ensemble result manipulation:
# We need to reformat and multiply by a factor
original_ensemble_results = combined_output_dict['ensemble_results']
float_format_ensemble_results = recursive_change_key_to_float(original_ensemble_results)
del original_ensemble_results
gc.collect()
# Then sort the dictionary
sorted_ensemble_results = custom_sort_dict(float_format_ensemble_results)
del float_format_ensemble_results
gc.collect()
# Then Change the keys back to a string but with a %g format.
reformatted_ensemble_results = recursive_change_key_to_string(sorted_ensemble_results)
del sorted_ensemble_results
gc.collect()
# Put back in the dictionary
combined_output_dict['ensemble_results'] = reformatted_ensemble_results
gc.collect()
# Multiply the value by a factor:
# Put the values back as object properties
self.grid_results = combined_output_dict["results"]
self.grid_ensemble_results = combined_output_dict[
......@@ -1314,6 +1342,28 @@ class Population:
ensemble_raw_output
) # Load this into a dict so that we can combine it later
# Extra ensemble result manipulation:
# We need to reformat and multiply by a factor
original_ensemble_results = ensemble_json["ensemble"]
float_format_ensemble_results = recursive_change_key_to_float(original_ensemble_results)
del original_ensemble_results
gc.collect()
# Then sort the dictionary
sorted_ensemble_results = custom_sort_dict(float_format_ensemble_results)
del float_format_ensemble_results
gc.collect()
# Then Change the keys back to a string but with a %g format.
reformatted_ensemble_results = recursive_change_key_to_string(sorted_ensemble_results)
del sorted_ensemble_results
gc.collect()
# Put back in the dictionary
ensemble_json["ensemble"] = reformatted_ensemble_results
gc.collect()
else:
# If we do not allow this, automatically we will export this to the data_dir, in
# some formatted way
......@@ -1424,6 +1474,7 @@ class Population:
1,
)
self._clean_interpolators()
gc.collect()
return
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment