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

updated stuff

parent 22049a49
No related branches found
No related tags found
No related merge requests found
...@@ -351,6 +351,16 @@ class Population(object): ...@@ -351,6 +351,16 @@ class Population(object):
include_binary_c_help_all=include_binary_c_help_all, include_binary_c_help_all=include_binary_c_help_all,
) )
# Copy dict
all_info_cleaned = copy.deepcopy(all_info)
# Clean the all_info_dict: (i.e. transform the function objects to strings)
if all_info_cleaned.get('population_settings', None):
if all_info_cleaned['population_settings']['grid_options']['parse_function']:
all_info_cleaned['population_settings']['grid_options']['parse_function'] = str(all_info_cleaned['population_settings']['grid_options']['parse_function'])
if use_datadir: if use_datadir:
base_name = os.path.splitext(self.custom_options["base_filename"])[0] base_name = os.path.splitext(self.custom_options["base_filename"])[0]
settings_name = base_name + "_settings.json" settings_name = base_name + "_settings.json"
...@@ -366,14 +376,14 @@ class Population(object): ...@@ -366,14 +376,14 @@ class Population(object):
print("Writing settings to {}".format(settings_fullname)) print("Writing settings to {}".format(settings_fullname))
# if not outfile.endswith('json'): # if not outfile.endswith('json'):
with open(settings_fullname, "w") as f: with open(settings_fullname, "w") as f:
f.write(json.dumps(all_info, indent=4)) f.write(json.dumps(all_info_cleaned, indent=4))
else: else:
if self.grid_options["verbose"] > 0: if self.grid_options["verbose"] > 0:
print("Writing settings to {}".format(outfile)) print("Writing settings to {}".format(outfile))
# if not outfile.endswith('json'): # if not outfile.endswith('json'):
with open(outfile, "w") as f: with open(outfile, "w") as f:
f.write(json.dumps(all_info, indent=4)) f.write(json.dumps(all_info_cleaned, indent=4))
def set_custom_logging(self): def set_custom_logging(self):
""" """
...@@ -978,6 +988,7 @@ class Population(object): ...@@ -978,6 +988,7 @@ class Population(object):
code_string += "import numpy as np\n" code_string += "import numpy as np\n"
code_string += "from binarycpython.utils.distribution_functions import *\n" code_string += "from binarycpython.utils.distribution_functions import *\n"
code_string += "from binarycpython.utils.spacing_functions import *\n" code_string += "from binarycpython.utils.spacing_functions import *\n"
code_string += "from binarycpython.utils.useful_funcs import *\n"
code_string += "\n\n" code_string += "\n\n"
# Make the function # Make the function
...@@ -1123,7 +1134,7 @@ class Population(object): ...@@ -1123,7 +1134,7 @@ class Population(object):
code_string += ( code_string += (
indent * (depth + 1) indent * (depth + 1)
+ "{}".format( + "{}".format(
grid_variable["precode"].replace("\n", "\n" + indent * (depth + 1)) grid_variable["precode"].replace("\n", "\n" + indent * (depth))
) )
+ "\n" + "\n"
) )
...@@ -1440,9 +1451,9 @@ class Population(object): ...@@ -1440,9 +1451,9 @@ class Population(object):
# Define frequency # Define frequency
if self.grid_options['verbose'] == 1: if self.grid_options['verbose'] == 1:
print_freq = 10
else:
print_freq = 1 print_freq = 1
else:
print_freq = 10
# Calculate amount of time left # Calculate amount of time left
......
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