From 09f13d9a53a0d51cb357485bf1fd9de57d506933 Mon Sep 17 00:00:00 2001 From: Jungtaek Kim Date: Mon, 18 Nov 2024 02:12:38 -0500 Subject: [PATCH] Update tests --- tests/common/test_bo_bo_w_gp.py | 16 +++++++++++++++- tests/common/test_bo_bo_w_tp.py | 16 +++++++++++++++- 2 files changed, 30 insertions(+), 2 deletions(-) diff --git a/tests/common/test_bo_bo_w_gp.py b/tests/common/test_bo_bo_w_gp.py index ef5c08b..f72b317 100644 --- a/tests/common/test_bo_bo_w_gp.py +++ b/tests/common/test_bo_bo_w_gp.py @@ -581,7 +581,7 @@ def test_optimize_str_optimize_method_bo(): Y = np.random.randn(num_X, 1) model_bo = BO(arr_range_1, str_optimizer_method_bo="L-BFGS-B") - next_point, dict_info = model_bo.optimize(X, Y) + next_point, dict_info = model_bo.optimize(X, Y, seed=42) next_points = dict_info["next_points"] acquisitions = dict_info["acquisitions"] cov_X_X = dict_info["cov_X_X"] @@ -607,6 +607,12 @@ def test_optimize_str_optimize_method_bo(): assert next_points.shape[1] == dim_X assert next_points.shape[0] == acquisitions.shape[0] + print(next_point) + for elem in next_point: + print(elem) + truth_next_point = np.array([7.635218604824165, -2.0, 4.021317101319325]) + np.testing.assert_allclose(next_point, truth_next_point) + model_bo = BO(arr_range_1, str_optimizer_method_bo="DIRECT") next_point, dict_info = model_bo.optimize(X, Y) next_points = dict_info["next_points"] @@ -634,6 +640,10 @@ def test_optimize_str_optimize_method_bo(): assert next_points.shape[1] == dim_X assert next_points.shape[0] == acquisitions.shape[0] + print(next_point) + for elem in next_point: + print(elem) + model_bo = BO(arr_range_1, str_optimizer_method_bo="CMA-ES") next_point, dict_info = model_bo.optimize(X, Y) next_points = dict_info["next_points"] @@ -661,6 +671,10 @@ def test_optimize_str_optimize_method_bo(): assert next_points.shape[1] == dim_X assert next_points.shape[0] == acquisitions.shape[0] + print(next_point) + for elem in next_point: + print(elem) + def test_optimize_str_mlm_method(): np.random.seed(42) diff --git a/tests/common/test_bo_bo_w_tp.py b/tests/common/test_bo_bo_w_tp.py index 17606a3..8a121e0 100644 --- a/tests/common/test_bo_bo_w_tp.py +++ b/tests/common/test_bo_bo_w_tp.py @@ -570,7 +570,7 @@ def test_optimize_str_optimize_method_bo(): Y = np.random.randn(num_X, 1) model_bo = BO(arr_range_1, str_optimizer_method_bo="L-BFGS-B") - next_point, dict_info = model_bo.optimize(X, Y) + next_point, dict_info = model_bo.optimize(X, Y, seed=42) next_points = dict_info["next_points"] acquisitions = dict_info["acquisitions"] cov_X_X = dict_info["cov_X_X"] @@ -596,6 +596,12 @@ def test_optimize_str_optimize_method_bo(): assert next_points.shape[1] == dim_X assert next_points.shape[0] == acquisitions.shape[0] + print(next_point) + for elem in next_point: + print(elem) + truth_next_point = np.array([7.638093905542978, -2.0, 3.9619470988529613]) + np.testing.assert_allclose(next_point, truth_next_point) + model_bo = BO(arr_range_1, str_optimizer_method_bo="DIRECT") next_point, dict_info = model_bo.optimize(X, Y) next_points = dict_info["next_points"] @@ -623,6 +629,10 @@ def test_optimize_str_optimize_method_bo(): assert next_points.shape[1] == dim_X assert next_points.shape[0] == acquisitions.shape[0] + print(next_point) + for elem in next_point: + print(elem) + model_bo = BO(arr_range_1, str_optimizer_method_bo="CMA-ES") next_point, dict_info = model_bo.optimize(X, Y) next_points = dict_info["next_points"] @@ -650,6 +660,10 @@ def test_optimize_str_optimize_method_bo(): assert next_points.shape[1] == dim_X assert next_points.shape[0] == acquisitions.shape[0] + print(next_point) + for elem in next_point: + print(elem) + def test_optimize_use_ard(): np.random.seed(42)