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

moved the tests to single file

parent 52a1071a
No related branches found
No related tags found
No related merge requests found
import textwrap
from binarycpython import _binary_c_bindings
def test_return_store_memaddr():
output = _binary_c_bindings.return_store_memaddr()
print("function: test_return_store")
print("store memory adress:")
print(textwrap.indent(str(output), "\t"))
def test_unload_store_memaddr():
output = _binary_c_bindings.return_store_memaddr()
print("function: test_return_store")
print("store memory adress:")
print(textwrap.indent(str(output), "\t"))
print(type(output))
_ = _binary_c_bindings.free_store_memaddr(output)
print("freed store memaddr")
####
if __name__ == "__main__":
test_return_store_memaddr()
test_unload_store_memaddr()
from binarycpython import _binary_c_bindings
import textwrap
# Evolution functions
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
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,
)
output = _binary_c_bindings.run_system(argstring=argstring)
# print("function: test_run_system")
# print("Binary_c output:")
# print(textwrap.indent(output, "\t"))
assert "SINGLE_STAR_LIFETIME" in output, "Run system not working properly"
####
if __name__ == "__main__":
test_run_system()
# empty for now
"""
Module containing tests regarding the persistent_data memory and the ensemble output
"""
import os
import sys
import time
......@@ -18,6 +14,67 @@ from binarycpython.utils.functions import (
handle_ensemble_string_to_json,
)
#######################################################################################################################################################
### General run_system test
#######################################################################################################################################################
# Evolution functions
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
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,
)
output = _binary_c_bindings.run_system(argstring=argstring)
# print("function: test_run_system")
# print("Binary_c output:")
# print(textwrap.indent(output, "\t"))
assert "SINGLE_STAR_LIFETIME" in output, "Run system not working properly"
#######################################################################################################################################################
### memaddr test
#######################################################################################################################################################
def test_return_store_memaddr():
output = _binary_c_bindings.return_store_memaddr()
print("function: test_return_store")
print("store memory adress:")
print(textwrap.indent(str(output), "\t"))
def test_unload_store_memaddr():
output = _binary_c_bindings.return_store_memaddr()
print("function: test_return_store")
print("store memory adress:")
print(textwrap.indent(str(output), "\t"))
print(type(output))
_ = _binary_c_bindings.free_store_memaddr(output)
print("freed store memaddr")
#######################################################################################################################################################
### ensemble tests
#######################################################################################################################################################
"""
Module containing tests regarding the persistent_data memory and the ensemble output
"""
TMP_DIR = temp_dir()
os.makedirs(os.path.join(TMP_DIR, "test"), exist_ok=True)
......@@ -385,6 +442,9 @@ def test_full_ensemble_output():
assert "scalars" in json_1.keys()
def all():
test_run_system()
test_return_store_memaddr()
test_unload_store_memaddr()
test_minimal_ensemble_output()
test_return_persistent_data_memaddr()
test_passing_persistent_data_to_run_system()
......@@ -404,4 +464,4 @@ if __name__ == "__main__":
# test_free_and_json_output()
# test_combine_with_empty_json()
all()
print("Done")
print("Done")
\ No newline at end of file
......@@ -266,7 +266,6 @@ This is a python API for binary_c (versions {}) by David Hendriks, Rob Izzard an
"binarycpython.utils",
"binarycpython.core",
"binarycpython.tests",
"binarycpython.tests.c_bindings",
],
install_requires=["numpy", "pytest", "h5py", "pathos", "pandas"],
include_package_data=True,
......
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