From 0df3b40d1e02f64f11746b4c890888eab627b939 Mon Sep 17 00:00:00 2001
From: Robert Izzard <r.izzard@surrey.ac.uk>
Date: Tue, 7 Dec 2021 17:02:39 +0100
Subject: [PATCH] allow options to be passed to the IMF

---
 binarycpython/utils/distribution_functions.py |  9 +++++++--
 binarycpython/utils/spacing_functions.py      | 16 +++++-----------
 2 files changed, 12 insertions(+), 13 deletions(-)

diff --git a/binarycpython/utils/distribution_functions.py b/binarycpython/utils/distribution_functions.py
index 90621dd60..56799098c 100644
--- a/binarycpython/utils/distribution_functions.py
+++ b/binarycpython/utils/distribution_functions.py
@@ -1732,7 +1732,7 @@ class distribution_functions():
         return prob_dict
 
 
-    def Moe_di_Stefano_2017_pdf(self,options, verbosity=0):
+    def Moe_di_Stefano_2017_pdf(self, options, verbosity=0):
         """
         Moe & diStefano function to calculate the probability density.
 
@@ -1744,6 +1744,8 @@ class distribution_functions():
 
         mmin => minimum allowed stellar mass (default 0.07)
         mmax => maximum allowed stellar mass (default 80.0)
+
+        M1 options => options passed to the IMF function Kroupa2001()
         """
 
         verbose_print(
@@ -1805,8 +1807,11 @@ class distribution_functions():
 
         # TODO: Create an n-part-powerlaw method that can have breakpoints and slopes. I'm using a three-part power law now.
         # TODO: is this actually the correct way? putting the M1 in there? Do we sample in log space?
+        if "M1 options" in options:
+            M1_probability = self.Kroupa2001(m=options["M_1"],newopts=options["M1 options"]) * options["M_1"]
+        else:
+            M1_probability = self.Kroupa2001(options["M_1"]) * options["M_1"]
 
-        M1_probability = self.Kroupa2001(options["M_1"]) * options["M_1"]
 
         prob_dict["M_1"] = M1_probability
         verbose_print(
diff --git a/binarycpython/utils/spacing_functions.py b/binarycpython/utils/spacing_functions.py
index 2525d5c3a..392efbe65 100644
--- a/binarycpython/utils/spacing_functions.py
+++ b/binarycpython/utils/spacing_functions.py
@@ -335,24 +335,18 @@ class spacing_functions():
                 return func(*args, **kwargs)
             return wrapped
 
-        print("No brackets",cache.memoize)
+        #print("No brackets",cache.memoize)
         # <bound method Cache.memoize of <diskcache.core.Cache object at 0x14a83739d2e0>>
-        print("brackets",cache.memoize())
+        #print("brackets",cache.memoize())
         #  <function Cache.memoize.<locals>.decorator at 0x14a8373f6d30>
 
         if cache is not None:
-            try:
-                eval('cache.memoize')
-                print("could not eval ()")
-                use_brackets = False
-            except:
-                print("could eval ()")
-                use_brackets = True
 
             # brackets: works on 3.9
-            # no brackets : works on 3.8
+            # no brackets : works on 3.8 ? brackets ALSO seem to work
             #
-            # brackets are correct! http://www.grantjenks.com/docs/diskcache/tutorial.html
+            # indeed, brackets are correct!
+            # http://www.grantjenks.com/docs/diskcache/tutorial.html
             __decorator = cache.memoize()
         else:
             __decorator = __dummy_decorator
-- 
GitLab