Commit 54415f93 authored by David Hendriks's avatar David Hendriks
Browse files

Tried to fully package the core api but that seems like a very difficult...

Tried to fully package the core api but that seems like a very difficult endeavour, as passing the shared library via package_data is not enough. it complains about missing symbols, meaning that the other shared/linked stuff is not working anymore. it only works good if things are now loaded by adding this package to the PYTHONPATH atm. will do it later with pip, but thats gonna be some more work
parent a2c429ce
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -45,7 +45,7 @@ SO_FLAGS := -shared
PY_EXEC 			:= python3
PY_SETUP 			:= setup.py
#PY_OPTIONS 			:= build_ext --build-lib $(TARGET_LIB_DIR)
PY_OPTIONS 			:= build_ext --inplace --
PY_OPTIONS 			:= build_ext --inplace
# maybe pass argument from here to the setup.py?

all:
+0 −0

Empty file added.

+7 −7
Original line number Diff line number Diff line
from collections import defaultdict

import binary_c
from binaryc_python_utils.custom_logging_functions import (
import binary_c_python_api
from binarycpython.utils.custom_logging_functions import (
    create_and_load_logging_function,
)

@@ -22,7 +22,7 @@ def get_defaults():
    Function that calls the binaryc get args function and cast it into a dictionary
    All the values are strings
    """
    default_output = binary_c.return_arglines()
    default_output = binary_c_python_api.return_arglines()
    default_dict = {}

    for default in default_output.split("\n"):
@@ -71,7 +71,7 @@ def run_system(**kwargs):
        arg_string = "binary_c {}".format(arg_string)

        # Run it and get output
        output = binary_c.run_binary_custom_logging(arg_string, func_memaddr)
        output = binary_c_python_api.run_binary_custom_logging(arg_string, func_memaddr)
        return output

    elif "log_filename" in kwargs:
@@ -84,7 +84,7 @@ def run_system(**kwargs):
        arg_string = "binary_c {}".format(arg_string)

        # Run it and get output
        output = binary_c.run_binary_with_logfile(arg_string)
        output = binary_c_python_api.run_binary_with_logfile(arg_string)
        return output

    else:  # run the plain basic type
@@ -98,7 +98,7 @@ def run_system(**kwargs):
        arg_string = "binary_c {}".format(arg_string)

        # Run it and get output
        output = binary_c.run_binary(arg_string)
        output = binary_c_python_api.run_binary(arg_string)

        return output

@@ -129,7 +129,7 @@ def run_system_with_log(**kwargs):

    # Run it and get output
    buffer = ""
    output = binary_c.run_binary_with_log(arg_string)
    output = binary_c_python_api.run_binary_with_log(arg_string)

    return output

+8 −24
Original line number Diff line number Diff line
@@ -2,10 +2,10 @@
import os
import sys

import binary_c
import binary_c_python_api

from binaryc_python_utils.functions import run_system, parse_output
from binaryc_python_utils.custom_logging_functions import (
from binarycpython.utils.functions import run_system, parse_output
from binarycpython.utils.custom_logging_functions import (
    autogen_C_logging_code,
    binary_c_log_code,
)
@@ -42,10 +42,10 @@ def run_example_binary():
        metallicity=metallicity,
        max_evolution_time=max_evolution_time,
    )
    output = binary_c.run_binary(argstring)
    output = binary_c_python_api.run_binary(argstring)
    print(output)

# run_example_binary()
run_example_binary()


def run_example_binary_with_run_system():
@@ -143,7 +143,7 @@ def run_example_binary_with_custom_logging():
    # Do whatever you like with the dataframe.
    print(df)

# run_example_binary_with_custom_logging()
run_example_binary_with_custom_logging()

def run_example_binary_with_writing_logfile():
    """
@@ -161,23 +161,7 @@ def run_example_binary_with_writing_logfile():
        separation=0,
        orbital_period=100000000000,
        log_filename=tempfile.gettempdir() + "/test_log.txt",
    )

    # Catch results that start with a given header. (Mind that binary_c has to be configured to print them if your not using a custom logging function)
    result_example_header = parse_output(output, "example_header")

    #### Now do whatever you want with it:
    # Put it in numpy arrays
    # t_res = np.asarray(result_example_header['t'], dtype=np.float64, order='C')
    # m_res = np.asarray(result_example_header['mass'], dtype=np.float64, order='C')

    # Cast the data into a dataframe.
    df = pd.DataFrame.from_dict(result_example_header, dtype=np.float64)

    # print(df)
    # sliced_df = df[df.t < 1000] # Cut off late parts of evolution
    # print(sliced_df[["t","m1"]])

    # Some routine to plot.
    )

# run_example_binary_with_writing_logfile()
 No newline at end of file
run_example_binary_with_writing_logfile()
 No newline at end of file

lib/__init__.py

0 → 100644
+0 −0

Empty file added.

Loading