From 1117151f4249d02651096ee7756ec034f75c7dbc Mon Sep 17 00:00:00 2001
From: David Hendriks <davidhendriks93@gmail.com>
Date: Tue, 29 Dec 2020 23:31:07 +0000
Subject: [PATCH] fixed small bugs

---
 binarycpython/utils/grid.py                  | 31 +++++++++++---------
 binarycpython/utils/grid_options_defaults.py |  5 ++--
 2 files changed, 19 insertions(+), 17 deletions(-)

diff --git a/binarycpython/utils/grid.py b/binarycpython/utils/grid.py
index 8d3e6588f..eec2d188c 100644
--- a/binarycpython/utils/grid.py
+++ b/binarycpython/utils/grid.py
@@ -641,7 +641,7 @@ class Population:
         """
 
         # TODO: set a unique population_name here
-        self.grid_options["unique_population_name"] = uuid.uuid4().hex
+        self.grid_options["population_id"] = uuid.uuid4().hex
 
         ##
         # Prepare code/initialise grid.
@@ -668,7 +668,7 @@ class Population:
             )
 
         verbose_print(
-            "Population-{} finished!".format(self.grid_options['unique_population_name']), 
+            "Population-{} finished!".format(self.grid_options['population_id']), 
             self.grid_options["verbosity"], 
             0
         )
@@ -682,7 +682,7 @@ class Population:
             )
             # Some information afterwards
             verbose_print(
-                "The full argline commands for {} these systems have been written to {}".format("ALL" if not self.grid_options['error_exceeded'] else "SOME (only the first ones, as there were too many to log all of them)", os.path.join(self.grid_options['tmp_dir'], 'failed_systemsX.txt')),
+                "The full argline commands for {} these systems have been written to {}".format("ALL" if not self.grid_options['errors_exceeded'] else "SOME (only the first ones, as there were too many to log all of them)", os.path.join(self.grid_options['tmp_dir'], 'failed_systemsX.txt')),
                 self.grid_options["verbosity"], 
                 0
             )
@@ -746,10 +746,11 @@ class Population:
         # Return a set of results and errors
         output_dict = {
             "results": self.grid_options["results"], 
-            "total_errors": self.grid_options['failed_count'], 
-            "total_probability_errors": self.grid_options['failed_prob'],
-            "unique_error_codes": self.grid_options['failed_systems_error_codes'],
-            "error_exceeded": self.grid_options['error_exceeded'],
+            "failed_count": self.grid_options['failed_count'], 
+            "failed_prob": self.grid_options['failed_prob'],
+            "failed_systems_error_codes": self.grid_options['failed_systems_error_codes'],
+            "errors_exceeded": self.grid_options['errors_exceeded'],
+            "errors_found": self.grid_options['errors_found'],
         }
 
         return output_dict
@@ -805,10 +806,12 @@ class Population:
         print(combined_output_dict)
 
         self.grid_options["results"] = combined_output_dict["results"]
-        self.grid_options["failed_count"] = combined_output_dict["total_errors"]
-        self.grid_options["failed_prob"] = combined_output_dict["total_probability_errors"]
-        self.grid_options["failed_systems_error_codes"] = list(set(combined_output_dict["unique_error_codes"]))        
-        self.grid_options["error_exceeded"] = combined_output_dict["error_exceeded"]
+        self.grid_options["failed_count"] = combined_output_dict["failed_count"]
+        self.grid_options["failed_prob"] = combined_output_dict["failed_prob"]
+        self.grid_options["failed_systems_error_codes"] = list(set(combined_output_dict["failed_systems_error_codes"]))        
+        self.grid_options["errors_exceeded"] = combined_output_dict["errors_exceeded"]
+        self.grid_options["errors_found"] = combined_output_dict["errors_found"]
+
 
     def _evolve_population_lin(self):
         """
@@ -2352,19 +2355,19 @@ class Population:
 
             # Check if we have exceeded the amount of errors
             if self.grid_options['failed_count'] > self.grid_options['failed_systems_threshold']:
-                if not self.grid_options['error_exceeded']:
+                if not self.grid_options['errors_exceeded']:
                     verbose_print(
                         "Process {} exceeded the maximum ({}) amount of failing systems. Stopped logging them to files now".format(self.process_ID, self.grid_options['failed_systems_threshold']),
                         self.grid_options["verbosity"],
                         1,
                     )
-                    self.grid_options['error_exceeded'] = True
+                    self.grid_options['errors_exceeded'] = True
 
             # If not, write the failing systems to files unique to each process
             else:
                 # Write arglines to file
                 argstring = self._return_argline(system_dict)
-                with open(os.path.join(self.grid_options['tmp_dir'], 'failed_systems_process_{}.txt'.format(self.process_ID)), 'a+') as f:
+                with open(os.path.join(self.grid_options['tmp_dir'], 'failed_systems_{}_process_{}.txt'.format(self.grid_options['population_id'], self.process_ID)), 'a+') as f:
                     f.write(argstring+"\n")
 
 ################################################################################################
diff --git a/binarycpython/utils/grid_options_defaults.py b/binarycpython/utils/grid_options_defaults.py
index 4f8e14584..6e2a01d58 100644
--- a/binarycpython/utils/grid_options_defaults.py
+++ b/binarycpython/utils/grid_options_defaults.py
@@ -10,7 +10,6 @@ grid_options_defaults_dict = {
     ##########################
     # general (or unordered..)
     ##########################
-    "unique_population_name": 0 # Unique code for the population. Should be set only once by the controller process. 
     "amt_cores": 1,  # total amount of cores used to evolve the population
     "binary": 0,  # FLag on whether the systems are binary systems or single systems.
     "parse_function": None,  # FUnction to parse the output with.
@@ -82,12 +81,12 @@ grid_options_defaults_dict = {
     "start_time_evolution": 0,  # Start time of the grid
     "end_time_evolution": 0,  # end time of the grid
     "errors_found": False,  # Flag whether there are any errors from binary_c
-    "error_exceeded": False, # Flag whether the amt of errors have exceeded the limit
+    "errors_exceeded": False, # Flag whether the amt of errors have exceeded the limit
     "failed_count": 0,  # amt of failed systems
     "failed_prob": 0,  # Summed probability of failed systems
     "failed_systems_threshold": 20, # Maximum failed systems per process allowed to fail before the process stops logging the failing systems. 
     "failed_systems_error_codes": [], # List to store the unique error codes
-    "id": 0,  # Random id of this grid/population run,
+    "population_id": 0,  # Random id of this grid/population run, Unique code for the population. Should be set only once by the controller process. 
     "modulo": 1,  # run modulo n of the grid.
     ## Grid type evolution
     "grid_variables": {},  # grid variables
-- 
GitLab