From 88a2ac9cfb171a470229f95d09011cfddec4f899 Mon Sep 17 00:00:00 2001
From: David Hendriks <davidhendriks93@gmail.com>
Date: Mon, 7 Jun 2021 23:46:33 +0100
Subject: [PATCH] Fixed the bug with the mass lower bound

---
 binarycpython/utils/distribution_functions.py | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/binarycpython/utils/distribution_functions.py b/binarycpython/utils/distribution_functions.py
index 83aa6132d..ee4a0e81a 100644
--- a/binarycpython/utils/distribution_functions.py
+++ b/binarycpython/utils/distribution_functions.py
@@ -1288,7 +1288,7 @@ def build_q_table(options, m, p, verbosity=0):
                     "high"
                 ] = 1  # TODO: shouldnt the extrapolation need to happen if qmax > 0.95
                 qdata[qmin] = Moecache["rinterpolator_q"].interpolate(
-                    [np.log10(options[m]), np.log10(options[p])]
+                    [np.log10(options[m]), np.log10(options[p]), qmin]
                 )[0]
 
                 for q in np.arange(0.15, 0.950001, 0.1):
@@ -1469,14 +1469,14 @@ def build_q_table(options, m, p, verbosity=0):
             )
 
             # now we integrate and renormalize (if the table is not all zero)
-            I = get_integration_constant_q(q_interpolator, verbosity=verbosity)
+            I = get_integration_constant_q(q_interpolator, tmp_table, qdata, verbosity=verbosity)
 
             if I > 0:
                 # normalize to 1.0 by dividing the data by 1.0/$I
                 q_interpolator.multiply_table_column(1, 1.0 / I)
 
                 # test this
-                new_I = get_integration_constant_q(q_interpolator, verbosity=verbosity)
+                new_I = get_integration_constant_q(q_interpolator, tmp_table, qdata, verbosity=verbosity)
 
                 # fail if error in integral > 1e-6 (should be ~ machine precision)
                 if abs(1.0 - new_I) > 1e-6:
@@ -1555,7 +1555,7 @@ def linear_extrapolation_q(qs, indices, qlimit, qdata, end_index, verbosity=0):
     return max(0.0, slope * qlimit + intercept)
 
 
-def get_integration_constant_q(q_interpolator, verbosity=0):
+def get_integration_constant_q(q_interpolator, tmp_table, qdata, verbosity=0):
     """
     Function to integrate the q interpolator and return the integration constant
     """
-- 
GitLab