Commit 53b7a93d authored by Jan Kiene's avatar Jan Kiene
Browse files

sort so that any diffs are above no diffs

parent 965d19b8
Loading
Loading
Loading
Loading
+16 −3
Original line number Diff line number Diff line
import csv
import pathlib
import argparse
from functools import partial


CSV_DELIM = ";"
@@ -94,7 +95,7 @@ ARROW_DOWN = '<span class="arrowdown">&#11010;</span>'
COLUMNS = ["testcase", "Result", "MLD", "MAXIMUM ABS DIFF"]
COLUMNS_GLOBAL = COLUMNS[:1]
COLUMNS_DIFFERENTIAL = COLUMNS[1:]

COLUMNS_DIFFERENTIAL_NOT_MLD = COLUMNS_DIFFERENTIAL[2:]

def create_subpage(
    html_out,
@@ -210,7 +211,7 @@ def merge_and_cleanup_mld_reports(
    mld_col_curr = f"MLD-{id_current}"
    mld_col_prev = f"MLD-{id_previous}"

    def sort_func(x):
    def sort_func(x, other_col_pairs):
        """
        Sort function for the rows. Puts missing or invalid values on top as those usually
        indicate crashes. Then sorts by MLD difference in descending order. MLD diffs of zero
@@ -224,12 +225,24 @@ def merge_and_cleanup_mld_reports(
            return float("inf")

        diff = float(x[mld_col_curr]) - float(x[mld_col_prev])

        # if no diff in mld col found, check if there is a diff in any other measure
        if diff == 0:
            diff = float("-inf")

            diff_other = 0
            for col_pair in other_col_pairs:
                col_prev = col_pair[0]
                col_curr = col_pair[1]
                diff_other += abs(float(x[col_curr]) - float(x[col_prev]))

            if diff_other > 0:
                diff = -1000000

        return diff

    merged = sorted(merged, key=sort_func, reverse=True)
    other_col_pairs = [(f"{col}-{id_previous}", f"{col}-{id_current}") for col in COLUMNS_DIFFERENTIAL_NOT_MLD]
    merged = sorted(merged, key=partial(sort_func, other_col_pairs=other_col_pairs), reverse=True)

    # remove the unecessary whole path from the testcase names
    for row in merged: