From 8ede69f0518d6b847971a27e5202a4381fce2ecc Mon Sep 17 00:00:00 2001
From: David Hendriks <davidhendriks93@gmail.com>
Date: Wed, 1 Apr 2020 19:56:11 +0100
Subject: [PATCH] updated some errors

---
 binarycpython/utils/distribution_functions.py |  2 +-
 binarycpython/utils/grid.py                   | 21 +++++++++++++++++--
 2 files changed, 20 insertions(+), 3 deletions(-)

diff --git a/binarycpython/utils/distribution_functions.py b/binarycpython/utils/distribution_functions.py
index 278bbef12..f5f73e04e 100644
--- a/binarycpython/utils/distribution_functions.py
+++ b/binarycpython/utils/distribution_functions.py
@@ -130,7 +130,7 @@ def three_part_powerlaw(M, M0, M1, M2, M_MAX, P1, P2, P3):
 
     #
     if M < M0:
-        p = 0  # Below 0
+        p = 0  # Below lower bound
     elif M0 < M <= M1:
         p = three_part_powerlaw_constants[0] * (M ** P1)  # Between M0 and M1
     elif M1 < M <= M2:
diff --git a/binarycpython/utils/grid.py b/binarycpython/utils/grid.py
index 5a3953a22..311e74035 100644
--- a/binarycpython/utils/grid.py
+++ b/binarycpython/utils/grid.py
@@ -344,6 +344,7 @@ class Population(object):
         so, use a recursive function that goes over the all_info dict and finds those that fit
 
         TODO: Fix to write things to the directory. which options do which etc
+        TODO: theres flawed logic here. rewrite this part pls
         """
 
         all_info = self.return_all_info(
@@ -370,7 +371,11 @@ class Population(object):
                 )
 
         if use_datadir:
-            base_name = os.path.splitext(self.custom_options["base_filename"])[0]
+            if not self.custom_options.get('base_filename', None):
+                base_name = 'simulation_{}'.format(datetime.datetime.strftime(datetime.datetime.now(), '%Y%m%d_%H%M%S'))
+            else:
+                base_name = os.path.splitext(self.custom_options["base_filename"])[0]
+
             settings_name = base_name + "_settings.json"
 
             # Check directory, make if necessary
@@ -461,6 +466,11 @@ class Population(object):
         # Dry run and getting starcount
         self.grid_options["probtot"] = 0
 
+        # Put in check 
+        if len(self.grid_options["grid_variables"]) == 0:
+            print("Error: you havent defined any grid variables! Aborting")
+            raise ValueError
+
         self.generate_grid_code(dry_run=True)
 
         self.load_grid_function()
@@ -488,6 +498,8 @@ class Population(object):
         #
         self.load_grid_function()
 
+        #######
+
     def cleanup(self):
         """
         Function that handles all the cleaning up after the grid has been generated and/or run
@@ -1204,6 +1216,11 @@ class Population(object):
         # warning; dont use yet. not fully tested. 
         """
 
+
+
+
+
+
         if self.grid_options["system_generator"]:
             # Check if there is an output dir configured
             if self.custom_options.get("data_dir", None):
@@ -1241,7 +1258,7 @@ class Population(object):
                 else:
                     full_system_dict = self.bse_options.copy()
 
-                for system in self.grid_options["system_generator"]:
+                for system in self.grid_options["system_generator"](self):
                     # update values with current system values
                     full_system_dict.update(system)
 
-- 
GitLab