Loading binarycpython/tests/c_bindings/test_ensemble.py +34 −14 Original line number Diff line number Diff line Loading @@ -59,6 +59,38 @@ ensemble_filters_off {8} ensemble_filter_{9} 1 probability 0.1" return argstring def test_minimal_ensemble_output(): """ Tase case to check if the ensemble output is correctly written to the buffer instead of printed """ m1 = 2 # Msun m2 = 0.1 # Msun ############################################################################################# # The 2 runs below use the ensemble but do not defer the output to anything else, so that the # results are returned directly after the run # Direct output commands argstring_1 = return_argstring( m1=m1, m2=m2, ensemble_filter="STELLAR_TYPE_COUNTS", defer_ensemble=0 ) # Get outputs output_1 = _binary_c_bindings.run_system(argstring=argstring_1) test_ensemble_jsons_string = [ line for line in output_1.splitlines() if line.startswith("ENSEMBLE_JSON") ] test_json = handle_ensemble_string_to_json( test_ensemble_jsons_string[0][len("ENSEMBLE_JSON ") :] ) print(test_json.keys()) print(test_json) assert test_json, "Ensemble output not correctly written passed to the buffer in _binary_c_bindings" assert "number_counts" in test_json.keys(), "Output doesn't contain the correct information" def test_return_persistent_data_memaddr(): """ Loading Loading @@ -126,20 +158,6 @@ def test_passing_persistent_data_to_run_system(): ), "The output of the deferred two systems should not be the same as the first undeferred output" import pickle def pickle_n_checksize(obj): name = os.path.join(TMP_DIR, "test", "pickle") with open(name, "wb") as file: pickle.dump(obj, file) file_stats = os.stat(name) print("size: {}mb".format(file_stats.st_size / (1024 * 1024))) os.remove(name) def test_adding_ensemble_output(): """ Function that adds the output of 2 ensembles and compares it to the output that we get by deferring the first output Loading Loading @@ -367,6 +385,7 @@ def test_full_ensemble_output(): assert "scalars" in json_1.keys() def all(): test_minimal_ensemble_output() test_return_persistent_data_memaddr() test_passing_persistent_data_to_run_system() test_full_ensemble_output() Loading @@ -377,6 +396,7 @@ def all(): #### if __name__ == "__main__": # test_minimal_ensemble_output() # test_return_persistent_data_memaddr() # test_passing_persistent_data_to_run_system() # test_full_ensemble_output() Loading binarycpython/tests/python_API_test.py +0 −2 Original line number Diff line number Diff line Loading @@ -36,14 +36,12 @@ def test_run_system(): 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")) def test_run_system_with_log(): m1 = 15.0 # Msun m2 = 14.0 # Msun Loading setup.py +8 −7 Original line number Diff line number Diff line Loading @@ -235,18 +235,19 @@ class CustomBuildCommand(distutils.command.build.build): distutils.command.build.build.run(self) # It is tested and designed to work for versions {}, we can't guarantee proper functioning for other versions # If you want to use a different version of binary_c, download and install a different version of this package setup( name="binarycpython", version="0.2.1", description=""" This is a python API for binary_c (versions {}) by David Hendriks, Rob Izzard and collaborators. Based on the initial set up by Jeff andrews. It is tested and designed to work for versions {}, we can't guarantee proper functioning for other versions If you want to use a different version of binary_c, download and install a different version of this package This is a python API for binary_c (versions {}) by David Hendriks, Rob Izzard and collaborators. Based on the initial set up by Jeff andrews. """.format( ",".join(str(REQUIRED_BINARY_C_VERSIONS)), ",".join(str(REQUIRED_BINARY_C_VERSIONS)), ",".join(REQUIRED_BINARY_C_VERSIONS), ",".join(REQUIRED_BINARY_C_VERSIONS), ), author="David Hendriks", author_email="davidhendriks93@gmail.com", Loading Loading
binarycpython/tests/c_bindings/test_ensemble.py +34 −14 Original line number Diff line number Diff line Loading @@ -59,6 +59,38 @@ ensemble_filters_off {8} ensemble_filter_{9} 1 probability 0.1" return argstring def test_minimal_ensemble_output(): """ Tase case to check if the ensemble output is correctly written to the buffer instead of printed """ m1 = 2 # Msun m2 = 0.1 # Msun ############################################################################################# # The 2 runs below use the ensemble but do not defer the output to anything else, so that the # results are returned directly after the run # Direct output commands argstring_1 = return_argstring( m1=m1, m2=m2, ensemble_filter="STELLAR_TYPE_COUNTS", defer_ensemble=0 ) # Get outputs output_1 = _binary_c_bindings.run_system(argstring=argstring_1) test_ensemble_jsons_string = [ line for line in output_1.splitlines() if line.startswith("ENSEMBLE_JSON") ] test_json = handle_ensemble_string_to_json( test_ensemble_jsons_string[0][len("ENSEMBLE_JSON ") :] ) print(test_json.keys()) print(test_json) assert test_json, "Ensemble output not correctly written passed to the buffer in _binary_c_bindings" assert "number_counts" in test_json.keys(), "Output doesn't contain the correct information" def test_return_persistent_data_memaddr(): """ Loading Loading @@ -126,20 +158,6 @@ def test_passing_persistent_data_to_run_system(): ), "The output of the deferred two systems should not be the same as the first undeferred output" import pickle def pickle_n_checksize(obj): name = os.path.join(TMP_DIR, "test", "pickle") with open(name, "wb") as file: pickle.dump(obj, file) file_stats = os.stat(name) print("size: {}mb".format(file_stats.st_size / (1024 * 1024))) os.remove(name) def test_adding_ensemble_output(): """ Function that adds the output of 2 ensembles and compares it to the output that we get by deferring the first output Loading Loading @@ -367,6 +385,7 @@ def test_full_ensemble_output(): assert "scalars" in json_1.keys() def all(): test_minimal_ensemble_output() test_return_persistent_data_memaddr() test_passing_persistent_data_to_run_system() test_full_ensemble_output() Loading @@ -377,6 +396,7 @@ def all(): #### if __name__ == "__main__": # test_minimal_ensemble_output() # test_return_persistent_data_memaddr() # test_passing_persistent_data_to_run_system() # test_full_ensemble_output() Loading
binarycpython/tests/python_API_test.py +0 −2 Original line number Diff line number Diff line Loading @@ -36,14 +36,12 @@ def test_run_system(): 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")) def test_run_system_with_log(): m1 = 15.0 # Msun m2 = 14.0 # Msun Loading
setup.py +8 −7 Original line number Diff line number Diff line Loading @@ -235,18 +235,19 @@ class CustomBuildCommand(distutils.command.build.build): distutils.command.build.build.run(self) # It is tested and designed to work for versions {}, we can't guarantee proper functioning for other versions # If you want to use a different version of binary_c, download and install a different version of this package setup( name="binarycpython", version="0.2.1", description=""" This is a python API for binary_c (versions {}) by David Hendriks, Rob Izzard and collaborators. Based on the initial set up by Jeff andrews. It is tested and designed to work for versions {}, we can't guarantee proper functioning for other versions If you want to use a different version of binary_c, download and install a different version of this package This is a python API for binary_c (versions {}) by David Hendriks, Rob Izzard and collaborators. Based on the initial set up by Jeff andrews. """.format( ",".join(str(REQUIRED_BINARY_C_VERSIONS)), ",".join(str(REQUIRED_BINARY_C_VERSIONS)), ",".join(REQUIRED_BINARY_C_VERSIONS), ",".join(REQUIRED_BINARY_C_VERSIONS), ), author="David Hendriks", author_email="davidhendriks93@gmail.com", Loading