Skip to content

Commit

Permalink
tests/ParameterEstimationComposition: Reduce running time (#2753)
Browse files Browse the repository at this point in the history
Reduce the number of estimates by a factor of 40, it's enough to pass the test and it significantly reduces test running time.
Provide expected results for different optimization methods
  • Loading branch information
jvesely authored Jul 31, 2023
2 parents 70f0c57 + 3218ef9 commit c49c015
Showing 1 changed file with 7 additions and 9 deletions.
16 changes: 7 additions & 9 deletions tests/composition/test_parameterestimationcomposition.py
Original file line number Diff line number Diff line change
Expand Up @@ -125,15 +125,15 @@ def test_pec_run_input_formats(inputs_dict, error_msg):


@pytest.mark.parametrize(
"opt_method",
"opt_method, result",
[
"differential_evolution",
optuna.samplers.RandomSampler(),
optuna.samplers.CmaEsSampler(),
("differential_evolution", [0.010363518438648106]),
(optuna.samplers.RandomSampler(), [0.01]),
(optuna.samplers.CmaEsSampler(), [0.01]),
],
ids=["differential_evolultion", "optuna_random_sampler", "optuna_cmaes_sampler"],
)
def test_parameter_optimization_ddm(func_mode, opt_method):
def test_parameter_optimization_ddm(func_mode, opt_method, result):
"""Test parameter optimization of a DDM in integrator mode"""

if func_mode == "Python":
Expand Down Expand Up @@ -212,9 +212,7 @@ def reward_rate(sim_data):

ret = pec.run(inputs={comp: trial_inputs})

np.testing.assert_allclose(
pec.optimized_parameter_values, [0.010363518438648106], atol=1e-2
)
np.testing.assert_allclose(pec.optimized_parameter_values, result)


# func_mode is a hacky wa to get properly marked; Python, LLVM, and CUDA
Expand All @@ -229,7 +227,7 @@ def test_parameter_estimation_ddm_mle(func_mode):
# High-level parameters the impact performance of the test
num_trials = 50
time_step_size = 0.01
num_estimates = 40000
num_estimates = 1000

ddm_params = dict(
starting_value=0.0,
Expand Down

0 comments on commit c49c015

Please sign in to comment.