Commit acde5b1a authored by Jan Kiene's avatar Jan Kiene
Browse files

run formatter

parent 625d6748
Loading
Loading
Loading
Loading
Loading
+17 −5
Original line number Diff line number Diff line
@@ -112,11 +112,18 @@ def create_subpage(
    )
    write_out_csv(merged_reports, merged_reports[0].keys(), csv_out)

    table_header_a = "".join([TH_TMPL_GLOBAL.format(c) for c in COLUMNS_GLOBAL] + [TH_TMPL_DIFFERENTIAL.format(c) for c in COLUMNS_DIFFERENTIAL])
    table_header_a = "".join(
        [TH_TMPL_GLOBAL.format(c) for c in COLUMNS_GLOBAL]
        + [TH_TMPL_DIFFERENTIAL.format(c) for c in COLUMNS_DIFFERENTIAL]
    )
    table_header_b = list()
    for c in COLUMNS_DIFFERENTIAL:
        table_header_b.append(TH_TMPL_SECOND_ROW.format(f"Previous Run<br>ID: {id_previous}"))
        table_header_b.append(TH_TMPL_SECOND_ROW.format(f"Current Run<br>ID: {id_current}"))
        table_header_b.append(
            TH_TMPL_SECOND_ROW.format(f"Previous Run<br>ID: {id_previous}")
        )
        table_header_b.append(
            TH_TMPL_SECOND_ROW.format(f"Current Run<br>ID: {id_current}")
        )
    table_header_b = "".join(table_header_b)
    table_body = "\n".join(
        tr_from_row(row, id_current, id_previous) for row in merged_reports
@@ -242,8 +249,13 @@ def merge_and_cleanup_mld_reports(

        return diff

    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)
    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:
+45 −31
Original line number Diff line number Diff line
@@ -342,8 +342,14 @@ def compare(
                for i in range(nchannels):
                    tmpfile_ref = Path(tmpdir).joinpath(f"ref_ch{i+1}.wav")
                    tmpfile_test = Path(tmpdir).joinpath(f"test_ch{i+1}.wav")
                    r48 = np.clip( resample(ref[:, i].astype(float), fs, 48000), -32768, 32767 ).astype(np.int16) # Convert to float for resample, then to int16 for wavfile.write
                    t48 = np.clip( resample(test[:, i].astype(float), fs, 48000), -32768, 32767 ).astype(np.int16)
                    r48 = np.clip(
                        resample(ref[:, i].astype(float), fs, 48000), -32768, 32767
                    ).astype(
                        np.int16
                    )  # Convert to float for resample, then to int16 for wavfile.write
                    t48 = np.clip(
                        resample(test[:, i].astype(float), fs, 48000), -32768, 32767
                    ).astype(np.int16)
                    wavfile.write(str(tmpfile_ref), 48000, r48)
                    wavfile.write(str(tmpfile_test), 48000, t48)
                    out = subprocess.check_output([mld, tmpfile_ref, tmpfile_test])
@@ -355,7 +361,13 @@ def compare(
            # length of segment is always 20ms
            len_seg = int(0.02 * fs)
            print(len_seg, ref.shape, test.shape)
            result["SSNR"] = ssnr(ref, test, len_seg, thresh_low=ssnr_thresh_low, thresh_high=ssnr_thresh_high)
            result["SSNR"] = ssnr(
                ref,
                test,
                len_seg,
                thresh_low=ssnr_thresh_low,
                thresh_high=ssnr_thresh_high,
            )

    return result

@@ -575,7 +587,9 @@ def ssnr(
    # for that channel and the division here would trigger a warning. We supress the warning and later
    # set the SSNR for those channels to -inf manually instead (overwriting later is simply easier than adding ifs here)
    with warnings.catch_warnings():
        ssnr = np.round(10 * np.log10(10 ** (np.sum(ss, axis=0) / segment_counter) - 1), 2)
        ssnr = np.round(
            10 * np.log10(10 ** (np.sum(ss, axis=0) / segment_counter) - 1), 2
        )
    ssnr[segment_counter == 0] = -np.inf

    return ssnr
+10 −4
Original line number Diff line number Diff line
@@ -14,7 +14,9 @@ def main(args):

    len_seg = int(20 * fs_ref / 1000)
    print(len_seg, ref_sig.shape, test_sig.shape)
    ssnr = audioarray.ssnr(ref_sig, test_sig, len_seg, args.thresh_low, args.thresh_high)
    ssnr = audioarray.ssnr(
        ref_sig, test_sig, len_seg, args.thresh_low, args.thresh_high
    )

    for i, s in enumerate(ssnr, start=1):
        print(f"Channel {i}: {s}")
@@ -29,10 +31,14 @@ if __name__ == "__main__":
        "test_file", type=pathlib.Path, help="Signal under test wav file"
    )
    parser.add_argument(
            "--thresh_low", type=float, default="-inf",
        "--thresh_low",
        type=float,
        default="-inf",
    )
    parser.add_argument(
            "--thresh_high", type=float, default="inf",
        "--thresh_high",
        type=float,
        default="inf",
    )

    args = parser.parse_args()
+12 −3
Original line number Diff line number Diff line
@@ -40,8 +40,12 @@ def cmp_pcm(
    else:
        nchannels = pyivastest.constants.OC_TO_NCHANNELS[out_config.upper()]

    s1, _ = pyaudio3dtools.audiofile.readfile(ref_file, nchannels, fs, outdtype=np.int16)
    s2, _ = pyaudio3dtools.audiofile.readfile(cmp_file, nchannels, fs, outdtype=np.int16)
    s1, _ = pyaudio3dtools.audiofile.readfile(
        ref_file, nchannels, fs, outdtype=np.int16
    )
    s2, _ = pyaudio3dtools.audiofile.readfile(
        cmp_file, nchannels, fs, outdtype=np.int16
    )

    # In case of wav input, override the nchannels with the one from the wav header
    nchannels = s1.shape[1]
@@ -63,7 +67,12 @@ def cmp_pcm(
        return 1, reason

    cmp_result = pyaudio3dtools.audioarray.compare(
        s1, s2, fs, per_frame=False, get_mld=get_mld, get_ssnr=get_ssnr,
        s1,
        s2,
        fs,
        per_frame=False,
        get_mld=get_mld,
        get_ssnr=get_ssnr,
    )

    output_differs = 0
+10 −2
Original line number Diff line number Diff line
@@ -366,7 +366,11 @@ class EncoderFrontend:

        try:
            result = run(
                command, capture_output=True, check=False, timeout=self.timeout, cwd=run_dir
                command,
                capture_output=True,
                check=False,
                timeout=self.timeout,
                cwd=run_dir,
            )
        except TimeoutExpired:
            pytest.fail(f"{self._type} encoder run timed out after {self.timeout}s.")
@@ -565,7 +569,11 @@ class DecoderFrontend:

        try:
            result = run(
                command, capture_output=True, check=False, timeout=self.timeout, cwd=run_dir
                command,
                capture_output=True,
                check=False,
                timeout=self.timeout,
                cwd=run_dir,
            )
        except TimeoutExpired:
            pytest.fail(f"{self._type} decoder run timed out after {self.timeout}s.")