Commit 734142ae authored by Archit Tamarapu's avatar Archit Tamarapu
Browse files

remove random sampling in test_renderer.py - exhaustive run takes ~5s for 312 tests

parent c87f0714
Loading
Loading
Loading
Loading
Loading
+30 −32
Original line number Diff line number Diff line
@@ -27,31 +27,29 @@
"""


import random
import pytest

from .utils import *

random.seed(42)

""" Ambisonics """


@pytest.mark.parametrize("out_fmt", random.sample(OUTPUT_FORMATS[2:], 2))
@pytest.mark.parametrize("in_fmt", random.sample(INPUT_FORMATS_AMBI, 1))
@pytest.mark.parametrize("out_fmt", OUTPUT_FORMATS[2:])
@pytest.mark.parametrize("in_fmt", INPUT_FORMATS_AMBI)
def test_ambisonics(test_info, in_fmt, out_fmt):
    run_renderer(in_fmt, out_fmt)


@pytest.mark.parametrize("out_fmt", OUTPUT_FORMATS_BINAURAL)
@pytest.mark.parametrize("in_fmt", random.sample(INPUT_FORMATS_AMBI, 1))
@pytest.mark.parametrize("in_fmt", INPUT_FORMATS_AMBI)
def test_ambisonics_binaural_static(test_info, in_fmt, out_fmt):
    run_renderer(in_fmt, out_fmt)


@pytest.mark.parametrize("trj_file", random.sample(HR_TRAJECTORIES_TO_TEST, 1))
@pytest.mark.parametrize("trj_file", HR_TRAJECTORIES_TO_TEST)
@pytest.mark.parametrize("out_fmt", OUTPUT_FORMATS_BINAURAL)
@pytest.mark.parametrize("in_fmt", random.sample(INPUT_FORMATS_AMBI, 1))
@pytest.mark.parametrize("in_fmt", INPUT_FORMATS_AMBI)
def test_ambisonics_binaural_headrotation(test_info, in_fmt, out_fmt, trj_file):
    run_renderer(
        in_fmt,
@@ -63,14 +61,14 @@ def test_ambisonics_binaural_headrotation(test_info, in_fmt, out_fmt, trj_file):
""" Multichannel """


@pytest.mark.parametrize("out_fmt", random.sample(OUTPUT_FORMATS[2:], 2))
@pytest.mark.parametrize("in_fmt", random.sample(INPUT_FORMATS_MC, 2))
@pytest.mark.parametrize("out_fmt", OUTPUT_FORMATS[2:])
@pytest.mark.parametrize("in_fmt", INPUT_FORMATS_MC)
def test_multichannel(test_info, in_fmt, out_fmt):
    run_renderer(in_fmt, out_fmt)


@pytest.mark.parametrize("out_fmt", OUTPUT_FORMATS_BINAURAL)
@pytest.mark.parametrize("in_fmt", random.sample(INPUT_FORMATS_MC, 2))
@pytest.mark.parametrize("in_fmt", INPUT_FORMATS_MC)
def test_multichannel_binaural_static(test_info, in_fmt, out_fmt):
    if in_fmt in ["MONO", "STEREO"]:
        pytest.skip("MONO or STEREO to Binaural rendering unsupported")
@@ -78,9 +76,9 @@ def test_multichannel_binaural_static(test_info, in_fmt, out_fmt):
    run_renderer(in_fmt, out_fmt)


@pytest.mark.parametrize("trj_file", random.sample(HR_TRAJECTORIES_TO_TEST, 1))
@pytest.mark.parametrize("trj_file", HR_TRAJECTORIES_TO_TEST)
@pytest.mark.parametrize("out_fmt", OUTPUT_FORMATS_BINAURAL)
@pytest.mark.parametrize("in_fmt", random.sample(INPUT_FORMATS_MC, 2))
@pytest.mark.parametrize("in_fmt", INPUT_FORMATS_MC)
def test_multichannel_binaural_headrotation(test_info, in_fmt, out_fmt, trj_file):
    if in_fmt in ["MONO", "STEREO"]:
        pytest.skip("MONO or STEREO to Binaural rendering unsupported")
@@ -102,14 +100,14 @@ def test_multichannel_binaural_headrotation(test_info, in_fmt, out_fmt, trj_file
""" ISM """


@pytest.mark.parametrize("out_fmt", random.sample(OUTPUT_FORMATS[2:], 2))
@pytest.mark.parametrize("in_fmt", random.sample(INPUT_FORMATS_ISM, 2))
@pytest.mark.parametrize("out_fmt", OUTPUT_FORMATS[2:])
@pytest.mark.parametrize("in_fmt", INPUT_FORMATS_ISM)
def test_ism(test_info, in_fmt, out_fmt):
    run_renderer(in_fmt, out_fmt, in_meta_files=FORMAT_TO_METADATA_FILES[in_fmt])


@pytest.mark.parametrize("out_fmt", OUTPUT_FORMATS_BINAURAL)
@pytest.mark.parametrize("in_fmt", random.sample(INPUT_FORMATS_ISM, 2))
@pytest.mark.parametrize("in_fmt", INPUT_FORMATS_ISM)
def test_ism_binaural_static(test_info, in_fmt, out_fmt):
    try:
        in_meta_files = FORMAT_TO_METADATA_FILES[in_fmt]
@@ -122,9 +120,9 @@ def test_ism_binaural_static(test_info, in_fmt, out_fmt):
        run_renderer(in_fmt, out_fmt, in_meta_files=in_meta_files)


@pytest.mark.parametrize("trj_file", random.sample(HR_TRAJECTORIES_TO_TEST, 1))
@pytest.mark.parametrize("trj_file", HR_TRAJECTORIES_TO_TEST)
@pytest.mark.parametrize("out_fmt", OUTPUT_FORMATS_BINAURAL)
@pytest.mark.parametrize("in_fmt", random.sample(INPUT_FORMATS_ISM, 2))
@pytest.mark.parametrize("in_fmt", INPUT_FORMATS_ISM)
def test_ism_binaural_headrotation(test_info, in_fmt, out_fmt, trj_file):
    try:
        in_meta_files = FORMAT_TO_METADATA_FILES[in_fmt]
@@ -150,8 +148,8 @@ def test_ism_binaural_headrotation(test_info, in_fmt, out_fmt, trj_file):
""" MASA """


@pytest.mark.parametrize("out_fmt", random.sample(OUTPUT_FORMATS[2:], 2))
@pytest.mark.parametrize("in_fmt", random.sample(INPUT_FORMATS_MASA, 1))
@pytest.mark.parametrize("out_fmt", OUTPUT_FORMATS[2:])
@pytest.mark.parametrize("in_fmt", INPUT_FORMATS_MASA)
def test_masa(test_info, in_fmt, out_fmt):
    # # TODO: implement MASA in Python, compare BE
    # compare_renderer_vs_pyscripts( test_info, in_fmt, out_fmt, in_meta_files=FORMAT_TO_METADATA_FILES[in_fmt]
@@ -160,8 +158,8 @@ def test_masa(test_info, in_fmt, out_fmt):


# MASA inputs not supported yet
# @pytest.mark.parametrize("out_fmt", random.sample(OUTPUT_FORMATS, 2))
# @pytest.mark.parametrize("in_fmt", random.sample(METADATA_SCENES_TO_TEST_NO_BE, 2))
# @pytest.mark.parametrize("out_fmt", OUTPUT_FORMATS)
# @pytest.mark.parametrize("in_fmt", METADATA_SCENES_TO_TEST_NO_BE)
# def test_metadata_masa(test_info, in_fmt, out_fmt):
#     # TODO: unify with test_metadata once Python supports MASA
#     cut, cut_fs = run_renderer(
@@ -174,14 +172,14 @@ def test_masa(test_info, in_fmt, out_fmt):
""" Custom loudspeaker layouts """


@pytest.mark.parametrize("out_fmt", random.sample(OUTPUT_FORMATS[2:], 2))
@pytest.mark.parametrize("in_layout", random.sample(CUSTOM_LS_TO_TEST, 1))
@pytest.mark.parametrize("out_fmt", OUTPUT_FORMATS[2:])
@pytest.mark.parametrize("in_layout", CUSTOM_LS_TO_TEST)
def test_custom_ls_input(test_info, in_layout, out_fmt):
    run_renderer(CUSTOM_LAYOUT_DIR.joinpath(f"{in_layout}.txt"), out_fmt)


@pytest.mark.parametrize("out_fmt", random.sample(CUSTOM_LS_TO_TEST, 1))
@pytest.mark.parametrize("in_fmt", random.sample(OUTPUT_FORMATS[2:], 2))
@pytest.mark.parametrize("out_fmt", CUSTOM_LS_TO_TEST)
@pytest.mark.parametrize("in_fmt", OUTPUT_FORMATS[2:])
def test_custom_ls_output(test_info, in_fmt, out_fmt):
    run_renderer(
        in_fmt,
@@ -189,8 +187,8 @@ def test_custom_ls_output(test_info, in_fmt, out_fmt):
    )


@pytest.mark.parametrize("out_fmt", random.sample(CUSTOM_LS_TO_TEST, 1))
@pytest.mark.parametrize("in_fmt", random.sample(CUSTOM_LS_TO_TEST, 1))
@pytest.mark.parametrize("out_fmt", CUSTOM_LS_TO_TEST)
@pytest.mark.parametrize("in_fmt", CUSTOM_LS_TO_TEST)
def test_custom_ls_input_output(test_info, in_fmt, out_fmt):
    run_renderer(
        CUSTOM_LAYOUT_DIR.joinpath(f"{in_fmt}.txt"),
@@ -199,7 +197,7 @@ def test_custom_ls_input_output(test_info, in_fmt, out_fmt):


@pytest.mark.parametrize("out_fmt", OUTPUT_FORMATS_BINAURAL)
@pytest.mark.parametrize("in_layout", random.sample(CUSTOM_LS_TO_TEST, 2))
@pytest.mark.parametrize("in_layout", CUSTOM_LS_TO_TEST)
def test_custom_ls_input_binaural(test_info, in_layout, out_fmt):
    run_renderer(
        CUSTOM_LAYOUT_DIR.joinpath(f"{in_layout}.txt"),
@@ -207,9 +205,9 @@ def test_custom_ls_input_binaural(test_info, in_layout, out_fmt):
    )


@pytest.mark.parametrize("trj_file", random.sample(HR_TRAJECTORIES_TO_TEST, 1))
@pytest.mark.parametrize("trj_file", HR_TRAJECTORIES_TO_TEST)
@pytest.mark.parametrize("out_fmt", OUTPUT_FORMATS_BINAURAL)
@pytest.mark.parametrize("in_layout", random.sample(CUSTOM_LS_TO_TEST, 2))
@pytest.mark.parametrize("in_layout", CUSTOM_LS_TO_TEST)
def test_custom_ls_input_binaural_headrotation(test_info, in_layout, out_fmt, trj_file):
    run_renderer(
        CUSTOM_LAYOUT_DIR.joinpath(f"{in_layout}.txt"),
@@ -221,8 +219,8 @@ def test_custom_ls_input_binaural_headrotation(test_info, in_layout, out_fmt, tr
""" Metadata / scene description input """


@pytest.mark.parametrize("out_fmt", random.sample(OUTPUT_FORMATS[2:], 1))
@pytest.mark.parametrize("in_fmt", random.sample(METADATA_SCENES_TO_TEST, 1))
@pytest.mark.parametrize("out_fmt", OUTPUT_FORMATS[2:])
@pytest.mark.parametrize("in_fmt", METADATA_SCENES_TO_TEST)
def test_metadata(test_info, in_fmt, out_fmt):
    run_renderer(
        "META",