From 06116de07306d9a061dd071d42ccc1b7e803b4cb Mon Sep 17 00:00:00 2001
From: dh00601 <dh00601@surrey.ac.uk>
Date: Wed, 22 Sep 2021 11:19:24 +0100
Subject: [PATCH] fixed issue

---
 binarycpython/utils/grid.py | 25 +++++++++++++------------
 1 file changed, 13 insertions(+), 12 deletions(-)

diff --git a/binarycpython/utils/grid.py b/binarycpython/utils/grid.py
index cd5728d95..d695262ce 100644
--- a/binarycpython/utils/grid.py
+++ b/binarycpython/utils/grid.py
@@ -101,7 +101,7 @@ class Population:
     population of systems
     """
 
-    def __init__(self):
+    def __init__(self, **kwargs):
         """
         Initialisation function of the population class
         """
@@ -126,13 +126,13 @@ class Population:
         # Custom options
         self.custom_options = {}
 
-        # shared memory used for logging
-        self.shared_memory = {}
+        # Set the options that are passed at creation of the object
+        self.set(**kwargs)
 
         # Load M&s options
         self.grid_options['m&s_options'] = copy.deepcopy(moe_di_stefano_default_options)
 
-        # Write M&S options to a file
+        # Write M&S options to a file. NOTE: not sure why i put this here anymore
         os.makedirs(os.path.join(self.grid_options["tmp_dir"], "moe_distefano"), exist_ok=True)
         with open(os.path.join(os.path.join(self.grid_options["tmp_dir"], "moe_distefano"), "moeopts.dat"), "w") as f:
             f.write(json.dumps(self.grid_options['m&s_options'], indent=4))
@@ -140,13 +140,16 @@ class Population:
         # Argline dict
         self.argline_dict = {}
 
-        # Set main process id
-        self.grid_options["_main_pid"] = os.getpid()
-
         # Set some memory dicts
         self.persistent_data_memory_dict = {}
 
-        #
+        # shared memory used for logging
+        self.shared_memory = {}
+
+        # Set global (OS) process id
+        self.grid_options["_main_pid"] = os.getpid()
+
+        # local process ID
         self.process_ID = 0
 
         # Create location to store results. Users should write to this dictionary.
@@ -168,7 +171,7 @@ class Population:
     # - For a population the bse_options will get copied to a temp_bse_options dict and updated with
     #   all the parameters generated by the grid
 
-    # I will NOT create the argument line by fully writing ALL the defaults and overriding user
+    # I will not create the argument line by fully writing all the defaults and overriding user
     # input, that seems not necessary because by using the get_defaults() function we already
     # know for sure which parameter names are valid for the binary_c version
     # And because binary_c uses internal defaults, its not necessary to explicitly pass them.
@@ -192,8 +195,6 @@ class Population:
             via kwargs all the arguments are either set to binary_c parameters, grid_options or custom_options (see above)
         """
 
-        # Select the params that end with %d
-
         # Go over all the input
         for key in kwargs:
             # Filter out keys for the bse_options
@@ -240,7 +241,7 @@ class Population:
                         key, kwargs[key]
                     ),
                     self.grid_options["verbosity"],
-                    1,
+                    0, # NOTE: setting this to be 0 prevents mistakes being overlooked. 
                 )
                 self.custom_options[key] = kwargs[key]
 
-- 
GitLab