Commit 9b5185fe authored by David Hendriks's avatar David Hendriks
Browse files

added extra test files. there are new api functions im starting to put all of...

added extra test files. there are new api functions im starting to put all of them into a test function now. later this will become a real unit test function
parent ee872b09
Loading
Loading
Loading
Loading
+31 −7
Original line number Diff line number Diff line
@@ -47,11 +47,38 @@ test_pop.set(

## Custom logging:
# test_pop.set(C_auto_logging={'MY_HEADER_LINE': ['star[0].mass', 'star[1].mass', 'model.probability']})
# test_pop.set(C_logging_code='Printf("MY_STELLAR_DATA time=%g mass=%g\\n", stardata->model.time, stardata->star[0].mass);')
# test_pop.set(C_logging_code='Printf("MY_HEADER_LINE %g %g %g\\n",((double)stardata->star[0].mass),((double)stardata->star[1].mass),((double)stardata->model.probability));')

# test_pop.set(C_logging_code='Printf("MY_STELLAR_DATA time=%g mass=%g radius=%g\\n", stardata->model.time, stardata->star[0].mass, stardata->star[0].radius);')
# test_pop.evolve_population()


## Custom logging with bigger print statement:
test_pop.set(M_1=100, M_2=1, metallicity=0.0002, orbital_period=500000000)
test_pop.set(C_logging_code="""
    if(stardata->star[0].stellar_type>=MS)
    {
        if (stardata->model.time < stardata->model.max_evolution_time)
        {
            Printf("DAVID_SCO %30.12e %g %g %g %g %d %d\\n",
                // 
                stardata->model.time, // 1

                stardata->star[0].mass, //2
                stardata->previous_stardata->star[0].mass, //3

                stardata->star[0].radius, //4
                stardata->previous_stardata->star[0].radius, //5

                stardata->star[0].stellar_type, //6
                stardata->previous_stardata->star[0].stellar_type //7
          );
        };
        /* Kill the simulation to save time */
        //stardata->model.max_evolution_time = stardata->model.time - stardata->model.dtm;
    };
""")
test_pop.evolve_population()


## Help all
# print(get_help_all(return_dict=True))

@@ -62,6 +89,3 @@ test_pop.set(
# return all info:
# print(json.dumps(test_pop.return_all_info(), indent=4))
test_pop.export_all_info(outfile=os.path.join(os.getcwd(), "test_output.txt"))
 No newline at end of file


test_pop.evolve_population()
+2248 −0

File added.

Preview size limit exceeded, changes collapsed.

+32 −9
Original line number Diff line number Diff line
@@ -14,7 +14,6 @@ import tempfile
# Test script for the api functions
############################################################


def test_run_binary():
    m1 = 15.0  # Msun
    m2 = 14.0  # Msun
@@ -132,20 +131,44 @@ def test_return_store():
    print(out)


def test_run_system():

    m1 = 15.0  # Msun
    m2 = 14.0  # Msun
    separation = 0  # 0 = ignored, use period
    orbital_period = 4530.0  # days
    eccentricity = 0.0
    metallicity = 0.02
    max_evolution_time = 15000
    log_filename = tempfile.gettempdir() + "/test_log.txt"
    argstring = "binary_c M_1 {0:g} M_2 {1:g} separation {2:g} orbital_period {3:g} eccentricity {4:g} metallicity {5:g} max_evolution_time {6:g}".format(
        m1,
        m2,
        separation,
        orbital_period,
        eccentricity,
        metallicity,
        max_evolution_time,
        log_filename,
    )
    out = binary_c_python_api.run_system(argstring, -1, -1)

####
if __name__ == "__main__":
    test_run_binary()
    # test_run_binary()

    # test_run_binary_with_log()

    test_run_binary_with_log()
    # test_run_binary_with_custom_logging()

    test_run_binary_with_custom_logging()
    # test_return_help()

    test_return_help()
    # test_return_arglines()

    test_return_arglines()
    # test_return_help_all()

    test_return_help_all()
    # test_return_version_info()

    test_return_version_info()
    # test_return_store()

    test_return_store()
    test_run_system()
 No newline at end of file

tests/random_tests.py

0 → 100644
+8 −0
Original line number Diff line number Diff line

import binary_c_python_api
from binarycpython.utils.functions import get_help_super



# get_help_super(print_help=True)
get_help_super(print_help=False)
 No newline at end of file