Commit c4ffb1be authored by norvell's avatar norvell
Browse files

Separate images per format

parent 10c395a9
Loading
Loading
Loading
Loading
Loading
+7 −9
Original line number Diff line number Diff line
@@ -34,7 +34,7 @@ Comparing:
    <li><a href="{job_name}--merged_csv--{id_current}.csv">Merged csv data</a></li>
</ul>

<img src={histogram}>
{images}

<br>
<b>How is the table sorted?</b>
@@ -108,7 +108,7 @@ def create_subpage(
    id_current: int,
    id_previous: int,
    job_name: str,
    histogram: str,
    histogram,
):
    merged_reports = merge_and_cleanup_mld_reports(
        csv_current, csv_previous, id_current, id_previous
@@ -131,6 +131,7 @@ def create_subpage(
    table_body = "\n".join(
        tr_from_row(row, id_current, id_previous) for row in merged_reports
    )
    images = " ".join([f"<img src={x}>" for x in histogram])
    new_subpage = SUBPAGE_TMPL_CSS + SUBPAGE_TMPL_HTML.format(
        id_current=id_current,
        id_previous=id_previous,
@@ -138,7 +139,7 @@ def create_subpage(
        job_name=job_name,
        table_header_a=table_header_a,
        table_header_b=table_header_b,
        histogram=histogram
        images=images
    )
    with open(html_out, "w") as f:
        f.write(new_subpage)
@@ -298,13 +299,10 @@ if __name__ == "__main__":
    parser.add_argument("id_current", type=int)
    parser.add_argument("id_previous", type=int)
    parser.add_argument("job_name")
    parser.add_argument("--histogram", type=str, nargs=1, help="histogram picture", default = None)
    parser.add_argument("--histogram", type=str, nargs='+', help="histogram picture(s)", default = [])
    args = parser.parse_args()

    if args.histogram != None:
        histogram = args.histogram[0]
    else:
        histogram = "None"


    create_subpage(
        args.html_out,
@@ -314,5 +312,5 @@ if __name__ == "__main__":
        args.id_current,
        args.id_previous,
        args.job_name,
        histogram,
        args.histogram,
    )
+12 −14
Original line number Diff line number Diff line
@@ -7,6 +7,7 @@ import matplotlib # These steps are added as a precaution in case the gitlab
matplotlib.use('Agg') # needs DISPLAY to render the plots, even if they are written to file.
import matplotlib.pyplot as plt
import csv
import os
from parse_xml_report import FORMATS, CATEGORIES

"""
@@ -72,12 +73,9 @@ if __name__ == "__main__":
        headerline = f"Format;Category;" + ";".join(limits_labels) + "\n"
        fp.write(headerline)

        subplot = 0
        fig, ax = plt.subplots(len(FORMATS)//4, 4)
        for fmt in FORMATS:
            fig, ax = plt.subplots()
            bottom = np.zeros(len(limits_labels))
            row = subplot // 4
            col = subplot % 4
            for cat in CATEGORIES:
                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
@@ -97,17 +95,17 @@ if __name__ == "__main__":
                fp.write(line)
        
                # Matplotlib histogram
                ax[row][col].bar(limits_labels, data, 0.5, label=cat, bottom=bottom)
                ax.bar(limits_labels, data, 0.5, label=cat, bottom=bottom)
                bottom += data

            # Histogram layout
            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
            ax.set_title(fmt)
            ax.legend(loc="best")
            ax.set_xlabel(measure_label)
            ax.set_ylabel("Number of test cases")

        fig.set_figheight(16)
        fig.set_figwidth(32)
            fig.set_figheight(4)
            fig.set_figwidth(6)
            if csv_image:
            plt.savefig(csv_image)
                base, ext = os.path.splitext(csv_image)
                plt.savefig(f"{base}_{fmt}{ext}")