Mar-28-2020, 03:05 AM
Greetings folks,
I am still fairly new to python and have a small problem with a function I have written:
Thank you very much in advance!
I am still fairly new to python and have a small problem with a function I have written:
def evaluate_tests(test_results): evaluation = {}; n = 0; for tests in test_results: test_eval = {}; test_eval['error'] = []; test_eval['incomplete_nodes'] = []; test_eval['finished_fbc'] = 0; test_eval['finished_mfcn'] = 0; sum_fbc_error = 0; sum_mfcn_error = 0; sum_fbc_in = 0; sum_mfcn_in = 0; for test_result in tests: fbc = test_result['find_best_coverage']; mfcn = test_result['max_fully_covered_nodes']; print("fbc['incomplete_nodes']"); print(fbc['incomplete_nodes']); print("mfcn['incomplete_nodes']"); print(mfcn['incomplete_nodes']); print("mfcn fbc incomplete notes difference"); print(abs(len(fbc['incomplete_nodes']) - len(mfcn['incomplete_nodes']))); test_eval['error'].append(abs(fbc['errors'] - mfcn['errors'])); test_eval['incomplete_nodes'].append(abs(len(fbc['incomplete_nodes']) - len(mfcn['incomplete_nodes']))); test_eval['finished_fbc'] += 1; test_eval['finished_mfcn'] += 1; sum_fbc_error += fbc['errors']; sum_mfcn_error += mfcn['errors']; sum_fbc_in += len(fbc['incomplete_nodes']); sum_mfcn_in += len(mfcn['incomplete_nodes']); print("error difference fbc mfcn"); print(test_eval['error']); print("test_eval['incomplete_nodes']"); print(test_eval['incomplete_nodes']);All initiated variables of the dictionary
test_eval['error'] = []; test_eval['incomplete_nodes'] = []; test_eval['finished_fbc'] = 0; test_eval['finished_mfcn'] = 0;will be filled with data inside the loop (the print command shows that to me) but are empty outside (or 0) of the loop (as they were initialised), since I initialised them before the loop I actually expected to be available also after the loop finished - can somebody tell me how to fix it (and what I did wrong)?
Thank you very much in advance!