Skip to content
Snippets Groups Projects
Commit 90cadce7 authored by David Hendriks's avatar David Hendriks
Browse files

fixed a bug in the api bindings, the persitent_data needs to be done properly

parent 4dd3beac
No related branches found
No related tags found
No related merge requests found
...@@ -7,6 +7,8 @@ ...@@ -7,6 +7,8 @@
*/ */
#include "binary_c_API.h" #include "binary_c_API.h"
#include "binary_c.h"
#include "binary_c_API_prototypes.h"
/* Binary_c's python API prototypes */ /* Binary_c's python API prototypes */
int run_system(char * argstring, int run_system(char * argstring,
......
...@@ -21,13 +21,13 @@ def license(): ...@@ -21,13 +21,13 @@ def license():
with open("LICENSE.md") as file: with open("LICENSE.md") as file:
return file.read() return file.read()
def check_version(installed_binary_c_version, required_binary_c_version): def check_version(installed_binary_c_version, required_binary_c_versions):
"""Function to check the installed version and compare it to the required version""" """Function to check the installed version and compare it to the required version"""
message = """ message = """
The binary_c version that is installed ({}) does not match any of the binary_c versions ({}) The binary_c version that is installed ({}) does not match the binary_c versions ({})
that this release of the binary_c python module requires. that this release of the binary_c python module requires.
""".format(installed_binary_c_version, required_binary_c_version) """.format(installed_binary_c_version, required_binary_c_versions)
assert installed_binary_c_version in required_binary_c_version, message assert installed_binary_c_version in required_binary_c_versions, message
### ###
REQUIRED_BINARY_C_VERSIONS = ['2.1.7'] REQUIRED_BINARY_C_VERSIONS = ['2.1.7']
...@@ -110,6 +110,10 @@ for x in DEFINES: ...@@ -110,6 +110,10 @@ for x in DEFINES:
if y: if y:
BINARY_C_DEFINE_MACROS.extend([(y.group(1), None)]) BINARY_C_DEFINE_MACROS.extend([(y.group(1), None)])
# add API header file
API_h = os.path.join(BINARY_C_DIR, "src", "API", "binary_c_API.h")
BINARY_C_DEFINE_MACROS.extend([("BINARY_C_API_H", API_h)])
############################################################ ############################################################
# Setting all directories and LIBRARIES to their final values # Setting all directories and LIBRARIES to their final values
############################################################ ############################################################
...@@ -141,16 +145,17 @@ RUNTIME_LIBRARY_DIRS = [ ...@@ -141,16 +145,17 @@ RUNTIME_LIBRARY_DIRS = [
# os.path.join(CWD, "binarycpython/core/"), # os.path.join(CWD, "binarycpython/core/"),
] + BINARY_C_LIBDIRS ] + BINARY_C_LIBDIRS
print('\n') # print('\n')
print("BINARY_C_CONFIG: ", str(BINARY_C_CONFIG) + "\n") # print("BINARY_C_CONFIG: ", str(BINARY_C_CONFIG) + "\n")
print("incdirs: ", str(INCLUDE_DIRS) + "\n") # print("incdirs: ", str(INCLUDE_DIRS) + "\n")
print("BINARY_C_LIBS: ", str(BINARY_C_LIBS) + "\n") # print("BINARY_C_LIBS: ", str(BINARY_C_LIBS) + "\n")
print("LIBRARIES: ", str(LIBRARIES) + "\n") # print("LIBRARIES: ", str(LIBRARIES) + "\n")
print("LIBRARY_DIRS: ", str(LIBRARY_DIRS) + "\n") # print("LIBRARY_DIRS: ", str(LIBRARY_DIRS) + "\n")
print("RUNTIME_LIBRARY_DIRS: ", str(RUNTIME_LIBRARY_DIRS) + "\n") # print("RUNTIME_LIBRARY_DIRS: ", str(RUNTIME_LIBRARY_DIRS) + "\n")
print("BINARY_C_CFLAGS: ", str(BINARY_C_CFLAGS) + "\n") # print("BINARY_C_CFLAGS: ", str(BINARY_C_CFLAGS) + "\n")
print("macros: ", str(BINARY_C_DEFINE_MACROS) + "\n") # print("API_h: ", str(API_h) + "\n")
print('\n') # print("macros: ", str(BINARY_C_DEFINE_MACROS) + "\n")
# print('\n')
############################################################ ############################################################
# Making the extension function # Making the extension function
......
...@@ -79,7 +79,7 @@ int run_system(char * argstring, ...@@ -79,7 +79,7 @@ int run_system(char * argstring,
NULL, // previous_stardatas NULL, // previous_stardatas
NULL, // preferences NULL, // preferences
&store, // store &store, // store
&persistent_data, // persistent_data TODO: see if this use is correct NULL, // persistent_data TODO: see if this use is correct
&argstring, // argv &argstring, // argv
-1 // argc -1 // argc
); );
......
...@@ -10,6 +10,7 @@ from binarycpython.utils.custom_logging_functions import ( ...@@ -10,6 +10,7 @@ from binarycpython.utils.custom_logging_functions import (
from binarycpython.utils.functions import temp_dir from binarycpython.utils.functions import temp_dir
import tempfile import tempfile
import textwrap
############################################################ ############################################################
# Test script for the api functions # Test script for the api functions
...@@ -18,9 +19,7 @@ import tempfile ...@@ -18,9 +19,7 @@ import tempfile
############################################################ ############################################################
# Evolution functionality # Evolution functions
def test_run_system(): def test_run_system():
m1 = 15.0 # Msun m1 = 15.0 # Msun
m2 = 14.0 # Msun m2 = 14.0 # Msun
...@@ -43,7 +42,7 @@ def test_run_system(): ...@@ -43,7 +42,7 @@ def test_run_system():
print("function: test_run_system") print("function: test_run_system")
print("Binary_c output:") print("Binary_c output:")
print(output) print(textwrap.indent(output, "\t"))
def test_run_system_with_log(): def test_run_system_with_log():
...@@ -74,13 +73,10 @@ def test_run_system_with_log(): ...@@ -74,13 +73,10 @@ def test_run_system_with_log():
print("function: test_run_system_with_log") print("function: test_run_system_with_log")
print("Binary_c output:") print("Binary_c output:")
print(output) print(textwrap.indent(output, "\t"))
def test_run_system_with_custom_logging(): def test_run_system_with_custom_logging():
"""
"""
# generate logging lines. Here you can choose whatever you want to have logged, and with what header # generate logging lines. Here you can choose whatever you want to have logged, and with what header
# this generates working print statements # this generates working print statements
logging_line = autogen_C_logging_code( logging_line = autogen_C_logging_code(
...@@ -116,56 +112,55 @@ def test_run_system_with_custom_logging(): ...@@ -116,56 +112,55 @@ def test_run_system_with_custom_logging():
print("function: test_run_system_with_custom_logging") print("function: test_run_system_with_custom_logging")
print("memory adress of custom logging functions:") print("memory adress of custom logging functions:")
print(func_memaddr) print(textwrap.indent(str(func_memaddr), "\t"))
out = binary_c_python_api.run_system( output = binary_c_python_api.run_system(
argstring, custom_logging_func_memaddr=func_memaddr argstring, custom_logging_func_memaddr=func_memaddr
) )
print("binary_c output:") print("binary_c output:")
print(out) print(textwrap.indent(output, "\t"))
# Testing other utility functions # Testing other utility functions
def test_return_help(): def test_return_help():
out = binary_c_python_api.return_help("M_1") output = binary_c_python_api.return_help("M_1")
print("function: test_return_help") print("function: test_return_help")
print("help output:") print("help output:")
print(out) print(textwrap.indent(output, "\t"))
def test_return_arglines(): def test_return_arglines():
out = binary_c_python_api.return_arglines() output = binary_c_python_api.return_arglines()
print("function: test_return_arglines") print("function: test_return_arglines")
print("arglines output:") print("arglines output:")
print(out) print(textwrap.indent(output, "\t"))
def test_return_help_all(): def test_return_help_all():
out = binary_c_python_api.return_help_all("M_1") output = binary_c_python_api.return_help_all("M_1")
print("function: test_return_help_all") print("function: test_return_help_all")
print("help all output:") print("help all output:")
print(out) print(textwrap.indent(output, "\t"))
def test_return_version_info(): def test_return_version_info():
out = binary_c_python_api.return_version_info() output = binary_c_python_api.return_version_info()
print("function: test_return_version_info") print("function: test_return_version_info")
print("version info output:") print("version info output:")
print(out) print(textwrap.indent(output, "\t"))
# Testing other functions # Testing other functions
def test_return_store(): def test_return_store():
out = binary_c_python_api.return_store("") output = binary_c_python_api.return_store("")
print("function: test_return_store") print("function: test_return_store")
print("store memory adress:") print("store memory adress:")
print(out) print(textwrap.indent(str(output), "\t"))
#### ####
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment