From d5b857868b76aaa6d990d79769a0f15a379cb950 Mon Sep 17 00:00:00 2001
From: kohlhaasrebecca <rebecca.kohlhaas@outlook.com>
Date: Mon, 26 Aug 2024 11:06:37 +0200
Subject: [PATCH] [tests] More updates for the tests

---
 src/bayesvalidrox/surrogate_models/engine.py |  2 +-
 tests/test_SequentialDesign.py               | 96 ++++++++++----------
 2 files changed, 49 insertions(+), 49 deletions(-)

diff --git a/src/bayesvalidrox/surrogate_models/engine.py b/src/bayesvalidrox/surrogate_models/engine.py
index a6d2447c6..c9a19b8aa 100644
--- a/src/bayesvalidrox/surrogate_models/engine.py
+++ b/src/bayesvalidrox/surrogate_models/engine.py
@@ -947,7 +947,7 @@ class Engine:
             distHellinger = 0.0
 
         # Bayesian inference with Emulator only for 2D problem
-        if post_snapshot and self.MetaModel.n_params == 2 and not idx % 5:
+        if post_snapshot and self.MetaModel.ndim == 2 and not idx % 5:
             bayes = BayesInference(self)
 
             bayes.emulator = True
diff --git a/tests/test_SequentialDesign.py b/tests/test_SequentialDesign.py
index bcffc5d05..0f90425ef 100644
--- a/tests/test_SequentialDesign.py
+++ b/tests/test_SequentialDesign.py
@@ -134,10 +134,10 @@ def test_tradeoff_weights_adaptiveit1() -> None:
     inp.Marginals[0].dist_type = 'normal'
     inp.Marginals[0].parameters = [0, 1]
     expdes = ExpDesigns(inp)
-    expdes.n_init_samples = 2
-    expdes.n_max_samples = 4
     expdes.X = np.array([[0], [1], [0.5]])
     expdes.Y = {'Z': [[0.4], [0.5], [0.45]]}
+    expdes.n_init_samples = expdes.X.shape[0]
+    expdes.n_max_samples = 4
     mm = PCE(inp)
     mm.fit(expdes.X, expdes.Y)
     mod = PL()
@@ -161,10 +161,10 @@ def test_choose_next_sample() -> None:
     inp.Marginals[0].dist_type = 'normal'
     inp.Marginals[0].parameters = [0, 1]
     expdes = ExpDesigns(inp)
-    expdes.n_init_samples = 2
-    expdes.n_max_samples = 4
     expdes.X = np.array([[0], [1], [0.5]])
     expdes.Y = {'Z': [[0.4], [0.5], [0.45]]}
+    expdes.n_init_samples = expdes.X.shape[0]
+    expdes.n_max_samples = 4
     expdes.explore_method = 'random'
     expdes.exploit_method = 'Space-filling'
     expdes.util_func = 'Space-filling'
@@ -191,10 +191,10 @@ def test_choose_next_sample_da_spaceparallel() -> None:
     inp.Marginals[0].dist_type = 'normal'
     inp.Marginals[0].parameters = [0, 1]
     expdes = ExpDesigns(inp)
-    expdes.n_init_samples = 2
-    expdes.n_max_samples = 4
     expdes.X = np.array([[0], [1], [0.5]])
     expdes.Y = {'Z': [[0.4], [0.5], [0.45]]}
+    expdes.n_init_samples = expdes.X.shape[0]
+    expdes.n_max_samples = 4
     expdes.explore_method = 'dual-annealing'
     expdes.exploit_method = 'Space-filling'
     expdes.util_func = 'Space-filling'
@@ -222,10 +222,10 @@ def test_choose_next_sample_da_spacenoparallel() -> None:
     inp.Marginals[0].dist_type = 'normal'
     inp.Marginals[0].parameters = [0, 1]
     expdes = ExpDesigns(inp)
-    expdes.n_init_samples = 2
-    expdes.n_max_samples = 4
     expdes.X = np.array([[0], [1], [0.5]])
     expdes.Y = {'Z': [[0.4], [0.5], [0.45]]}
+    expdes.n_init_samples = expdes.X.shape[0]
+    expdes.n_max_samples = 4
     expdes.explore_method = 'dual-annealing'
     expdes.exploit_method = 'Space-filling'
     expdes.util_func = 'Space-filling'
@@ -253,10 +253,10 @@ def test_choose_next_sample_loo_space() -> None:
     inp.Marginals[0].dist_type = 'normal'
     inp.Marginals[0].parameters = [0, 1]
     expdes = ExpDesigns(inp)
-    expdes.n_init_samples = 2
-    expdes.n_max_samples = 4
     expdes.X = np.array([[0], [1], [0.5]])
     expdes.Y = {'Z': [[0.4], [0.5], [0.45]]}
+    expdes.n_init_samples = expdes.X.shape[0]
+    expdes.n_max_samples = 4
     expdes.explore_method = 'LOO-CV'
     expdes.exploit_method = 'Space-filling'
     expdes.util_func = 'Space-filling'
@@ -283,10 +283,10 @@ def test_choose_next_sample_vor_space() -> None:
     inp.Marginals[0].dist_type = 'normal'
     inp.Marginals[0].parameters = [0, 1]
     expdes = ExpDesigns(inp)
-    expdes.n_init_samples = 2
-    expdes.n_max_samples = 4
     expdes.X = np.array([[0], [1], [0.5]])
     expdes.Y = {'Z': [[0.4], [0.5], [0.45]]}
+    expdes.n_init_samples = expdes.X.shape[0]
+    expdes.n_max_samples = 4
     expdes.explore_method = 'voronoi'
     expdes.exploit_method = 'Space-filling'
     expdes.util_func = 'Space-filling'
@@ -318,10 +318,10 @@ def test_choose_next_sample_latin_space() -> None:
     inp.Marginals[0].dist_type = 'normal'
     inp.Marginals[0].parameters = [0, 1]
     expdes = ExpDesigns(inp)
-    expdes.n_init_samples = 2
-    expdes.n_max_samples = 4
     expdes.X = np.array([[0], [1], [0.5]])
     expdes.Y = {'Z': [[0.4], [0.5], [0.45]]}
+    expdes.n_init_samples = expdes.X.shape[0]
+    expdes.n_max_samples = 4
     expdes.explore_method = 'latin-hypercube'
     expdes.exploit_method = 'Space-filling'
     expdes.util_func = 'Space-filling'
@@ -348,10 +348,10 @@ def test_choose_next_sample_latin_alphD() -> None:
     inp.Marginals[0].dist_type = 'normal'
     inp.Marginals[0].parameters = [0, 1]
     expdes = ExpDesigns(inp)
-    expdes.n_init_samples = 2
-    expdes.n_max_samples = 4
     expdes.X = np.array([[0], [1], [0.5]])
     expdes.Y = {'Z': [[0.4], [0.5], [0.45]]}
+    expdes.n_init_samples = expdes.X.shape[0]
+    expdes.n_max_samples = 4
     expdes.explore_method = 'latin-hypercube'
     expdes.exploit_method = 'alphabetic'
     expdes.util_func = 'D-Opt'
@@ -378,10 +378,10 @@ def test_choose_next_sample_latin_alphK() -> None:
     inp.Marginals[0].dist_type = 'normal'
     inp.Marginals[0].parameters = [0, 1]
     expdes = ExpDesigns(inp)
-    expdes.n_init_samples = 2
-    expdes.n_max_samples = 4
     expdes.X = np.array([[0], [1], [0.5]])
     expdes.Y = {'Z': [[0.4], [0.5], [0.45]]}
+    expdes.n_init_samples = expdes.X.shape[0]
+    expdes.n_max_samples = 4
     expdes.explore_method = 'latin-hypercube'
     expdes.exploit_method = 'alphabetic'
     expdes.util_func = 'K-Opt'
@@ -408,10 +408,10 @@ def test_choose_next_sample_latin_alphA() -> None:
     inp.Marginals[0].dist_type = 'normal'
     inp.Marginals[0].parameters = [0, 1]
     expdes = ExpDesigns(inp)
-    expdes.n_init_samples = 2
-    expdes.n_max_samples = 4
     expdes.X = np.array([[0], [1], [0.5]])
     expdes.Y = {'Z': [[0.4], [0.5], [0.45]]}
+    expdes.n_init_samples = expdes.X.shape[0]
+    expdes.n_max_samples = 4
     expdes.explore_method = 'latin-hypercube'
     expdes.exploit_method = 'alphabetic'
     expdes.util_func = 'A-Opt'
@@ -438,10 +438,10 @@ def test_choose_next_sample_latin_VarALM() -> None:
     inp.Marginals[0].dist_type = 'normal'
     inp.Marginals[0].parameters = [0, 1]
     expdes = ExpDesigns(inp)
-    expdes.n_init_samples = 2
-    expdes.n_max_samples = 4
     expdes.X = np.array([[0], [1], [0.5]])
     expdes.Y = {'Z': [[0.4], [0.5], [0.45]]}
+    expdes.n_init_samples = expdes.X.shape[0]
+    expdes.n_max_samples = 4
     expdes.tradeoff_scheme = 'equal'
     expdes.explore_method = 'latin-hypercube'
     expdes.exploit_method = 'VarOptDesign'
@@ -469,10 +469,10 @@ def test_choose_next_sample_latin_VarEIGF() -> None:
     inp.Marginals[0].dist_type = 'normal'
     inp.Marginals[0].parameters = [0, 1]
     expdes = ExpDesigns(inp)
-    expdes.n_init_samples = 2
-    expdes.n_max_samples = 4
     expdes.X = np.array([[0], [1], [0.5]])
     expdes.Y = {'Z': [[0.4], [0.5], [0.45]]}
+    expdes.n_init_samples = expdes.X.shape[0]
+    expdes.n_max_samples = 4
     expdes.tradeoff_scheme = 'equal'
     expdes.explore_method = 'latin-hypercube'
     expdes.exploit_method = 'VarOptDesign'
@@ -502,10 +502,10 @@ if 0:
         inp.Marginals[0].dist_type = 'normal'
         inp.Marginals[0].parameters = [0, 1]
         expdes = ExpDesigns(inp)
-        expdes.n_init_samples = 2
-        expdes.n_max_samples = 4
         expdes.X = np.array([[0], [1], [0.5]])
         expdes.Y = {'Z': [[0.4], [0.5], [0.45]]}
+        expdes.n_init_samples = expdes.X.shape[0]
+        expdes.n_max_samples = 4
         expdes.tradeoff_scheme = 'equal'
         expdes.explore_method = 'latin-hypercube'
         expdes.exploit_method = 'VarOptDesign'
@@ -534,10 +534,10 @@ def test_choose_next_sample_latin_BODMI() -> None:
     inp.Marginals[0].parameters = [0, 1]
     expdes = ExpDesigns(inp)
     expdes.sampling_method = 'user'
-    expdes.n_init_samples = 2
-    expdes.n_max_samples = 4
     expdes.X = np.array([[0], [1], [0.5]])
     expdes.Y = {'Z': [[0.4], [0.5], [0.45]]}
+    expdes.n_init_samples = expdes.X.shape[0]
+    expdes.n_max_samples = 4
     expdes.tradeoff_scheme = 'equal'
     expdes.explore_method = 'latin-hypercube'
     expdes.exploit_method = 'BayesOptDesign'
@@ -567,10 +567,10 @@ def test_choose_next_sample_vor_BODMI() -> None:
     inp.Marginals[0].parameters = [0, 1]
     expdes = ExpDesigns(inp)
     expdes.sampling_method = 'user'
-    expdes.n_init_samples = 2
-    expdes.n_max_samples = 4
     expdes.X = np.array([[0], [1], [0.5]])
     expdes.Y = {'Z': [[0.4], [0.5], [0.45]]}
+    expdes.n_init_samples = expdes.X.shape[0]
+    expdes.n_max_samples = 4
     expdes.tradeoff_scheme = 'equal'
     expdes.explore_method = 'voronoi'
     expdes.exploit_method = 'BayesOptDesign'
@@ -605,10 +605,10 @@ def test_choose_next_sample_latin_BODALC() -> None:
     inp.Marginals[0].dist_type = 'normal'
     inp.Marginals[0].parameters = [0, 1]
     expdes = ExpDesigns(inp)
-    expdes.n_init_samples = 2
-    expdes.n_max_samples = 4
     expdes.X = np.array([[0], [1], [0.5]])
     expdes.Y = {'Z': [[0.4], [0.5], [0.45]]}
+    expdes.n_init_samples = expdes.X.shape[0]
+    expdes.n_max_samples = 4
     expdes.tradeoff_scheme = 'equal'
     expdes.explore_method = 'latin-hypercube'
     expdes.exploit_method = 'BayesOptDesign'
@@ -638,10 +638,10 @@ def test_choose_next_sample_latin_BODDKL() -> None:
     inp.Marginals[0].dist_type = 'normal'
     inp.Marginals[0].parameters = [0, 1]
     expdes = ExpDesigns(inp)
-    expdes.n_init_samples = 2
-    expdes.n_max_samples = 4
     expdes.X = np.array([[0], [1], [0.5]])
     expdes.Y = {'Z': [[0.4], [0.5], [0.45]]}
+    expdes.n_init_samples = expdes.X.shape[0]
+    expdes.n_max_samples = 4
     expdes.tradeoff_scheme = 'equal'
     expdes.explore_method = 'latin-hypercube'
     expdes.exploit_method = 'BayesOptDesign'
@@ -671,10 +671,10 @@ def test_choose_next_sample_latin_BODDPP() -> None:
     inp.Marginals[0].dist_type = 'normal'
     inp.Marginals[0].parameters = [0, 1]
     expdes = ExpDesigns(inp)
-    expdes.n_init_samples = 2
-    expdes.n_max_samples = 4
     expdes.X = np.array([[0], [1], [0.5]])
     expdes.Y = {'Z': [[0.4], [0.5], [0.45]]}
+    expdes.n_init_samples = expdes.X.shape[0]
+    expdes.n_max_samples = 4
     expdes.tradeoff_scheme = 'equal'
     expdes.explore_method = 'latin-hypercube'
     expdes.exploit_method = 'BayesOptDesign'
@@ -704,10 +704,10 @@ def test_choose_next_sample_latin_BODAPP() -> None:
     inp.Marginals[0].dist_type = 'normal'
     inp.Marginals[0].parameters = [0, 1]
     expdes = ExpDesigns(inp)
-    expdes.n_init_samples = 2
-    expdes.n_max_samples = 4
     expdes.X = np.array([[0], [1], [0.5]])
     expdes.Y = {'Z': [[0.4], [0.5], [0.45]]}
+    expdes.n_init_samples = expdes.X.shape[0]
+    expdes.n_max_samples = 4
     expdes.tradeoff_scheme = 'equal'
     expdes.explore_method = 'latin-hypercube'
     expdes.exploit_method = 'BayesOptDesign'
@@ -737,10 +737,10 @@ def test_choose_next_sample_latin_BODMI_() -> None:
     inp.Marginals[0].dist_type = 'normal'
     inp.Marginals[0].parameters = [0, 1]
     expdes = ExpDesigns(inp)
-    expdes.n_init_samples = 2
-    expdes.n_max_samples = 4
     expdes.X = np.array([[0], [1], [0.5]])
     expdes.Y = {'Z': [[0.4], [0.5], [0.45]]}
+    expdes.n_init_samples = expdes.X.shape[0]
+    expdes.n_max_samples = 4
     expdes.tradeoff_scheme = 'equal'
     expdes.explore_method = 'latin-hypercube'
     expdes.exploit_method = 'BayesOptDesign'
@@ -770,10 +770,10 @@ if 0:
         inp.Marginals[0].dist_type = 'normal'
         inp.Marginals[0].parameters = [0, 1]
         expdes = ExpDesigns(inp)
-        expdes.n_init_samples = 2
-        expdes.n_max_samples = 4
         expdes.X = np.array([[0], [1], [0.5]])
         expdes.Y = {'Z': [[0.4], [0.5], [0.45]]}
+        expdes.n_init_samples = expdes.X.shape[0]
+        expdes.n_max_samples = 4
         expdes.tradeoff_scheme = 'equal'
         expdes.explore_method = 'latin-hypercube'
         expdes.exploit_method = 'BayesActDesign'
@@ -804,10 +804,10 @@ if 0:
         inp.Marginals[0].dist_type = 'normal'
         inp.Marginals[0].parameters = [0, 1]
         expdes = ExpDesigns(inp)
-        expdes.n_init_samples = 2
-        expdes.n_max_samples = 4
         expdes.X = np.array([[0], [1], [0.5]])
         expdes.Y = {'Z': [[0.4], [0.5], [0.45]]}
+        expdes.n_init_samples = expdes.X.shape[0]
+        expdes.n_max_samples = 4
         expdes.tradeoff_scheme = 'equal'
         expdes.explore_method = 'latin-hypercube'
         expdes.exploit_method = 'BayesActDesign'
@@ -838,10 +838,10 @@ if 0:
         inp.Marginals[0].dist_type = 'normal'
         inp.Marginals[0].parameters = [0, 1]
         expdes = ExpDesigns(inp)
-        expdes.n_init_samples = 2
-        expdes.n_max_samples = 4
         expdes.X = np.array([[0], [1], [0.5]])
         expdes.Y = {'Z': [[0.4], [0.5], [0.45]]}
+        expdes.n_init_samples = expdes.X.shape[0]
+        expdes.n_max_samples = 4
         expdes.tradeoff_scheme = 'equal'
         expdes.explore_method = 'latin-hypercube'
         expdes.exploit_method = 'BayesActDesign'
@@ -921,10 +921,10 @@ if __name__ == '__main__':
 
     expdes = ExpDesigns(inp)
     expdes.init_param_space(max_deg=1)
-    expdes.n_init_samples = 2
-    expdes.n_max_samples = 4
     expdes.X = np.array([[0], [1], [0.5]])
     expdes.Y = {'Z': [[0.4], [0.5], [0.45]]}
+    expdes.n_init_samples = expdes.X.shape[0]
+    expdes.n_max_samples = 4
     expdes.x_values = np.array([0])  # Error in plots if this is not
 
     mm = PCE(inp)
-- 
GitLab