Skip to content

Commit

Permalink
Fix test values when ConfigSpace not installed
Browse files Browse the repository at this point in the history
  • Loading branch information
relf committed Nov 24, 2023
1 parent 649b0c2 commit 4cc4631
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions smt/applications/tests/test_ego.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@
MixedIntegerContext,
MixedIntegerSamplingMethod,
)
import smt.utils.design_space as ds


# This implementation only works with Python > 3.3
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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()
Expand Down

0 comments on commit 4cc4631

Please sign in to comment.