From baf1e618f62aeea8f4da7c4fbd249f59eb086f36 Mon Sep 17 00:00:00 2001 From: "valentin.emiya" <valentin.emiya@lif.univ-mrs.fr> Date: Thu, 4 Jun 2020 10:56:04 +0200 Subject: [PATCH] add tests for experiment --- python/tffpy/experiments/exp_solve_tff.py | 2 ++ .../experiments/tests/test_exp_solve_tff.py | 33 +++++++++++++++++++ python/tffpy/scripts/script_exp_solve_tff.py | 2 ++ python/tffpy/tests/ci_config.py | 6 +++- python/tffpy/tf_fading.py | 2 +- 5 files changed, 43 insertions(+), 2 deletions(-) create mode 100644 python/tffpy/experiments/tests/test_exp_solve_tff.py diff --git a/python/tffpy/experiments/exp_solve_tff.py b/python/tffpy/experiments/exp_solve_tff.py index 2558156..179d011 100644 --- a/python/tffpy/experiments/exp_solve_tff.py +++ b/python/tffpy/experiments/exp_solve_tff.py @@ -112,6 +112,8 @@ class SolveTffExperiment(Experiment): data_params['wideband_src'] = 'car' problem_params['win_choice'] = ['gauss 64', 'hann 128'] problem_params['crop'] = 4096 + problem_params['delta_loc_db'] = 20 + problem_params['wb_to_loc_ratio_db'] = 16 solver_params['tolerance_arrf'] = 1e-2 solver_params['proba_arrf'] = 1 - 1e-2 diff --git a/python/tffpy/experiments/tests/test_exp_solve_tff.py b/python/tffpy/experiments/tests/test_exp_solve_tff.py new file mode 100644 index 0000000..5364e9f --- /dev/null +++ b/python/tffpy/experiments/tests/test_exp_solve_tff.py @@ -0,0 +1,33 @@ +# -*- coding: utf-8 -*- + +"""Test of the module :module:`tffpy.experiments.exp_solve_tff` + +.. moduleauthor:: Valentin Emiya +""" +import unittest + +import matplotlib.pyplot as plt + +from tffpy.experiments.exp_solve_tff import \ + SolveTffExperiment, create_and_run_light_experiment +from tffpy.tests.ci_config import create_config_files + + +class TestSolveTffExperiment(unittest.TestCase): + def setUp(self): + create_config_files() + + def test_light_experiment(self): + create_and_run_light_experiment() + + light_exp = SolveTffExperiment.get_experiment( + setting='light', force_reset=False) + for idt in range(light_exp.n_tasks): + light_exp.plot_task(idt=idt, fontsize=16) + plt.close('all') + light_exp.plot_results() + + def test_create_full_experiment(self): + experiment = SolveTffExperiment.get_experiment( + setting='full', force_reset=False) + experiment.display_status() diff --git a/python/tffpy/scripts/script_exp_solve_tff.py b/python/tffpy/scripts/script_exp_solve_tff.py index 25b8342..e94dfbc 100644 --- a/python/tffpy/scripts/script_exp_solve_tff.py +++ b/python/tffpy/scripts/script_exp_solve_tff.py @@ -1,9 +1,11 @@ # -*- coding: utf-8 -*- """ +Run this script to handle the main experiment :class:`SolveTffExperiment`. .. moduleauthor:: Valentin Emiya """ from yafe.utils import generate_oar_script + import matplotlib.pyplot as plt from tffpy.experiments.exp_solve_tff import \ diff --git a/python/tffpy/tests/ci_config.py b/python/tffpy/tests/ci_config.py index c47b4d1..4e41b8e 100644 --- a/python/tffpy/tests/ci_config.py +++ b/python/tffpy/tests/ci_config.py @@ -12,7 +12,8 @@ from yafe.utils import ConfigParser as YafeConfigParser from tffpy.utils import get_config_file, generate_config -if __name__ == '__main__': + +def create_config_files(): config_file = get_config_file() if not config_file.exists(): generate_config() @@ -37,3 +38,6 @@ if __name__ == '__main__': yafe_config_parser.set('USER', 'data_path', str(yafe_user_path)) yafe_config_parser.set('LOGGER', 'path', str(yafe_logger_path)) yafe_config_parser.write(open(yafe_config_file, 'w')) + +if __name__ == '__main__': + create_config_files() \ No newline at end of file diff --git a/python/tffpy/tf_fading.py b/python/tffpy/tf_fading.py index c0be148..28c3f80 100644 --- a/python/tffpy/tf_fading.py +++ b/python/tffpy/tf_fading.py @@ -1,6 +1,6 @@ # -*- coding: utf-8 -*- """ -Class :class:`GabMulTff` is the main object to solve a time-frequency fading +Class :class:`GabMulTff` is the main object to solve a time-frequency fading problem. .. moduleauthor:: Valentin Emiya -- GitLab