From d24aaa3dea0d80a468da1e775ce9fda54e13bedd Mon Sep 17 00:00:00 2001 From: Jan Kiene Date: Fri, 14 Jun 2024 15:49:55 +0200 Subject: [PATCH 1/6] add odg diff to pytst suite --- tests/cmp_pcm.py | 47 +++++++++++++++++++ .../test_param_file.py | 11 ++++- tests/conftest.py | 14 ++++++ tests/constants.py | 2 + 4 files changed, 73 insertions(+), 1 deletion(-) diff --git a/tests/cmp_pcm.py b/tests/cmp_pcm.py index 3c16e526c9..65c1cd5c6e 100755 --- a/tests/cmp_pcm.py +++ b/tests/cmp_pcm.py @@ -3,6 +3,11 @@ import argparse import os import sys +import tempfile +import re +import subprocess +from pathlib import Path +from typing import Optional THIS_PATH = os.path.join(os.getcwd(), __file__) sys.path.append(os.path.join(os.path.dirname(THIS_PATH), "../scripts")) @@ -10,6 +15,7 @@ sys.path.append(os.path.join(os.path.dirname(THIS_PATH), "../scripts")) import numpy as np import pyaudio3dtools import pyivastest +from constants import ODG_PATTERN def cmp_pcm( @@ -22,6 +28,8 @@ def cmp_pcm( mld_lim=0, abs_tol=0, get_ssnr=False, + get_odg=False, + orig_file: Optional[Path]=None ) -> (int, str): """ Compare 2 PCM files for bitexactness @@ -98,9 +106,48 @@ def cmp_pcm( reason += msg + "\n" print(msg) + if get_odg: + reason += "\n" + orig_sig, _ = pyaudio3dtools.audiofile.readfile(orig_file) + for n in range(nchannels): + pqeval_output_ref = pqevalaudio_wrapper(s1[:, n], orig_sig[:, n]) + pqeval_output_cmp = pqevalaudio_wrapper(s2[:, n], orig_sig[:, n]) + + match_ref = re.match(ODG_PATTERN, pqeval_output_ref) + match_cmp = re.match(ODG_PATTERN, pqeval_output_cmp) + + odg_ref = float(match_ref.groups()[0]) + odg_cmp = float(match_cmp.groups()[0]) + odg_diff = odg_cmp - odg_ref + msg = f"Channel {n} ODG diff: {odg_diff}" + reason += msg + print(msg) + return output_differs, reason +def pqevalaudio_wrapper( + ref_sig: np.ndarray, + eval_sig: np.ndarray, + fs: int, + ) -> str: + with tempfile.TemporaryDirectory() as tmp_dir: + tmp_dir = Path(tmp_dir) + tmp_file_ref = str(tmp_dir.joinpath("ref.wav")) + tmp_file_eval = str(tmp_dir.joinpath("eval.wav")) + + pyaudio3dtools.audiofile.writefile(tmp_file_ref, ref_sig, fs) + pyaudio3dtools.audiofile.writefile(tmp_file_eval, eval_sig, fs) + + cmd = ["PQevalAudio", tmp_file_ref, tmp_file_eval] + + result = subprocess.run(cmd, capture_output=True) + if result.returncode != 0: + raise RuntimeError("Error running PQevalaudio") + + return result.stdout.decode("utf8") + + if __name__ == "__main__": parser = argparse.ArgumentParser() parser.add_argument("ref_file", type=str) diff --git a/tests/codec_be_on_mr_nonselection/test_param_file.py b/tests/codec_be_on_mr_nonselection/test_param_file.py index 9fd688471c..7268c70bcd 100644 --- a/tests/codec_be_on_mr_nonselection/test_param_file.py +++ b/tests/codec_be_on_mr_nonselection/test_param_file.py @@ -45,7 +45,7 @@ import numpy as np from tests.cmp_pcm import cmp_pcm from tests.conftest import DecoderFrontend, EncoderFrontend from tests.testconfig import PARAM_FILE -from ..constants import MLD_PATTERN, MAX_DIFF_PATTERN, SSNR_PATTERN +from ..constants import MLD_PATTERN, MAX_DIFF_PATTERN, SSNR_PATTERN, ODG_DIFF_PATTERN VALID_DEC_OUTPUT_CONF = [ "MONO", @@ -153,6 +153,7 @@ def test_param_file_tests( get_mld_lim, abs_tol, get_ssnr, + get_odg, ): enc_opts, dec_opts, sim_opts, eid_opts = param_file_test_dict[test_tag] @@ -351,6 +352,7 @@ def test_param_file_tests( abs_tol=abs_tol, allow_differing_lengths=allow_differing_lengths, get_ssnr=get_ssnr, + get_odg=get_odg, ) md_out_files = get_expected_md_files(ref_output_file, enc_split, output_config) @@ -365,6 +367,13 @@ def test_param_file_tests( record_property("MIN_SSNR", min_ssnr) record_property("MIN_SSNR_CHANNEL", min_ssnr_channel) + if get_odg: + odg_diffs = re.findall(ODG_DIFF_PATTERN, reason) + max_odg_diff = max(odg_diffs) + max_odg_diff_channel = odg_diffs.index(max_odg_diff) + record_property("MAX_ODG_DIFF", max_odg_diff) + record_property("MAX_ODG_DIFF_CHANNEL", max_odg_diff_channel) + max_diff = 0 if output_differs: search_result = re.search(MAX_DIFF_PATTERN, reason) diff --git a/tests/conftest.py b/tests/conftest.py index 304651846d..699fa06867 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -178,6 +178,12 @@ def pytest_addoption(parser): help="Compute Segmental SNR (SSNR) between ref and dut output instead of just comparing for bitexactness", ) + parser.addoption( + "--odg", + action="store_true", + help="Get Objective Difference Grade for both conditions during comparison and report difference", + ) + parser.addoption( "--create_ref", action="store_true", @@ -257,6 +263,14 @@ def get_ssnr(request): return request.config.option.ssnr +@pytest.fixture(scope="session", autouse=True) +def get_odg(request): + """ + Return indication to compute ssnr during ref/dut comparison. + """ + return request.config.option.odg + + @pytest.fixture(scope="session") def abs_tol(request) -> int: """ diff --git a/tests/constants.py b/tests/constants.py index 27b10e52f6..1379a0907a 100644 --- a/tests/constants.py +++ b/tests/constants.py @@ -2,3 +2,5 @@ MLD_PATTERN = r"MLD: ([\d\.]*)" MAX_DIFF_PATTERN = r"MAXIMUM ABS DIFF: (\d*)" SSNR_PATTERN = r"Channel \d* SSNR: (\d*\.\d*)" +ODG_PATTERN = r"Objective Difference Grade: (-*\d*\.\d*)" +ODG_DIFF_PATTERN = r"ODG diff: (-*\d*\.\d*)" -- GitLab From eff8c567c8e70a9856ff4c9d0c0c384206f74f8c Mon Sep 17 00:00:00 2001 From: kiene Date: Fri, 14 Jun 2024 17:06:37 +0200 Subject: [PATCH 2/6] fix odg --- tests/cmp_pcm.py | 24 ++++++++++++------- .../test_param_file.py | 1 + 2 files changed, 17 insertions(+), 8 deletions(-) diff --git a/tests/cmp_pcm.py b/tests/cmp_pcm.py index 65c1cd5c6e..c4c6ce3d12 100755 --- a/tests/cmp_pcm.py +++ b/tests/cmp_pcm.py @@ -15,7 +15,7 @@ sys.path.append(os.path.join(os.path.dirname(THIS_PATH), "../scripts")) import numpy as np import pyaudio3dtools import pyivastest -from constants import ODG_PATTERN +from .constants import ODG_PATTERN def cmp_pcm( @@ -108,13 +108,15 @@ def cmp_pcm( if get_odg: reason += "\n" + print(orig_file) orig_sig, _ = pyaudio3dtools.audiofile.readfile(orig_file) for n in range(nchannels): - pqeval_output_ref = pqevalaudio_wrapper(s1[:, n], orig_sig[:, n]) - pqeval_output_cmp = pqevalaudio_wrapper(s2[:, n], orig_sig[:, n]) + pqeval_output_ref = pqevalaudio_wrapper(s1[:, n], orig_sig[:, n], fs) + pqeval_output_cmp = pqevalaudio_wrapper(s2[:, n], orig_sig[:, n], fs) - match_ref = re.match(ODG_PATTERN, pqeval_output_ref) - match_cmp = re.match(ODG_PATTERN, pqeval_output_cmp) + print(pqeval_output_ref) + match_ref = re.search(ODG_PATTERN, pqeval_output_ref) + match_cmp = re.search(ODG_PATTERN, pqeval_output_cmp) odg_ref = float(match_ref.groups()[0]) odg_cmp = float(match_cmp.groups()[0]) @@ -136,15 +138,21 @@ def pqevalaudio_wrapper( tmp_file_ref = str(tmp_dir.joinpath("ref.wav")) tmp_file_eval = str(tmp_dir.joinpath("eval.wav")) - pyaudio3dtools.audiofile.writefile(tmp_file_ref, ref_sig, fs) - pyaudio3dtools.audiofile.writefile(tmp_file_eval, eval_sig, fs) + # PQevalAudio neeeds 48 kHz sampling rate + r48 = np.clip( pyaudio3dtools.audioarray.resample(ref_sig.astype(float), fs, 48000), -32768, 32767 ).astype(np.int16) + t48 = np.clip( pyaudio3dtools.audioarray.resample(eval_sig.astype(float), fs, 48000), -32768, 32767 ).astype(np.int16) + + pyaudio3dtools.audiofile.writefile(tmp_file_ref, r48, 48000) + pyaudio3dtools.audiofile.writefile(tmp_file_eval, t48, 48000) cmd = ["PQevalAudio", tmp_file_ref, tmp_file_eval] + print(cmd) result = subprocess.run(cmd, capture_output=True) if result.returncode != 0: - raise RuntimeError("Error running PQevalaudio") + raise RuntimeError(f"Error running PQevalaudio: {result.stderr}") + print(result.stdout.decode("utf8")) return result.stdout.decode("utf8") diff --git a/tests/codec_be_on_mr_nonselection/test_param_file.py b/tests/codec_be_on_mr_nonselection/test_param_file.py index 7268c70bcd..1edc111019 100644 --- a/tests/codec_be_on_mr_nonselection/test_param_file.py +++ b/tests/codec_be_on_mr_nonselection/test_param_file.py @@ -353,6 +353,7 @@ def test_param_file_tests( allow_differing_lengths=allow_differing_lengths, get_ssnr=get_ssnr, get_odg=get_odg, + orig_file=Path(reference_path).joinpath(testv_file) ) md_out_files = get_expected_md_files(ref_output_file, enc_split, output_config) -- GitLab From cfd1245c2ef6e44deeb05aff3f437387023f47d7 Mon Sep 17 00:00:00 2001 From: Jan Kiene Date: Tue, 25 Jun 2024 07:05:33 +0200 Subject: [PATCH 3/6] correct printouts --- tests/cmp_pcm.py | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-) diff --git a/tests/cmp_pcm.py b/tests/cmp_pcm.py index c4c6ce3d12..65505ee0f7 100755 --- a/tests/cmp_pcm.py +++ b/tests/cmp_pcm.py @@ -100,21 +100,17 @@ def cmp_pcm( reason += f" > {mld_lim}" if get_ssnr: - reason += "\n" for i, s in enumerate(cmp_result["SSNR"], start=1): msg = f"Channel {i} SSNR: {s}" - reason += msg + "\n" + reason += " - " + msg print(msg) if get_odg: - reason += "\n" - print(orig_file) orig_sig, _ = pyaudio3dtools.audiofile.readfile(orig_file) for n in range(nchannels): pqeval_output_ref = pqevalaudio_wrapper(s1[:, n], orig_sig[:, n], fs) pqeval_output_cmp = pqevalaudio_wrapper(s2[:, n], orig_sig[:, n], fs) - print(pqeval_output_ref) match_ref = re.search(ODG_PATTERN, pqeval_output_ref) match_cmp = re.search(ODG_PATTERN, pqeval_output_cmp) @@ -122,7 +118,7 @@ def cmp_pcm( odg_cmp = float(match_cmp.groups()[0]) odg_diff = odg_cmp - odg_ref msg = f"Channel {n} ODG diff: {odg_diff}" - reason += msg + reason += " - " + msg print(msg) return output_differs, reason @@ -147,12 +143,10 @@ def pqevalaudio_wrapper( cmd = ["PQevalAudio", tmp_file_ref, tmp_file_eval] - print(cmd) result = subprocess.run(cmd, capture_output=True) if result.returncode != 0: raise RuntimeError(f"Error running PQevalaudio: {result.stderr}") - print(result.stdout.decode("utf8")) return result.stdout.decode("utf8") -- GitLab From 23eebe187f417cecb2fe94049d3c66864b2d1bf5 Mon Sep 17 00:00:00 2001 From: Jan Kiene Date: Thu, 4 Jul 2024 14:40:33 +0200 Subject: [PATCH 4/6] use reference output as uncodec input for PEAQ --- tests/cmp_pcm.py | 17 +++++------------ .../test_param_file.py | 1 - .../test_sba_bs_dec_plc.py | 4 ++++ .../test_sba_bs_enc.py | 12 ++++++++++++ tests/conftest.py | 4 ++-- tests/constants.py | 4 ++-- 6 files changed, 25 insertions(+), 17 deletions(-) diff --git a/tests/cmp_pcm.py b/tests/cmp_pcm.py index 49d2d3d31c..3139a32dc9 100755 --- a/tests/cmp_pcm.py +++ b/tests/cmp_pcm.py @@ -15,7 +15,7 @@ sys.path.append(os.path.join(os.path.dirname(THIS_PATH), "../scripts")) import numpy as np import pyaudio3dtools import pyivastest -from .constants import ODG_PATTERN +from .constants import ODG_PATTERN_PQEVALAUDIO def cmp_pcm( @@ -29,7 +29,6 @@ def cmp_pcm( abs_tol=0, get_ssnr=False, get_odg=False, - orig_file: Optional[Path]=None ) -> (int, str): """ Compare 2 PCM files for bitexactness @@ -116,18 +115,12 @@ def cmp_pcm( print(msg) if get_odg: - orig_sig, _ = pyaudio3dtools.audiofile.readfile(orig_file) for n in range(nchannels): - pqeval_output_ref = pqevalaudio_wrapper(s1[:, n], orig_sig[:, n], fs) - pqeval_output_cmp = pqevalaudio_wrapper(s2[:, n], orig_sig[:, n], fs) + pqeval_output = pqevalaudio_wrapper(s1[:, n], s2[:, n], fs) - match_ref = re.search(ODG_PATTERN, pqeval_output_ref) - match_cmp = re.search(ODG_PATTERN, pqeval_output_cmp) - - odg_ref = float(match_ref.groups()[0]) - odg_cmp = float(match_cmp.groups()[0]) - odg_diff = odg_cmp - odg_ref - msg = f"Channel {n} ODG diff: {odg_diff}" + match_odg = re.search(ODG_PATTERN_PQEVALAUDIO, pqeval_output) + odg = float(match_odg.groups()[0]) + msg = f"Channel {n} ODG: {odg}" reason += " - " + msg print(msg) diff --git a/tests/codec_be_on_mr_nonselection/test_param_file.py b/tests/codec_be_on_mr_nonselection/test_param_file.py index 3c5283dd35..61f40072cd 100644 --- a/tests/codec_be_on_mr_nonselection/test_param_file.py +++ b/tests/codec_be_on_mr_nonselection/test_param_file.py @@ -352,7 +352,6 @@ def test_param_file_tests( allow_differing_lengths=allow_differing_lengths, get_ssnr=get_ssnr, get_odg=get_odg, - orig_file=Path(reference_path).joinpath(testv_file) ) md_out_files = get_expected_md_files(ref_output_file, enc_split, output_config) diff --git a/tests/codec_be_on_mr_nonselection/test_sba_bs_dec_plc.py b/tests/codec_be_on_mr_nonselection/test_sba_bs_dec_plc.py index e188d4a114..d191f87e10 100644 --- a/tests/codec_be_on_mr_nonselection/test_sba_bs_dec_plc.py +++ b/tests/codec_be_on_mr_nonselection/test_sba_bs_dec_plc.py @@ -94,6 +94,7 @@ def test_sba_plc_system( get_mld_lim, abs_tol, get_ssnr, + get_odg ): SID = 0 if dtx == "1" and ivas_br not in ["13200", "16400", "24400", "32000", "64000"]: @@ -135,6 +136,7 @@ def test_sba_plc_system( get_mld_lim=get_mld_lim, abs_tol=abs_tol, get_ssnr=get_ssnr, + get_odg=get_odg, ) @@ -161,6 +163,7 @@ def sba_dec_plc( get_mld_lim=0, abs_tol=0, get_ssnr=False, + get_odg=False, ): # ------------ run cmd ------------ @@ -219,6 +222,7 @@ def sba_dec_plc( mld_lim=get_mld_lim, abs_tol=abs_tol, get_ssnr=get_ssnr, + get_odg=get_odg, ) props = parse_properties(reason, cmp_result!=0, props_to_record) diff --git a/tests/codec_be_on_mr_nonselection/test_sba_bs_enc.py b/tests/codec_be_on_mr_nonselection/test_sba_bs_enc.py index ce99c55a27..3dd7e6dc67 100644 --- a/tests/codec_be_on_mr_nonselection/test_sba_bs_enc.py +++ b/tests/codec_be_on_mr_nonselection/test_sba_bs_enc.py @@ -108,6 +108,7 @@ def test_pca_enc( decoder_only, abs_tol, get_ssnr, + get_odg, ): pca = True tag = tag + fs + "c" @@ -165,6 +166,7 @@ def test_pca_enc( pca=pca, abs_tol=abs_tol, get_ssnr=get_ssnr, + get_odg=get_odg, ) @@ -199,6 +201,7 @@ def test_sba_enc_system( decoder_only, abs_tol, get_ssnr, + get_odg, ): if dtx == "1" and ivas_br not in ["13200", "16400", "24400", "32000", "64000"]: # skip high bitrates for DTX until DTX issue is resolved @@ -276,6 +279,7 @@ def test_sba_enc_system( get_mld_lim=get_mld_lim, abs_tol=abs_tol, get_ssnr=get_ssnr, + get_odg=get_odg, ) @@ -301,6 +305,7 @@ def test_spar_hoa2_enc_system( decoder_only, abs_tol, get_ssnr, + get_odg, ): fs = "48" dtx = "0" @@ -355,6 +360,7 @@ def test_spar_hoa2_enc_system( get_mld_lim=get_mld_lim, abs_tol=abs_tol, get_ssnr=get_ssnr, + get_odg=get_odg, ) @@ -380,6 +386,7 @@ def test_spar_hoa3_enc_system( decoder_only, abs_tol, get_ssnr, + get_odg, ): fs = "48" dtx = "0" @@ -434,6 +441,7 @@ def test_spar_hoa3_enc_system( get_mld_lim=get_mld_lim, abs_tol=abs_tol, get_ssnr=get_ssnr, + get_odg=get_odg, ) @@ -463,6 +471,7 @@ def test_sba_enc_BWforce_system( decoder_only, abs_tol, get_ssnr, + get_odg, ): if dtx == "1" and ivas_br not in ["32000", "64000"]: # skip high bitrates for DTX until DTX issue is resolved @@ -523,6 +532,7 @@ def test_sba_enc_BWforce_system( get_mld_lim=get_mld_lim, abs_tol=abs_tol, get_ssnr=get_ssnr, + get_odg=get_odg, ) @@ -686,6 +696,7 @@ def sba_dec( pca=False, abs_tol=0, get_ssnr=False, + get_odg=False, ): # -------- run cmd ------------ # sampling rate to BW mapping @@ -751,6 +762,7 @@ def sba_dec( mld_lim=get_mld_lim, abs_tol=abs_tol, get_ssnr=get_ssnr, + get_odg=get_odg, ) props = parse_properties(reason, cmp_result!=0, props_to_record) diff --git a/tests/conftest.py b/tests/conftest.py index 0d1c0cbcfd..7c4acd697f 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -42,7 +42,7 @@ import textwrap from pathlib import Path from subprocess import TimeoutExpired, run from typing import Optional, Union -from .constants import MLD_PATTERN, MAX_DIFF_PATTERN, SSNR_PATTERN, ODG_DIFF_PATTERN +from .constants import MLD_PATTERN, MAX_DIFF_PATTERN, SSNR_PATTERN, ODG_PATTERN logger = logging.getLogger(__name__) USE_LOGGER_FOR_DBG = False # current tests do not make use of the logger feature @@ -862,7 +862,7 @@ def parse_properties(text_to_parse: str, output_differs: bool, props_to_record: props["MIN_SSNR"] = min_ssnr props["MIN_SSNR_CHANNEL"] = min_ssnr_channel elif prop == "ODG": - odg_diffs = re.findall(ODG_DIFF_PATTERN, text_to_parse) + odg_diffs = re.findall(ODG_PATTERN, text_to_parse) max_odg_diff = max(odg_diffs) max_odg_diff_channel = odg_diffs.index(max_odg_diff) props[ diff --git a/tests/constants.py b/tests/constants.py index 14975bf0f3..cd0cb1a622 100644 --- a/tests/constants.py +++ b/tests/constants.py @@ -7,6 +7,6 @@ TESTV_DIR = SCRIPTS_DIR.joinpath("testv") # regex patterns for parsing the output from cmp_pcm -> mainly for BASOP ci MLD_PATTERN = r"MLD: ([\d\.]*)" MAX_DIFF_PATTERN = r"MAXIMUM ABS DIFF: (\d*)" -ODG_PATTERN = r"Objective Difference Grade: (-*\d*\.\d*)" -ODG_DIFF_PATTERN = r"ODG diff: (-*\d*\.\d*)" +ODG_PATTERN_PQEVALAUDIO = r"Objective Difference Grade: (-*\d*\.\d*)" +ODG_PATTERN = r"ODG diff: (-*\d*\.\d*)" SSNR_PATTERN = r"Channel \d* SSNR: (nan|[+-]*inf|[\d\.]*)" -- GitLab From db7ecb808f696ad3473b4552d6cd6de34f447a31 Mon Sep 17 00:00:00 2001 From: Jan Kiene Date: Thu, 4 Jul 2024 14:42:45 +0200 Subject: [PATCH 5/6] rename to MIN_ODG and adapt pages-related scripts --- ci/basop-pages/create_report_pages.py | 2 +- scripts/parse_xml_report.py | 2 +- tests/conftest.py | 4 ++-- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/ci/basop-pages/create_report_pages.py b/ci/basop-pages/create_report_pages.py index c849b160be..5a3737d532 100644 --- a/ci/basop-pages/create_report_pages.py +++ b/ci/basop-pages/create_report_pages.py @@ -92,7 +92,7 @@ ARROW_DOWN = '' # expected columns. actual columns are filtered from the incoming data later, this # is mainly for controlling the order in the output table -COLUMNS = ["testcase", "Result", "MLD", "MAXIMUM ABS DIFF", "MIN_SSNR"] +COLUMNS = ["testcase", "Result", "MLD", "MAXIMUM ABS DIFF", "MIN_SSNR", "MIN_ODG"] COLUMNS_GLOBAL = COLUMNS[:1] COLUMNS_DIFFERENTIAL = COLUMNS[1:] COLUMNS_DIFFERENTIAL_NOT_MLD = COLUMNS_DIFFERENTIAL[2:] diff --git a/scripts/parse_xml_report.py b/scripts/parse_xml_report.py index 4b61dc1a94..b0dc94c990 100644 --- a/scripts/parse_xml_report.py +++ b/scripts/parse_xml_report.py @@ -10,7 +10,7 @@ from xml.etree import ElementTree Parse a junit report and create a summary report. """ -PROPERTIES = ["MLD", "MAXIMUM ABS DIFF", "MIN_SSNR"] +PROPERTIES = ["MLD", "MAXIMUM ABS DIFF", "MIN_SSNR", "MIN_ODG"] # Main routine diff --git a/tests/conftest.py b/tests/conftest.py index 7c4acd697f..f57d07b597 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -866,10 +866,10 @@ def parse_properties(text_to_parse: str, output_differs: bool, props_to_record: max_odg_diff = max(odg_diffs) max_odg_diff_channel = odg_diffs.index(max_odg_diff) props[ - "MAX_ODG_DIFF" + "MIN_ODG" ] = max_odg_diff props[ - "MAX_ODG_DIFF_CHANNEL" + "MIN_ODG_CHANNEL" ] = max_odg_diff_channel return props -- GitLab From bdb65cbb941e3b5b7905960ab2fe9fcdcbea654d Mon Sep 17 00:00:00 2001 From: Jan Kiene Date: Thu, 4 Jul 2024 14:56:26 +0200 Subject: [PATCH 6/6] fix re pattern ad run formatter --- tests/conftest.py | 28 +++++++++++++++++----------- tests/constants.py | 2 +- 2 files changed, 18 insertions(+), 12 deletions(-) diff --git a/tests/conftest.py b/tests/conftest.py index f57d07b597..c5d827569f 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -580,11 +580,20 @@ class DecoderFrontend: raise ValueError(f'Wrong system "{system}"!') if not os.path.isfile(netsim_path): - raise FileNotFoundError(f"network simulator binary {netsim_path} not found!\n") + raise FileNotFoundError( + f"network simulator binary {netsim_path} not found!\n" + ) netsim_bitstream_path = input_bitstream_path.with_suffix(".netsimout") tracefile_path = input_bitstream_path.with_suffix(".netsimtrace") # TODO: need to check if the "1" works with every profile - netsim_command = [netsim_path, netsim_profile, input_bitstream_path, netsim_bitstream_path, tracefile_path, "1"] + netsim_command = [ + netsim_path, + netsim_profile, + input_bitstream_path, + netsim_bitstream_path, + tracefile_path, + "1", + ] print(netsim_command) try: run(netsim_command, check=True, cwd=run_dir) @@ -862,15 +871,12 @@ def parse_properties(text_to_parse: str, output_differs: bool, props_to_record: props["MIN_SSNR"] = min_ssnr props["MIN_SSNR_CHANNEL"] = min_ssnr_channel elif prop == "ODG": - odg_diffs = re.findall(ODG_PATTERN, text_to_parse) - max_odg_diff = max(odg_diffs) - max_odg_diff_channel = odg_diffs.index(max_odg_diff) - props[ - "MIN_ODG" - ] = max_odg_diff - props[ - "MIN_ODG_CHANNEL" - ] = max_odg_diff_channel + odgs = re.findall(ODG_PATTERN, text_to_parse) + print(odgs) + min_odg = min(odgs) + min_odg_channel = odgs.index(min_odg) + props["MIN_ODG"] = min_odg + props["MIN_ODG_CHANNEL"] = min_odg_channel return props diff --git a/tests/constants.py b/tests/constants.py index cd0cb1a622..e6ea1c1589 100644 --- a/tests/constants.py +++ b/tests/constants.py @@ -8,5 +8,5 @@ TESTV_DIR = SCRIPTS_DIR.joinpath("testv") MLD_PATTERN = r"MLD: ([\d\.]*)" MAX_DIFF_PATTERN = r"MAXIMUM ABS DIFF: (\d*)" ODG_PATTERN_PQEVALAUDIO = r"Objective Difference Grade: (-*\d*\.\d*)" -ODG_PATTERN = r"ODG diff: (-*\d*\.\d*)" +ODG_PATTERN = r"ODG: (-*\d*\.\d*)" SSNR_PATTERN = r"Channel \d* SSNR: (nan|[+-]*inf|[\d\.]*)" -- GitLab