From cbcc519d15592787e61f6061b9d9de97db354e01 Mon Sep 17 00:00:00 2001 From: David Hendriks <davidhendriks93@gmail.com> Date: Fri, 21 Aug 2020 21:58:39 +0100 Subject: [PATCH] trying to figure out why the second defer =false doesnt work --- src/binary_c_python_api.c | 2 ++ tests/test_return_persistent_data_memaddr.py | 24 +++++++++++++++----- 2 files changed, 20 insertions(+), 6 deletions(-) diff --git a/src/binary_c_python_api.c b/src/binary_c_python_api.c index 50b9f2fde..87b827f19 100644 --- a/src/binary_c_python_api.c +++ b/src/binary_c_python_api.c @@ -121,6 +121,8 @@ int run_system(char * argstring, stardata->preferences->custom_output_function = (void*)(struct stardata_t *)custom_logging_func_memaddr; } + printf("ensemble_defer: %d\n", stardata->preferences->ensemble_defer); + /* do binary evolution */ binary_c_evolve_for_dt(stardata, stardata->model.max_evolution_time); diff --git a/tests/test_return_persistent_data_memaddr.py b/tests/test_return_persistent_data_memaddr.py index ddd2adfaa..88124da6f 100644 --- a/tests/test_return_persistent_data_memaddr.py +++ b/tests/test_return_persistent_data_memaddr.py @@ -175,7 +175,7 @@ def adding_ensemble_output(): ############################################################################################# # The 2 runs below use the ensemble and both defer the output so that after they are finished - # nothing is printed. After that we explicitly free the memory of the persistent_data and + # nothing is printed. After that we explicitly free the memory of the persistent_data and # have the output returned in that way # Deferred commands @@ -188,8 +188,14 @@ def adding_ensemble_output(): persistent_data_memaddr = binary_c_python_api.return_persistent_data_memaddr() # Run the systems and defer the output each time - output_1_deferred = binary_c_python_api.run_system(argstring=argstring_1_deferred, persistent_data_memaddr=persistent_data_memaddr) - output_2_deferred = binary_c_python_api.run_system(argstring=argstring_2_deferred, persistent_data_memaddr=persistent_data_memaddr) + output_1_deferred = binary_c_python_api.run_system( + argstring=argstring_1_deferred, + persistent_data_memaddr=persistent_data_memaddr + ) + output_2_deferred = binary_c_python_api.run_system( + argstring=argstring_2_deferred, + persistent_data_memaddr=persistent_data_memaddr + ) # Have the persistent_memory adress be released and have the json outputted output_total_deferred = binary_c_python_api.free_persistent_data_memaddr_and_return_json_output(persistent_data_memaddr) @@ -205,14 +211,20 @@ def adding_ensemble_output(): ############################################################################################# # The 2 runs below use the ensemble and the first one defers the output to the memory, - # Then the second one uses that memory to combine its results with, but doesn't defer the + # Then the second one uses that memory to combine its results with, but doesn't defer the # data after that, so it will print it after the second run is done persistent_data_memaddr_2 = binary_c_python_api.return_persistent_data_memaddr() # Run the systems and defer the output once and the second time not, so that the second run automatically prints out the results - output_1_deferred = binary_c_python_api.run_system(argstring=argstring_1_deferred, persistent_data_memaddr=persistent_data_memaddr_2) - output_2_deferred_and_output = binary_c_python_api.run_system(argstring=argstring_2, persistent_data_memaddr=persistent_data_memaddr_2) + output_1_deferred = binary_c_python_api.run_system( + argstring=argstring_1_deferred, + persistent_data_memaddr=persistent_data_memaddr_2 + ) + output_2_deferred_and_output = binary_c_python_api.run_system( + argstring=argstring_2, + persistent_data_memaddr=persistent_data_memaddr_2 + ) ensemble_jsons_deferred_and_output = [line for line in output_2_deferred_and_output.splitlines() if line.startswith("ENSEMBLE_JSON")] -- GitLab