Commit 9a6d2967 authored by Jan Kiene's avatar Jan Kiene
Browse files

cleanup and make parametrization more readable

parent a9be5aa0
Loading
Loading
Loading
Loading
+4 −8
Original line number Diff line number Diff line
@@ -34,7 +34,7 @@ import os
import filecmp
from pathlib import Path
import subprocess
from .constants import OUTPUT_MODES_AND_OPTIONS_FOR_EXPERIMENT
from .constants import OUTPUT_MODES_AND_OPTIONS_FOR_EXPERIMENT, DTX_ON, FER_5PERC

HERE = Path(__file__).parent
# set environment variables in CI job
@@ -70,17 +70,13 @@ def get_testvectors_for_exp_cat_and_testset(
    if experiment in MASA_TESTS:
        metadata.append(TESTV_PATH.joinpath(fname + ".met"))

    print(metadata)

    return signal, metadata


def get_out_bitstream_and_synthesis_name(input_signal, bitrate, dtx, fer):
    dtx_str = "DTXon" if dtx else "DTXoff"
    fer_str = "FER_5perc" if fer else "FER_0perc"
    suffix = [".192", ".wav"]
    return [
        DUT_PATH.joinpath(f"{input_signal.stem}-{bitrate}bps-{dtx_str}-{fer_str}{s}")
        DUT_PATH.joinpath(f"{input_signal.stem}-{bitrate}bps-{dtx}-{fer}{s}")
        for s in suffix
    ]

@@ -126,7 +122,7 @@ def run_check(
    )
    error_pattern = (
        get_error_pattern_for_exp_cat_and_testset(experiment, category, testset)
        if fer
        if fer == FER_5PERC
        else None
    )

@@ -147,7 +143,7 @@ def run_check(
        sampling_rate,
        testv,
        dut_bitstream,
        dtx_mode=dtx,
        dtx_mode=True if dtx == DTX_ON else False,
        add_option_list=options + [str(f) for f in metadata],
    )

+23 −17
Original line number Diff line number Diff line
@@ -32,6 +32,12 @@ from itertools import product
from typing import Union, List


DTX_ON = "DTXon"
DTX_OFF = "DTXoff"
FER_5PERC = "FER_5perc"
FER_0PERC = "FER_0perc"


class ExperimentParams:
    """
    Class to bundle the parameters for the experiments. Main purpose is to make things more readable over
@@ -44,11 +50,11 @@ class ExperimentParams:
        n_conditions: int,
        bitrates: List[int],
        testsets: List[str],
        dtx: Union[List[bool], bool] = False,
        fer: Union[List[bool], bool] = False,
        dtx: Union[List[str], str] = DTX_OFF,
        fer: Union[List[str], str] = FER_0PERC,
    ):
        dtx = n_conditions * [dtx] if isinstance(dtx, bool) else dtx
        fer = n_conditions * [fer] if isinstance(fer, bool) else fer
        dtx = n_conditions * [dtx] if isinstance(dtx, str) else dtx
        fer = n_conditions * [fer] if isinstance(fer, str) else fer
        assert (
            len(bitrates) == n_conditions
            and len(testsets) == 2
@@ -94,8 +100,8 @@ P800_PARAMS = [
            24400,
            13200,
        ],
        dtx=10 * [False] + 2 * [True],
        fer=5 * [False] + 5 * [True] + [False, True],
        dtx=10 * [DTX_OFF] + 2 * [DTX_ON],
        fer=5 * [FER_0PERC] + 5 * [FER_5PERC] + [FER_0PERC, FER_5PERC],
        testsets=["a", "d"],
    ),
    ExperimentParams(
@@ -114,7 +120,7 @@ P800_PARAMS = [
            32000,
            48000,
        ],
        dtx=6 * [False] + 5 * [True],
        dtx=6 * [DTX_OFF] + 5 * [DTX_ON],
        testsets=["b", "d"],
    ),
    ExperimentParams(
@@ -135,8 +141,8 @@ P800_PARAMS = [
            24400,
            13200,
        ],
        dtx=11 * [False] + 2 * [True],
        fer=6 * [False] + 5 * [True] + [False, True],
        dtx=11 * [DTX_OFF] + 2 * [DTX_ON],
        fer=6 * [FER_0PERC] + 5 * [FER_5PERC] + [FER_0PERC, FER_5PERC],
        testsets=["a", "d"],
    ),
    ExperimentParams(
@@ -157,7 +163,7 @@ P800_PARAMS = [
            80000,
            96000,
        ],
        fer=7 * [False] + 6 * [True],
        fer=7 * [FER_0PERC] + 6 * [FER_5PERC],
        testsets=["a", "c"],
    ),
    ExperimentParams(
@@ -178,7 +184,7 @@ P800_PARAMS = [
            64000,
            80000,
        ],
        dtx=7 * [False] + 6 * [True],
        dtx=7 * [DTX_OFF] + 6 * [DTX_ON],
        testsets=["a", "b"],
    ),
    ExperimentParams(
@@ -199,8 +205,8 @@ P800_PARAMS = [
            16400,
            24400,
        ],
        dtx=10 * [False] + 3 * [True],
        fer=6 * [False] + 4 * [True] + 3 * [False],
        dtx=10 * [DTX_OFF] + 3 * [DTX_ON],
        fer=6 * [FER_0PERC] + 4 * [FER_5PERC] + 3 * [FER_0PERC],
        testsets=["a", "c"],
    ),
    ExperimentParams(
@@ -221,8 +227,8 @@ P800_PARAMS = [
            32000,
            48000,
        ],
        dtx=9 * [False] + 4 * [True],
        fer=5 * [False] + 4 * [True] + 4 * [False],
        dtx=9 * [DTX_OFF] + 4 * [DTX_ON],
        fer=5 * [FER_0PERC] + 4 * [FER_5PERC] + 4 * [FER_0PERC],
        testsets=["a", "d"],
    ),
    ExperimentParams(
@@ -242,7 +248,7 @@ P800_PARAMS = [
            48000,
            64000,
        ],
        fer=7 * [False] + 5 * [True],
        fer=7 * [FER_0PERC] + 5 * [FER_5PERC],
        testsets=["a", "b"],
    ),
    ExperimentParams(
@@ -263,7 +269,7 @@ P800_PARAMS = [
            48000,
            64000,
        ],
        dtx=7 * [False] + 6 * [True],
        dtx=7 * [DTX_OFF] + 6 * [DTX_ON],
        testsets=["a", "d"],
    ),
]