From 4cc4631fe2a248952dfbd8627a7a43e5c0953cb7 Mon Sep 17 00:00:00 2001 From: relf Date: Fri, 24 Nov 2023 09:44:11 +0100 Subject: [PATCH] Fix test values when ConfigSpace not installed --- smt/applications/tests/test_ego.py | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/smt/applications/tests/test_ego.py b/smt/applications/tests/test_ego.py index b0af816df..a2a7e7d9c 100644 --- a/smt/applications/tests/test_ego.py +++ b/smt/applications/tests/test_ego.py @@ -37,6 +37,7 @@ MixedIntegerContext, MixedIntegerSamplingMethod, ) +import smt.utils.design_space as ds # This implementation only works with Python > 3.3 @@ -892,7 +893,7 @@ def _evaluate(self, x, kx): return ego, fun - def test_sampling_consistency(self): + def test_ego_seeding(self): def f_obj(X): """ s01 objective @@ -997,8 +998,12 @@ def f_obj(X): n_start=15, ) x_opt, y_opt, dnk, x_data, y_data = ego.optimize(fun=f_obj) - self.assertAlmostEqual(np.sum(y_data), 2.7639515433083854, delta=1e-4) - self.assertAlmostEqual(np.sum(x_data), 32.11001423996299, delta=1e-4) + if ds.HAS_CONFIG_SPACE: # results differs wrt config_space impl + self.assertAlmostEqual(np.sum(y_data), 2.7639515433083854, delta=1e-4) + self.assertAlmostEqual(np.sum(x_data), 32.11001423996299, delta=1e-4) + else: + self.assertAlmostEqual(np.sum(y_data), 2.03831406306514, delta=1e-4) + self.assertAlmostEqual(np.sum(x_data), 33.56885202767958, delta=1e-4) def test_ego_gek(self): ego, fun = self.initialize_ego_gek()