Commit 56e874cc authored by norvell's avatar norvell
Browse files

Harmonize results into a dict

parent 884f6f26
Loading
Loading
Loading
Loading
+12 −6
Original line number Diff line number Diff line
@@ -79,16 +79,21 @@ if __name__ == "__main__":
            # For ERROR cases, both a FAIL and an ERROR result is generated. 
            # Here, a FAIL would be overwritten with an ERROR result since it has the same name.
            # Todo: Change to fielded dict for all entries to eliminate confusing literal indices
            results_unsorted[fulltestname] = (fmt, cat, testresult, properties_values) 
            #results_unsorted[fulltestname] = (fmt, cat, testresult, properties_values) 
            results_unsorted[fulltestname] = {'Format':fmt, 'Category':cat, 'Result':testresult}
            for propertyname, propertyvalue in zip(PROPERTIES, properties_values):
                results_unsorted[fulltestname][propertyname] = propertyvalue

    results_sorted = dict(sorted(results_unsorted.items()))

    keys = list(results_sorted[list(results_unsorted.keys())[0]].keys())

    with open(csv_file, "w") as outfile:
        headerline = ";".join(["testcase","Format","Category","Result"] + PROPERTIES) + "\n"
        headerline = ";".join(["testcase"] + keys) + "\n"
        outfile.write(headerline)
        for test in results_sorted:
            count[results_sorted[test][2]] += 1
            line = ";".join([test] + list(results_sorted[test])[0:-1] + results_sorted[test][-1]) + "\n"
            count[results_sorted[test]["Result"]] += 1
            line = ";".join([test] + list(results_sorted[test].values())) + "\n"
            outfile.write(line)

    tmp = {}
@@ -100,8 +105,9 @@ if __name__ == "__main__":
    if summary_file is not None:
        with open(summary_file, "w") as fp:
            for testcase in results_sorted:
                (fmt, cat, _, _) = results_sorted[testcase]
                tmp[fmt][cat].append(results_sorted[testcase][-1][0]) # Add MLD score to list
                fmt = results_sorted[testcase]["Format"]
                cat = results_sorted[testcase]["Category"]
                tmp[fmt][cat].append(results_sorted[testcase]["MLD"]) # Add MLD score to list
                
            for fmt in tmp:
                headerline = f"{fmt};\nCategory;0;" + ";".join([f"{str(a)} -- {str(b)}" for (a,b) in zip(limits[0:-1],limits[1:])]) + ";None\n"