From f5d57687a692c0efa7ed8e6a47315ba4bd616d17 Mon Sep 17 00:00:00 2001 From: David Hendriks <davidhendriks93@gmail.com> Date: Sun, 1 Aug 2021 23:19:15 +0100 Subject: [PATCH] fixing somee test things --- binarycpython/tests/test_c_bindings.py | 4 +-- binarycpython/tests/test_grid.py | 44 ++++++++++++++------------ 2 files changed, 26 insertions(+), 22 deletions(-) diff --git a/binarycpython/tests/test_c_bindings.py b/binarycpython/tests/test_c_bindings.py index 3e9029ad3..662a50e46 100644 --- a/binarycpython/tests/test_c_bindings.py +++ b/binarycpython/tests/test_c_bindings.py @@ -48,7 +48,7 @@ def return_argstring( # Make the argstrings argstring_template = "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} ensemble 1 ensemble_defer {7} \ -ensemble_filters_off {8} ensemble_filter_{9} 1 probability 0.1" +ensemble_filters_off {8} ensemble_filter_{9} 1 probability 0.1 ensemble_dt 1000" argstring = argstring_template.format( m1, @@ -176,7 +176,7 @@ class TestEnsemble(unittest.TestCase): output = _binary_c_bindings.return_persistent_data_memaddr() - self.assertTrue(is_capsule(output), msg="Object must be an integer") + self.assertTrue(is_capsule(output), msg="Object must be a capsule") # self.assertNotEqual( # output, 0, "memory adress seems not to have a correct value" # ) diff --git a/binarycpython/tests/test_grid.py b/binarycpython/tests/test_grid.py index d64a9f0ce..e36319fc7 100644 --- a/binarycpython/tests/test_grid.py +++ b/binarycpython/tests/test_grid.py @@ -10,8 +10,6 @@ import os import sys import json import unittest -import tempfile -import datetime import numpy as np from binarycpython.utils.grid import Population @@ -26,6 +24,7 @@ from binarycpython.utils.custom_logging_functions import binary_c_log_code binary_c_temp_dir = temp_dir() +TEST_VERBOSITY = 1 def parse_function_test_grid_evolve_2_threads_with_custom_logging(self, output): """ @@ -103,10 +102,10 @@ class test_Population(unittest.TestCase): """ test_pop = Population() - test_pop.set(amt_cores=2) + test_pop.set(amt_cores=2, verbosity=TEST_VERBOSITY) test_pop.set(M_1=10) test_pop.set(data_dir="/tmp/binary_c_python") - test_pop.set(ensemble_filter_SUPERNOVAE=1) + test_pop.set(ensemble_filter_SUPERNOVAE=1, ensemble_dt=1000) self.assertIn("data_dir", test_pop.custom_options) self.assertEqual(test_pop.custom_options["data_dir"], "/tmp/binary_c_python") @@ -139,7 +138,7 @@ class test_Population(unittest.TestCase): # Set up population test_pop = Population() - test_pop.set(data_dir="/tmp") + test_pop.set(data_dir="/tmp", verbosity=TEST_VERBOSITY) # parse arguments test_pop.parse_cmdline() @@ -170,7 +169,7 @@ class test_Population(unittest.TestCase): # Set up population test_pop = Population() - test_pop.set(metallicity=0.02) + test_pop.set(metallicity=0.02, verbosity=TEST_VERBOSITY) test_pop.set(M_1=10) argline = test_pop._return_argline() @@ -241,7 +240,7 @@ class test_Population(unittest.TestCase): """ test_pop = Population() - test_pop.set(metallicity=0.02) + test_pop.set(metallicity=0.02, verbosity=TEST_VERBOSITY) test_pop.set(M_1=10) test_pop.set(amt_cores=2) test_pop.set(data_dir="/tmp") @@ -340,7 +339,7 @@ class test_Population(unittest.TestCase): test_pop = Population() - test_pop.set(metallicity=0.02) + test_pop.set(metallicity=0.02, verbosity=TEST_VERBOSITY) test_pop.set(M_1=10) test_pop.set(amt_cores=2) test_pop.set(data_dir=binary_c_temp_dir) @@ -486,7 +485,7 @@ class test_Population(unittest.TestCase): M_2=5, orbital_period=100000, metallicty=0.02, - max_evolution_time=15000, + max_evolution_time=15000, verbosity=TEST_VERBOSITY ) test_pop.set(C_logging_code=CUSTOM_LOGGING_STRING_MASSES) @@ -505,7 +504,7 @@ class test_Population(unittest.TestCase): M_2=5, orbital_period=100000, metallicty=0.02, - max_evolution_time=15000, + max_evolution_time=15000, verbosity=TEST_VERBOSITY ) test_pop_2.set(C_auto_logging=custom_logging_dict) @@ -533,7 +532,7 @@ class test_grid_evolve(unittest.TestCase): test_pop_evolve_1_thread = Population() test_pop_evolve_1_thread.set( - amt_cores=1, verbosity=0, M_2=1, orbital_period=100000 + amt_cores=1, M_2=1, orbital_period=100000, verbosity=TEST_VERBOSITY ) resolution = {"M_1": 10} @@ -569,7 +568,7 @@ class test_grid_evolve(unittest.TestCase): """ test_pop = Population() - test_pop.set(amt_cores=2, verbosity=1, M_2=1, orbital_period=100000) + test_pop.set(amt_cores=2, M_2=1, orbital_period=100000, verbosity=TEST_VERBOSITY) resolution = {"M_1": 10} @@ -611,12 +610,13 @@ class test_grid_evolve(unittest.TestCase): test_pop.set( amt_cores=amt_cores_value, - verbosity=1, + verbosity=TEST_VERBOSITY, M_2=1, orbital_period=100000, data_dir=data_dir_value, C_logging_code=custom_logging_string, # input it like this. parse_function=parse_function_test_grid_evolve_2_threads_with_custom_logging, + ) test_pop.set(ensemble=0) resolution = {"M_1": 2} @@ -667,7 +667,7 @@ class test_grid_evolve(unittest.TestCase): """ test_pop = Population() - test_pop.set(amt_cores=2, verbosity=1, M_2=1, orbital_period=100000) + test_pop.set(amt_cores=2, M_2=1, orbital_period=100000, verbosity=TEST_VERBOSITY) # Set the amt of failed systems that each thread will log test_pop.set(failed_systems_threshold=4) @@ -719,7 +719,7 @@ Printf("TEST_CUSTOM_LOGGING_1 %30.12e %g %g %g %g\\n", # test to see if 1 thread does all the systems test_pop = Population() - test_pop.set(amt_cores=2, verbosity=1, M_2=1, orbital_period=100000) + test_pop.set(amt_cores=2, M_2=1, orbital_period=100000, verbosity=TEST_VERBOSITY) test_pop.set(failed_systems_threshold=4) test_pop.set(C_logging_code=CUSTOM_LOGGING_STRING_WITH_EXIT) @@ -771,7 +771,7 @@ Printf("TEST_CUSTOM_LOGGING_1 %30.12e %g %g %g %g\\n", """ test_pop = Population() - test_pop.set(amt_cores=1, verbosity=1, M_2=1, orbital_period=100000) + test_pop.set(amt_cores=1, M_2=1, orbital_period=100000, verbosity=TEST_VERBOSITY) resolution = {"M_1": 10} self.assertRaises(ValueError, test_pop.evolve) @@ -791,13 +791,14 @@ Printf("TEST_CUSTOM_LOGGING_1 %30.12e %g %g %g %g\\n", test_pop = Population() test_pop.set( amt_cores=amt_cores_value, - verbosity=1, + verbosity=TEST_VERBOSITY, M_2=1, orbital_period=100000, ensemble=1, ensemble_defer=1, ensemble_filters_off=1, ensemble_filter_STELLAR_TYPE_COUNTS=1, + ensemble_dt=1000, ) test_pop.set( data_dir=binary_c_temp_dir, @@ -864,13 +865,14 @@ Printf("TEST_CUSTOM_LOGGING_1 %30.12e %g %g %g %g\\n", test_pop = Population() test_pop.set( amt_cores=amt_cores_value, - verbosity=1, + verbosity=TEST_VERBOSITY, M_2=1, orbital_period=100000, ensemble=1, ensemble_defer=1, ensemble_filters_off=1, ensemble_filter_STELLAR_TYPE_COUNTS=1, + ensemble_dt=1000, ) test_pop.set( data_dir=binary_c_temp_dir, @@ -921,13 +923,14 @@ Printf("TEST_CUSTOM_LOGGING_1 %30.12e %g %g %g %g\\n", test_pop_1 = Population() test_pop_1.set( amt_cores=amt_cores_value, - verbosity=1, + verbosity=TEST_VERBOSITY, M_2=1, orbital_period=100000, ensemble=1, ensemble_defer=1, ensemble_filters_off=1, ensemble_filter_STELLAR_TYPE_COUNTS=1, + ensemble_dt=1000, ) test_pop_1.set( data_dir=binary_c_temp_dir, @@ -959,13 +962,14 @@ Printf("TEST_CUSTOM_LOGGING_1 %30.12e %g %g %g %g\\n", test_pop_2 = Population() test_pop_2.set( amt_cores=amt_cores_value, - verbosity=1, + verbosity=TEST_VERBOSITY, M_2=1, orbital_period=100000, ensemble=1, ensemble_defer=1, ensemble_filters_off=1, ensemble_filter_STELLAR_TYPE_COUNTS=1, + ensemble_dt=1000, ) test_pop_2.set( data_dir=binary_c_temp_dir, -- GitLab