From 90d656ecb430ffcb223b7e5d23d713d6563be2cd Mon Sep 17 00:00:00 2001 From: David Hendriks <davidhendriks93@gmail.com> Date: Mon, 7 Dec 2020 23:49:34 +0000 Subject: [PATCH] moved the tests to single file --- binarycpython/tests/c_bindings/__init__.py | 0 .../c_bindings/test_custom_logging_code.py | 0 .../c_bindings/test_return_store_memaddr.py | 27 ------- .../tests/c_bindings/test_run_system.py | 36 ---------- binarycpython/tests/grid/__init__.py | 0 binarycpython/tests/grid/test_grid.py | 1 - .../test_ensemble.py => test_c_bindings.py} | 70 +++++++++++++++++-- setup.py | 1 - 8 files changed, 65 insertions(+), 70 deletions(-) delete mode 100644 binarycpython/tests/c_bindings/__init__.py delete mode 100644 binarycpython/tests/c_bindings/test_custom_logging_code.py delete mode 100644 binarycpython/tests/c_bindings/test_return_store_memaddr.py delete mode 100644 binarycpython/tests/c_bindings/test_run_system.py delete mode 100644 binarycpython/tests/grid/__init__.py delete mode 100644 binarycpython/tests/grid/test_grid.py rename binarycpython/tests/{c_bindings/test_ensemble.py => test_c_bindings.py} (84%) diff --git a/binarycpython/tests/c_bindings/__init__.py b/binarycpython/tests/c_bindings/__init__.py deleted file mode 100644 index e69de29bb..000000000 diff --git a/binarycpython/tests/c_bindings/test_custom_logging_code.py b/binarycpython/tests/c_bindings/test_custom_logging_code.py deleted file mode 100644 index e69de29bb..000000000 diff --git a/binarycpython/tests/c_bindings/test_return_store_memaddr.py b/binarycpython/tests/c_bindings/test_return_store_memaddr.py deleted file mode 100644 index 3da497b45..000000000 --- a/binarycpython/tests/c_bindings/test_return_store_memaddr.py +++ /dev/null @@ -1,27 +0,0 @@ -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() diff --git a/binarycpython/tests/c_bindings/test_run_system.py b/binarycpython/tests/c_bindings/test_run_system.py deleted file mode 100644 index c12e37cf1..000000000 --- a/binarycpython/tests/c_bindings/test_run_system.py +++ /dev/null @@ -1,36 +0,0 @@ -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() diff --git a/binarycpython/tests/grid/__init__.py b/binarycpython/tests/grid/__init__.py deleted file mode 100644 index e69de29bb..000000000 diff --git a/binarycpython/tests/grid/test_grid.py b/binarycpython/tests/grid/test_grid.py deleted file mode 100644 index 9ed72bb49..000000000 --- a/binarycpython/tests/grid/test_grid.py +++ /dev/null @@ -1 +0,0 @@ -# empty for now diff --git a/binarycpython/tests/c_bindings/test_ensemble.py b/binarycpython/tests/test_c_bindings.py similarity index 84% rename from binarycpython/tests/c_bindings/test_ensemble.py rename to binarycpython/tests/test_c_bindings.py index 3fe9ab111..5021bcf5c 100644 --- a/binarycpython/tests/c_bindings/test_ensemble.py +++ b/binarycpython/tests/test_c_bindings.py @@ -1,7 +1,3 @@ -""" -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 diff --git a/setup.py b/setup.py index 4564e923f..92c4c25e3 100644 --- a/setup.py +++ b/setup.py @@ -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, -- GitLab