Loading scripts/create_histogram_summary.py +39 −21 Original line number Diff line number Diff line Loading @@ -33,61 +33,79 @@ if __name__ == "__main__": help="Summary image file, e.g. summary.png", default = None ) parser.add_argument( "--measure", type=str, nargs=1, help="Measure, any of: MLD, DIFF, SSNR, default: MLD", default = ['MLD'] ) args = parser.parse_args() csv_report = args.csv_report csv_summary = args.csv_summary csv_image = args.csv_image measure = args.measure[0] limits = [0, 5, 10, math.inf] limits_per_measure = {'MLD':('MLD',[0, 5, 10, math.inf]), 'DIFF':('MAXIMUM ABS DIFF',[0, 1024, 16384, 32769]), 'SSNR':('MIN_SSNR',[-math.inf, 0, 20, 40, 60, 100])} (measure_label, limits) = limits_per_measure[measure] # Load CSV report results_sorted = {} with open(csv_report,'r') as fp: reader = csv.reader(fp, delimiter=';') header = next(reader) keys = header[1:-1] keys = header[1:] for row in reader: testcase = row[0] results_sorted[testcase] = {} for k, val in zip(keys, row[1:-1]): for k, val in zip(keys, row[1:]): results_sorted[testcase][k] = val # Output CSV file with open(csv_summary, "w") as fp: limits_labels = ["0"] + [f"{str(a)} -- {str(b)}" for (a,b) in zip(limits[0:-1],limits[1:])] + ["None"] limits_labels = [f"{str(a)} -- {str(b)}" for (a,b) in zip(limits[0:-1],limits[1:])] + ["None"] # Zero difference is treated as a special category for MLD and MAXIMUM ABS DIFF if measure_label == "MLD" or measure_label == "MAXIMUM ABS DIFF": limits_labels = ["0"] + limits_labels headerline = f"Format;Category;" + ";".join(limits_labels) + "\n" fp.write(headerline) subplot = 0 fig, ax = plt.subplots(len(FORMATS)//2, 2) fig, ax = plt.subplots(len(FORMATS)//4, 4) for fmt in FORMATS: bottom = np.zeros(len(limits)+1) bottom = np.zeros(len(limits_labels)) row = subplot // 4 col = subplot % 4 for cat in CATEGORIES: mld_vals = [x for x in [m["MLD"] for m in results_sorted.values() if m["Format"] == fmt and m["Category"] == cat]] mld = [float(x) for x in mld_vals if x != 'None' and x != '0'] zero = sum([1 for x in mld_vals if x == '0']) none = sum([1 for x in mld_vals if x == 'None']) hist, _ = np.histogram(mld,limits) data = np.array([zero] + list(hist) + [none]) values = [x for x in [m[measure_label] for m in results_sorted.values() if m["Format"] == fmt and m["Category"] == cat]] # Zero difference is treated as a special category for MLD and MAXIMUM ABS DIFF if measure_label == "MLD" or measure_label == "MAXIMUM ABS DIFF": val = [float(x) for x in values if x != 'None' and x != '0' and x != ''] zero = [sum([1 for x in values if x == '0'])] none = [sum([1 for x in values if x == 'None' or x == ''])] else: val = [float(x) for x in values if x != 'None' and x != ''] zero = [] none = [sum([1 for x in values if x == 'None' or x == ''])] hist, _ = np.histogram(val,limits) data = np.array(zero + list(hist) + none) # CSV output line = f"{fmt};{cat};{'; '.join(map(str,data))}\n" fp.write(line) # Matplotlib histogram a = subplot % 4 b = subplot // 4 ax[a][b].bar(limits_labels, data, 0.5, label=cat, bottom=bottom) ax[row][col].bar(limits_labels, data, 0.5, label=cat, bottom=bottom) bottom += data # Histogram layout ax[a][b].set_title(fmt) ax[a][b].legend(loc="best") ax[a][b].set_xlabel("MLD") ax[a][b].set_ylabel("Number of test cases") ax[row][col].set_title(fmt) ax[row][col].legend(loc="best") ax[row][col].set_xlabel(measure_label) ax[row][col].set_ylabel("Number of test cases") subplot += 1 fig.set_figheight(20) fig.set_figwidth(16) fig.set_figheight(16) fig.set_figwidth(32) if csv_image: plt.savefig(csv_image) scripts/parse_xml_report.py +0 −1 Original line number Diff line number Diff line Loading @@ -4,7 +4,6 @@ import argparse import re import math import numpy as np import matplotlib.pyplot as plt from xml.etree import ElementTree """ Loading Loading
scripts/create_histogram_summary.py +39 −21 Original line number Diff line number Diff line Loading @@ -33,61 +33,79 @@ if __name__ == "__main__": help="Summary image file, e.g. summary.png", default = None ) parser.add_argument( "--measure", type=str, nargs=1, help="Measure, any of: MLD, DIFF, SSNR, default: MLD", default = ['MLD'] ) args = parser.parse_args() csv_report = args.csv_report csv_summary = args.csv_summary csv_image = args.csv_image measure = args.measure[0] limits = [0, 5, 10, math.inf] limits_per_measure = {'MLD':('MLD',[0, 5, 10, math.inf]), 'DIFF':('MAXIMUM ABS DIFF',[0, 1024, 16384, 32769]), 'SSNR':('MIN_SSNR',[-math.inf, 0, 20, 40, 60, 100])} (measure_label, limits) = limits_per_measure[measure] # Load CSV report results_sorted = {} with open(csv_report,'r') as fp: reader = csv.reader(fp, delimiter=';') header = next(reader) keys = header[1:-1] keys = header[1:] for row in reader: testcase = row[0] results_sorted[testcase] = {} for k, val in zip(keys, row[1:-1]): for k, val in zip(keys, row[1:]): results_sorted[testcase][k] = val # Output CSV file with open(csv_summary, "w") as fp: limits_labels = ["0"] + [f"{str(a)} -- {str(b)}" for (a,b) in zip(limits[0:-1],limits[1:])] + ["None"] limits_labels = [f"{str(a)} -- {str(b)}" for (a,b) in zip(limits[0:-1],limits[1:])] + ["None"] # Zero difference is treated as a special category for MLD and MAXIMUM ABS DIFF if measure_label == "MLD" or measure_label == "MAXIMUM ABS DIFF": limits_labels = ["0"] + limits_labels headerline = f"Format;Category;" + ";".join(limits_labels) + "\n" fp.write(headerline) subplot = 0 fig, ax = plt.subplots(len(FORMATS)//2, 2) fig, ax = plt.subplots(len(FORMATS)//4, 4) for fmt in FORMATS: bottom = np.zeros(len(limits)+1) bottom = np.zeros(len(limits_labels)) row = subplot // 4 col = subplot % 4 for cat in CATEGORIES: mld_vals = [x for x in [m["MLD"] for m in results_sorted.values() if m["Format"] == fmt and m["Category"] == cat]] mld = [float(x) for x in mld_vals if x != 'None' and x != '0'] zero = sum([1 for x in mld_vals if x == '0']) none = sum([1 for x in mld_vals if x == 'None']) hist, _ = np.histogram(mld,limits) data = np.array([zero] + list(hist) + [none]) values = [x for x in [m[measure_label] for m in results_sorted.values() if m["Format"] == fmt and m["Category"] == cat]] # Zero difference is treated as a special category for MLD and MAXIMUM ABS DIFF if measure_label == "MLD" or measure_label == "MAXIMUM ABS DIFF": val = [float(x) for x in values if x != 'None' and x != '0' and x != ''] zero = [sum([1 for x in values if x == '0'])] none = [sum([1 for x in values if x == 'None' or x == ''])] else: val = [float(x) for x in values if x != 'None' and x != ''] zero = [] none = [sum([1 for x in values if x == 'None' or x == ''])] hist, _ = np.histogram(val,limits) data = np.array(zero + list(hist) + none) # CSV output line = f"{fmt};{cat};{'; '.join(map(str,data))}\n" fp.write(line) # Matplotlib histogram a = subplot % 4 b = subplot // 4 ax[a][b].bar(limits_labels, data, 0.5, label=cat, bottom=bottom) ax[row][col].bar(limits_labels, data, 0.5, label=cat, bottom=bottom) bottom += data # Histogram layout ax[a][b].set_title(fmt) ax[a][b].legend(loc="best") ax[a][b].set_xlabel("MLD") ax[a][b].set_ylabel("Number of test cases") ax[row][col].set_title(fmt) ax[row][col].legend(loc="best") ax[row][col].set_xlabel(measure_label) ax[row][col].set_ylabel("Number of test cases") subplot += 1 fig.set_figheight(20) fig.set_figwidth(16) fig.set_figheight(16) fig.set_figwidth(32) if csv_image: plt.savefig(csv_image)
scripts/parse_xml_report.py +0 −1 Original line number Diff line number Diff line Loading @@ -4,7 +4,6 @@ import argparse import re import math import numpy as np import matplotlib.pyplot as plt from xml.etree import ElementTree """ Loading