From feebfe33cc4fe83b29eab34ad3f8ff4d324f35d2 Mon Sep 17 00:00:00 2001 From: Archit Tamarapu Date: Tue, 12 Mar 2024 13:56:32 +0100 Subject: [PATCH 1/4] remove unused function from audiofile.py --- scripts/pyaudio3dtools/audiofile.py | 32 ----------------------------- 1 file changed, 32 deletions(-) diff --git a/scripts/pyaudio3dtools/audiofile.py b/scripts/pyaudio3dtools/audiofile.py index d3153e21db..e614bfbd49 100644 --- a/scripts/pyaudio3dtools/audiofile.py +++ b/scripts/pyaudio3dtools/audiofile.py @@ -36,7 +36,6 @@ import shutil import struct import subprocess as sp import warnings -from importlib import import_module from tempfile import TemporaryDirectory from typing import Optional, Tuple @@ -662,37 +661,6 @@ def loudnessinfo( return measured_loudness, scale_factor -def print_plot_play(x: np.ndarray, fs: int, text: Optional[str] = "") -> None: - """1. Prints information about an audio signal, 2. plots the waveform, and 3. Creates player - - Parameters - ---------- - x: np array - Input signal - fs: int - Input sampling rate - text: Optional[str] = '' - text to print - Returns - ------- - None - - """ - - plt = import_module("matplotlib.pyplot") - ipd = import_module("IPython.display") - - print("%s fs = %d, x.shape = %s, x.dtype = %s" % (text, fs, x.shape, x.dtype)) - plt.figure(figsize=(8, 2)) - plt.plot(x, color="gray") - plt.xlim([0, x.shape[0]]) - plt.xlabel("Time (samples)") - plt.ylabel("Amplitude") - plt.tight_layout() - plt.show() - ipd.display(ipd.Audio(data=x, rate=fs)) - - def get_wav_file_info(filename: str) -> dict: """ Get the format information from a WAV file. -- GitLab From 3ae50cb0ef76baac7f4aa7f8ff4b14c8be1284b6 Mon Sep 17 00:00:00 2001 From: Archit Tamarapu Date: Tue, 12 Mar 2024 14:01:30 +0100 Subject: [PATCH 2/4] fix unused imports and redundant f-strings --- ci/complexity_measurements/mergeNewsletterRam.py | 1 - ci/complexity_measurements/mergeNewsletterRom.py | 1 - scripts/batch_comp_audio.py | 3 +-- scripts/mem_analysis.py | 3 --- scripts/prepare_combined_format_inputs.py | 3 +-- scripts/pyaudio3dtools/__init__.py | 1 - scripts/pyaudio3dtools/audio3dtools.py | 5 +---- scripts/pyivastest/IvasBaseClass.py | 1 - scripts/pyivastest/IvasModeCollector.py | 2 -- scripts/pyivastest/IvasModeRunner.py | 2 -- scripts/pyivastest/__init__.py | 10 ---------- scripts/self_test.py | 2 -- tests/codec_be_on_mr_nonselection/test_param_file.py | 4 ++-- tests/codec_be_on_mr_nonselection/test_sba_bs_enc.py | 6 +++--- tests/codec_be_on_mr_selection/__init__.py | 2 +- tests/conftest.py | 3 +-- tests/create_short_testvectors.py | 2 +- tests/cut_pcm.py | 3 +-- tests/hrtf_binary_loading/constants.py | 2 +- tests/hrtf_binary_loading/test_codec_ROM_vs_file.py | 1 - tests/hrtf_binary_loading/utils.py | 5 ++--- tests/scale_pcm.py | 2 -- tests/split_rendering/constants.py | 8 -------- tests/split_rendering/utils.py | 2 +- tests/test_26444.py | 1 - tests/test_param_file_ltv.py | 4 ++-- 26 files changed, 18 insertions(+), 61 deletions(-) diff --git a/ci/complexity_measurements/mergeNewsletterRam.py b/ci/complexity_measurements/mergeNewsletterRam.py index 40b5f75c59..d578b51c56 100755 --- a/ci/complexity_measurements/mergeNewsletterRam.py +++ b/ci/complexity_measurements/mergeNewsletterRam.py @@ -29,7 +29,6 @@ # accordance with the laws of the Federal Republic of Germany excluding its conflict of law rules and # the United Nations Convention on Contracts on the International Sales of Goods. import csv -import re import sys newsletterFilename = "" diff --git a/ci/complexity_measurements/mergeNewsletterRom.py b/ci/complexity_measurements/mergeNewsletterRom.py index 0e75f26f58..b46e6c5570 100755 --- a/ci/complexity_measurements/mergeNewsletterRom.py +++ b/ci/complexity_measurements/mergeNewsletterRom.py @@ -29,7 +29,6 @@ # accordance with the laws of the Federal Republic of Germany excluding its conflict of law rules and # the United Nations Convention on Contracts on the International Sales of Goods. import csv -import re import sys newsletterFilename = "" diff --git a/scripts/batch_comp_audio.py b/scripts/batch_comp_audio.py index 6854f41f30..ce1f380c56 100755 --- a/scripts/batch_comp_audio.py +++ b/scripts/batch_comp_audio.py @@ -33,7 +33,6 @@ import argparse import concurrent.futures import os -import pathlib import re import shutil import subprocess @@ -132,7 +131,7 @@ def main(args): if num_files_diff > 0: print(f"{num_files_diff} files differ/don't exist") else: - print(f"All files are bitexact") + print("All files are bitexact") def compare_files(f, fol1, fol2, outputs_dict, tool): diff --git a/scripts/mem_analysis.py b/scripts/mem_analysis.py index e3f3d8afe4..18d1e3a554 100644 --- a/scripts/mem_analysis.py +++ b/scripts/mem_analysis.py @@ -1,10 +1,7 @@ #!/usr/bin/env python3 import argparse -import csv import os -import struct -import sys import matplotlib.pyplot as plt import numpy as np diff --git a/scripts/prepare_combined_format_inputs.py b/scripts/prepare_combined_format_inputs.py index c081b75bb1..bb406a30b6 100755 --- a/scripts/prepare_combined_format_inputs.py +++ b/scripts/prepare_combined_format_inputs.py @@ -33,8 +33,7 @@ __license__ = """ import os import shutil -import numpy as np -from pyaudio3dtools import audioarray, audiofile +from pyaudio3dtools import audiofile def main(): diff --git a/scripts/pyaudio3dtools/__init__.py b/scripts/pyaudio3dtools/__init__.py index ccf53c51e1..3df489f582 100644 --- a/scripts/pyaudio3dtools/__init__.py +++ b/scripts/pyaudio3dtools/__init__.py @@ -40,4 +40,3 @@ Imports functions class """ -from . import audioarray, audiofile, spatialaudioformat diff --git a/scripts/pyaudio3dtools/audio3dtools.py b/scripts/pyaudio3dtools/audio3dtools.py index 0fec5c6ce9..22c26e28e8 100755 --- a/scripts/pyaudio3dtools/audio3dtools.py +++ b/scripts/pyaudio3dtools/audio3dtools.py @@ -30,11 +30,8 @@ the United Nations Convention on Contracts on the International Sales of Goods. """ -import argparse import logging -import os -from pyaudio3dtools import audiofile, spatialaudioformat main_logger = logging.getLogger("__main__") logger = main_logger.getChild(__name__) @@ -43,7 +40,7 @@ logger.setLevel(logging.DEBUG) def main(): print( - f"These scripts have been deprecated! Please check out and use the latest version from https://forge.3gpp.org/rep/ivas-codec-pc/ivas-processing-scripts.git" + "These scripts have been deprecated! Please check out and use the latest version from https://forge.3gpp.org/rep/ivas-codec-pc/ivas-processing-scripts.git" ) diff --git a/scripts/pyivastest/IvasBaseClass.py b/scripts/pyivastest/IvasBaseClass.py index bad578f753..c7c734c5c9 100644 --- a/scripts/pyivastest/IvasBaseClass.py +++ b/scripts/pyivastest/IvasBaseClass.py @@ -30,7 +30,6 @@ the United Nations Convention on Contracts on the International Sales of Goods. """ -import filecmp import json import logging import logging.handlers diff --git a/scripts/pyivastest/IvasModeCollector.py b/scripts/pyivastest/IvasModeCollector.py index 3255dc3a8a..90274544dc 100644 --- a/scripts/pyivastest/IvasModeCollector.py +++ b/scripts/pyivastest/IvasModeCollector.py @@ -34,8 +34,6 @@ import json import logging import os import os.path -import platform -import re from copy import deepcopy from pyivastest import IvasBaseClass, constants diff --git a/scripts/pyivastest/IvasModeRunner.py b/scripts/pyivastest/IvasModeRunner.py index 27f013ee8d..41dd4d20ab 100644 --- a/scripts/pyivastest/IvasModeRunner.py +++ b/scripts/pyivastest/IvasModeRunner.py @@ -35,8 +35,6 @@ import json import logging import logging.handlers import os -import platform -import re import subprocess import threading import time diff --git a/scripts/pyivastest/__init__.py b/scripts/pyivastest/__init__.py index 5ab768973f..71ab3180d3 100644 --- a/scripts/pyivastest/__init__.py +++ b/scripts/pyivastest/__init__.py @@ -40,13 +40,3 @@ Imports functions class """ -from . import ( - IvasBaseClass, - IvasModeAnalyzer, - IvasModeCollector, - IvasModeRunner, - IvasScriptsCommon, - IvasSvnBuilder, - constants, - ivas_svn, -) diff --git a/scripts/self_test.py b/scripts/self_test.py index c41e199939..714366bcf1 100755 --- a/scripts/self_test.py +++ b/scripts/self_test.py @@ -32,8 +32,6 @@ import errno -import multiprocessing -import operator import os import platform import re 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 459964a186..9a1405c27e 100644 --- a/tests/codec_be_on_mr_nonselection/test_param_file.py +++ b/tests/codec_be_on_mr_nonselection/test_param_file.py @@ -357,9 +357,9 @@ def test_param_file_tests( metadata_differs = True except FileNotFoundError: if not dut_metadata_file.exists(): - print(f"DUT output metadata missing for expected file: " + md_file) + print("DUT output metadata missing for expected file: " + md_file) if not ref_metadata_file.exists(): - print(f"REF output metadata missing for expected file: " + md_file) + print("REF output metadata missing for expected file: " + md_file) metadata_differs = True if get_mld and get_mld_lim > 0: 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 4f4c1a3271..5782982e9d 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 @@ -542,15 +542,15 @@ def sba_enc( if gain_flag != -1: short_tag_ext += f"_Gain{gain_flag}" if SID == 1: - short_tag_ext += f"_SID" + short_tag_ext += "_SID" if pca: - short_tag_ext += f"_pca" + short_tag_ext += "_pca" # to avoid conflicting names in case of parallel test execution, differentiate all cases long_tag_ext = "" if gain_flag != -1: long_tag_ext += f"_Gain{gain_flag}" if SID == 1: - long_tag_ext += f"_SID" + long_tag_ext += "_SID" dut_pkt_file = f"{dut_out_dir}/{tag_out}{long_tag_ext}.192" ref_pkt_file = f"{ref_out_dir}/{tag_out}{short_tag_ext}.192" ref_pkt_file_dutenc = f"{ref_out_dir}/{tag_out}{short_tag_ext}_dutenc.192" diff --git a/tests/codec_be_on_mr_selection/__init__.py b/tests/codec_be_on_mr_selection/__init__.py index 2ee63a30a5..bf530e5ebc 100644 --- a/tests/codec_be_on_mr_selection/__init__.py +++ b/tests/codec_be_on_mr_selection/__init__.py @@ -174,7 +174,7 @@ def run_check( if not is_ref_creation: if compare_bitstream: if not is_be_to_ref(dut_bitstream): - pytest.fail(f"Bitstream file differs from reference") + pytest.fail("Bitstream file differs from reference") dut_bitstream_to_decoder = dut_bitstream if error_pattern is not None: diff --git a/tests/conftest.py b/tests/conftest.py index bbe16f4715..da56b79c05 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -37,10 +37,9 @@ import os from tests import testconfig import pytest import platform -import tempfile import textwrap from pathlib import Path -from subprocess import STDOUT, CalledProcessError, TimeoutExpired, run +from subprocess import TimeoutExpired, run from typing import Optional, Union logger = logging.getLogger(__name__) diff --git a/tests/create_short_testvectors.py b/tests/create_short_testvectors.py index d80a328c14..e51f018f45 100755 --- a/tests/create_short_testvectors.py +++ b/tests/create_short_testvectors.py @@ -67,7 +67,7 @@ def collect_files(file_ids): for f in TEST_VECTOR_DIR.iterdir() if f.suffix == ".wav" and any([id in f.name for id in file_ids]) - and not "_cut" in f.name + and "_cut" not in f.name ] return files diff --git a/tests/cut_pcm.py b/tests/cut_pcm.py index 644a2ba1bc..2abc86b624 100755 --- a/tests/cut_pcm.py +++ b/tests/cut_pcm.py @@ -47,7 +47,6 @@ import platform import sys from pathlib import Path -import numpy as np HERE = Path(__file__).parent.resolve() SCRIPTS_DIR = str(HERE.joinpath("../scripts").resolve()) @@ -81,7 +80,7 @@ def cut_samples( ) if sample_rate is None and not str(in_file).endswith(".wav"): - raise ValueError(f"For non-wav files, samplerate must be explicitly given") + raise ValueError("For non-wav files, samplerate must be explicitly given") elif sample_rate is None: # set to default of pyaudio3dtools.audiofile.readfile -> for wav files it will be ignored anyway sample_rate = 48000 diff --git a/tests/hrtf_binary_loading/constants.py b/tests/hrtf_binary_loading/constants.py index 1524e9bf57..e2f8523106 100644 --- a/tests/hrtf_binary_loading/constants.py +++ b/tests/hrtf_binary_loading/constants.py @@ -33,7 +33,7 @@ import re from pathlib import Path -from tests.renderer.constants import OUTPUT_FORMATS_BINAURAL, SCRIPTS_DIR, TESTV_DIR +from tests.renderer.constants import SCRIPTS_DIR, TESTV_DIR TESTS_DIR = Path(__file__).parent diff --git a/tests/hrtf_binary_loading/test_codec_ROM_vs_file.py b/tests/hrtf_binary_loading/test_codec_ROM_vs_file.py index c66792c653..26a5e269d3 100644 --- a/tests/hrtf_binary_loading/test_codec_ROM_vs_file.py +++ b/tests/hrtf_binary_loading/test_codec_ROM_vs_file.py @@ -37,7 +37,6 @@ from tests.hrtf_binary_loading.utils import * from .constants import ( HRTF_TAGS, MC_BITRATE_FOR_FORMAT, - HRTF_TAG_DIFF_FROM_ROM, HRTF_TAG_SAME_AS_ROM, ) diff --git a/tests/hrtf_binary_loading/utils.py b/tests/hrtf_binary_loading/utils.py index 85d55a34d3..af150defb2 100644 --- a/tests/hrtf_binary_loading/utils.py +++ b/tests/hrtf_binary_loading/utils.py @@ -33,12 +33,11 @@ import os import sys import uuid -from typing import Dict, Optional +from typing import Optional import pytest -from tests.renderer.compare_audio import compare_audio_arrays -from tests.renderer.utils import check_BE, run_cmd, run_renderer, test_info +from tests.renderer.utils import check_BE, run_cmd, run_renderer from .constants import * diff --git a/tests/scale_pcm.py b/tests/scale_pcm.py index 614e8cef3f..356cdd90e1 100755 --- a/tests/scale_pcm.py +++ b/tests/scale_pcm.py @@ -10,9 +10,7 @@ sys.path.append(os.path.join(os.path.dirname(THIS_PATH), "../scripts")) import concurrent.futures -import numpy as np import pyaudio3dtools -import pyivastest def scale_folder(folder, factor): diff --git a/tests/split_rendering/constants.py b/tests/split_rendering/constants.py index 623d569376..73346c2980 100644 --- a/tests/split_rendering/constants.py +++ b/tests/split_rendering/constants.py @@ -32,14 +32,6 @@ from pathlib import Path -from tests.renderer.constants import ( - BIN_SUFFIX_MERGETARGET, - CUSTOM_LS_TO_TEST, - FORMAT_TO_FILE_COMPARETEST, - FORMAT_TO_FILE_SMOKETEST, - FORMAT_TO_METADATA_FILES, - METADATA_SCENES_TO_TEST, -) """ Set up paths """ TESTS_DIR = Path(__file__).parent diff --git a/tests/split_rendering/utils.py b/tests/split_rendering/utils.py index 3b37109e91..d5a27662f2 100644 --- a/tests/split_rendering/utils.py +++ b/tests/split_rendering/utils.py @@ -38,7 +38,7 @@ from typing import Tuple import numpy as np import pytest -from tests.renderer.utils import check_BE, run_cmd, test_info +from tests.renderer.utils import check_BE, run_cmd from tests.split_rendering.constants import * sys.path.append(SCRIPTS_DIR) diff --git a/tests/test_26444.py b/tests/test_26444.py index 3bcef2567a..c413be81e4 100644 --- a/tests/test_26444.py +++ b/tests/test_26444.py @@ -35,7 +35,6 @@ Execute tests specified via a parameter file. import filecmp import os import subprocess -from pathlib import Path import pytest diff --git a/tests/test_param_file_ltv.py b/tests/test_param_file_ltv.py index 44c6a388f8..41dfeae30e 100644 --- a/tests/test_param_file_ltv.py +++ b/tests/test_param_file_ltv.py @@ -355,9 +355,9 @@ def test_param_file_tests( metadata_differs = True except FileNotFoundError: if not dut_metadata_file.exists(): - print(f"DUT output metadata missing for expected file: " + md_file) + print("DUT output metadata missing for expected file: " + md_file) if not ref_metadata_file.exists(): - print(f"REF output metadata missing for expected file: " + md_file) + print("REF output metadata missing for expected file: " + md_file) metadata_differs = True if output_differs or metadata_differs: -- GitLab From 628460cbe4d69d90016ba988387903cbf21e96cb Mon Sep 17 00:00:00 2001 From: Archit Tamarapu Date: Tue, 12 Mar 2024 14:09:59 +0100 Subject: [PATCH 3/4] remove leftover debugging line --- tests/renderer/utils.py | 1 - 1 file changed, 1 deletion(-) diff --git a/tests/renderer/utils.py b/tests/renderer/utils.py index 52d1ccf19e..a538df7ee8 100644 --- a/tests/renderer/utils.py +++ b/tests/renderer/utils.py @@ -55,7 +55,6 @@ def test_info(request): def run_cmd(cmd, env=None): logging.info(f"\nRunning command\n{' '.join(cmd)}\n") - cmdJoin = " ".join(cmd) try: sp.run(cmd, check=True, capture_output=True, text=True, env=env) except sp.CalledProcessError as e: -- GitLab From 84bf1c5e26686a5204aaf0cacf06aa02d4a79712 Mon Sep 17 00:00:00 2001 From: Archit Tamarapu Date: Wed, 13 Mar 2024 10:26:02 +0100 Subject: [PATCH 4/4] [revert] incorrectly removed imports --- scripts/pyivastest/__init__.py | 10 ++++++++++ tests/hrtf_binary_loading/constants.py | 2 +- tests/hrtf_binary_loading/test_codec_ROM_vs_file.py | 1 + tests/hrtf_binary_loading/utils.py | 2 +- tests/split_rendering/constants.py | 8 ++++++++ tests/split_rendering/utils.py | 2 +- 6 files changed, 22 insertions(+), 3 deletions(-) diff --git a/scripts/pyivastest/__init__.py b/scripts/pyivastest/__init__.py index 71ab3180d3..5ab768973f 100644 --- a/scripts/pyivastest/__init__.py +++ b/scripts/pyivastest/__init__.py @@ -40,3 +40,13 @@ Imports functions class """ +from . import ( + IvasBaseClass, + IvasModeAnalyzer, + IvasModeCollector, + IvasModeRunner, + IvasScriptsCommon, + IvasSvnBuilder, + constants, + ivas_svn, +) diff --git a/tests/hrtf_binary_loading/constants.py b/tests/hrtf_binary_loading/constants.py index e2f8523106..1524e9bf57 100644 --- a/tests/hrtf_binary_loading/constants.py +++ b/tests/hrtf_binary_loading/constants.py @@ -33,7 +33,7 @@ import re from pathlib import Path -from tests.renderer.constants import SCRIPTS_DIR, TESTV_DIR +from tests.renderer.constants import OUTPUT_FORMATS_BINAURAL, SCRIPTS_DIR, TESTV_DIR TESTS_DIR = Path(__file__).parent diff --git a/tests/hrtf_binary_loading/test_codec_ROM_vs_file.py b/tests/hrtf_binary_loading/test_codec_ROM_vs_file.py index 26a5e269d3..c66792c653 100644 --- a/tests/hrtf_binary_loading/test_codec_ROM_vs_file.py +++ b/tests/hrtf_binary_loading/test_codec_ROM_vs_file.py @@ -37,6 +37,7 @@ from tests.hrtf_binary_loading.utils import * from .constants import ( HRTF_TAGS, MC_BITRATE_FOR_FORMAT, + HRTF_TAG_DIFF_FROM_ROM, HRTF_TAG_SAME_AS_ROM, ) diff --git a/tests/hrtf_binary_loading/utils.py b/tests/hrtf_binary_loading/utils.py index af150defb2..c1b34c57cd 100644 --- a/tests/hrtf_binary_loading/utils.py +++ b/tests/hrtf_binary_loading/utils.py @@ -37,7 +37,7 @@ from typing import Optional import pytest -from tests.renderer.utils import check_BE, run_cmd, run_renderer +from tests.renderer.utils import check_BE, run_cmd, run_renderer, test_info from .constants import * diff --git a/tests/split_rendering/constants.py b/tests/split_rendering/constants.py index 73346c2980..623d569376 100644 --- a/tests/split_rendering/constants.py +++ b/tests/split_rendering/constants.py @@ -32,6 +32,14 @@ from pathlib import Path +from tests.renderer.constants import ( + BIN_SUFFIX_MERGETARGET, + CUSTOM_LS_TO_TEST, + FORMAT_TO_FILE_COMPARETEST, + FORMAT_TO_FILE_SMOKETEST, + FORMAT_TO_METADATA_FILES, + METADATA_SCENES_TO_TEST, +) """ Set up paths """ TESTS_DIR = Path(__file__).parent diff --git a/tests/split_rendering/utils.py b/tests/split_rendering/utils.py index d5a27662f2..3b37109e91 100644 --- a/tests/split_rendering/utils.py +++ b/tests/split_rendering/utils.py @@ -38,7 +38,7 @@ from typing import Tuple import numpy as np import pytest -from tests.renderer.utils import check_BE, run_cmd +from tests.renderer.utils import check_BE, run_cmd, test_info from tests.split_rendering.constants import * sys.path.append(SCRIPTS_DIR) -- GitLab