From 741a4e0351cb0d8031912d58755a35cd0d601497 Mon Sep 17 00:00:00 2001
From: David Hendriks <davidhendriks93@gmail.com>
Date: Sun, 2 May 2021 23:10:13 +0100
Subject: [PATCH] Working on the errors generated by syncing with master

---
 binarycpython/tests/test_custom_logging.py    | 12 +++----
 binarycpython/tests/test_distributions.py     | 16 ---------
 .../utils/custom_logging_functions.py         |  2 ++
 binarycpython/utils/functions.py              | 35 +++++++++++++++++++
 4 files changed, 43 insertions(+), 22 deletions(-)

diff --git a/binarycpython/tests/test_custom_logging.py b/binarycpython/tests/test_custom_logging.py
index 057927324..f15ca184f 100644
--- a/binarycpython/tests/test_custom_logging.py
+++ b/binarycpython/tests/test_custom_logging.py
@@ -18,7 +18,7 @@ class test_custom_logging(unittest.TestCase):
     def test_autogen_C_logging_code(self):
         with Capturing() as output:
             self._test_autogen_C_logging_code()
-        print("\n".join(output))
+        # print("\n".join(output))
 
     def _test_autogen_C_logging_code(self):
         """
@@ -51,7 +51,7 @@ class test_custom_logging(unittest.TestCase):
     def test_binary_c_log_code(self):
         with Capturing() as output:
             self._test_binary_c_log_code()
-        print("\n".join(output))
+        # print("\n".join(output))
 
     def _test_binary_c_log_code(self):
         """
@@ -74,7 +74,7 @@ class test_custom_logging(unittest.TestCase):
     def test_binary_c_write_log_code(self):
         with Capturing() as output:
             self._test_binary_c_write_log_code()
-        print("\n".join(output))
+        # print("\n".join(output))
 
     def _test_binary_c_write_log_code(self):
         """
@@ -103,7 +103,7 @@ class test_custom_logging(unittest.TestCase):
     def test_from_binary_c_config(self):
         with Capturing() as output:
             self._test_from_binary_c_config()
-        print("\n".join(output))
+        # print("\n".join(output))
 
     def _test_from_binary_c_config(self):
         """
@@ -132,7 +132,7 @@ class test_custom_logging(unittest.TestCase):
     def test_return_compilation_dict(self):
         with Capturing() as output:
             self._test_return_compilation_dict()
-        print("\n".join(output))
+        # print("\n".join(output))
 
     def _test_return_compilation_dict(self):
         """
@@ -153,7 +153,7 @@ class test_custom_logging(unittest.TestCase):
     def test_create_and_load_logging_function(self):
         with Capturing() as output:
             self._test_create_and_load_logging_function()
-        print("\n".join(output))
+        # print("\n".join(output))
 
     def _test_create_and_load_logging_function(self):
         """
diff --git a/binarycpython/tests/test_distributions.py b/binarycpython/tests/test_distributions.py
index 1b5c1d836..2e3e7c26c 100644
--- a/binarycpython/tests/test_distributions.py
+++ b/binarycpython/tests/test_distributions.py
@@ -320,22 +320,6 @@ class TestDistributions(unittest.TestCase):
                 np.abs(python_results[i] - perl_results[i]), self.tolerance, msg=msg
             )
 
-        # # for m=0.5
-        # m = 0.5
-        # self.assertLess(
-        #     np.abs(imf_chabrier2003(m) - 0.581457346702825),
-        #     self.tolerance,
-        #     msg="Difference is bigger than the tolerance. Input mass = {}".format(m),
-        # )
-
-        # # For m = 2
-        # m = 2
-        # self.assertLess(
-        #     np.abs(imf_chabrier2003(m) - 0.581457346702825),
-        #     self.tolerance,
-        #     msg="Difference is bigger than the tolerance. Input mass = {}".format(m),
-        # )
-
     def test_duquennoy1991(self):
         with Capturing() as output:
             self._test_duquennoy1991()
diff --git a/binarycpython/utils/custom_logging_functions.py b/binarycpython/utils/custom_logging_functions.py
index c50562b91..0415f018c 100644
--- a/binarycpython/utils/custom_logging_functions.py
+++ b/binarycpython/utils/custom_logging_functions.py
@@ -138,6 +138,7 @@ def binary_c_log_code(code: str, verbose: int = 0) -> str:
 #undef MIN
 #include \"binary_c.h\"
 #include \"RLOF/RLOF_prototypes.h\"
+#include \"nucsyn/nucsyn_prototypes.h\"
 
 // add visibility __attribute__ ((visibility ("default"))) to it 
 void binary_c_API_function custom_output_function(struct stardata_t * stardata);
@@ -204,6 +205,7 @@ def from_binary_c_config(config_file: str, flag: str) -> str:
 
     # convert and chop off newline
     res = res.decode("utf-8").rstrip()
+    print(res)
 
     return res
 
diff --git a/binarycpython/utils/functions.py b/binarycpython/utils/functions.py
index 61941dbbe..7fb0131e6 100644
--- a/binarycpython/utils/functions.py
+++ b/binarycpython/utils/functions.py
@@ -322,6 +322,39 @@ def parse_binary_c_version_info(version_info_string: str) -> dict:
     splitted = version_info_string.strip().splitlines()
     cleaned = set([el.strip() for el in splitted if not el == ""])
 
+    ##########################
+    # Network:
+    # Split off all the networks and parse the info. 
+    
+    networks = set([el for el in cleaned if el.startswith("Network ")])
+    cleaned = cleaned - networks
+
+    networks_dict = {}
+    for el in networks:
+        network_dict = {}
+        split_info = el.split("Network ")[-1].strip().split("==")
+
+        network_number = int(split_info[0])
+        network_dict['network_number'] = network_number
+
+        network_info_split = split_info[1].split(" is ")
+
+        shortname = network_info_split[0].strip()
+        network_dict['shortname'] = shortname
+
+        if not network_info_split[1].strip().startswith(":"):
+            network_split_info_extra = network_info_split[1].strip().split(":")
+
+            longname = network_split_info_extra[0].strip()
+            network_dict['longname'] = longname
+
+            implementation = network_split_info_extra[1].strip().replace("implemented in", "")
+            if implementation:
+                network_dict['implemented_in'] = implementation.strip().split()
+
+        networks_dict[network_number] = copy.deepcopy(network_dict)
+    version_info_dict["networks"] = networks_dict if networks_dict else None
+
     ##########################
     # Isotopes:
     # Split off
@@ -401,6 +434,7 @@ def parse_binary_c_version_info(version_info_string: str) -> dict:
         "MACRO": str,
         "INT": int,
         "LONG_INT": int,
+        "UINT": int
     }
 
     macros_dict = {}
@@ -413,6 +447,7 @@ def parse_binary_c_version_info(version_info_string: str) -> dict:
         param_value = " is ".join(new_split[1:])
         # Sometimes the macros have extra information behind it. Needs an update in outputting by binary_c
         try:
+            print(param_name, param_type, param_value)
             macros_dict[param_name] = param_type_dict[param_type](param_value)
         except ValueError:
             macros_dict[param_name] = str(param_value)
-- 
GitLab