diff --git a/src/bayesvalidrox/surrogate_models/sequential_design.py b/src/bayesvalidrox/surrogate_models/sequential_design.py index f4669a7f29f0cefefdd4ae18f2ea5f0eab0b2317..347d9ac786e105623fa2e70b58566ad0ce667872 100644 --- a/src/bayesvalidrox/surrogate_models/sequential_design.py +++ b/src/bayesvalidrox/surrogate_models/sequential_design.py @@ -278,6 +278,9 @@ class SequentialDesign: # ToDo: Move this if/else into its own function called "do_exploration", which should select the # exploration samples, and assign exploration scores. We should send it explore_score, for if/else stmts # ToDo: Check if explore_scores can be nan, and remove them from any score normalization + if explore_method.lower() == 'voronoi': + raise AttributeError('Exploration with voronoi currently not supported!') + #print('WARNING: Exploration with Voronoi ') if explore_method.lower() == 'loocv': # ----------------------------------------------------------------- # TODO: LOOCV model construnction based on Feng et al. (2020) @@ -530,12 +533,17 @@ class SequentialDesign: temp = totalScore.copy() temp[np.isnan(totalScore)] = -np.inf # Since we are maximizing sorted_idxtotalScore = np.argsort(temp)[::-1] + print(sorted_idxtotalScore) + print(n_new_samples) bestIdx = sorted_idxtotalScore[:n_new_samples] + if type(bestIdx) is int: + bestIdx = [bestIdx] # select the requested number of samples if explore_method.lower() == 'voronoi': Xnew = np.zeros((n_new_samples, ndim)) for i, idx in enumerate(bestIdx): + print(explore.closestPoints) X_can = explore.closestPoints[idx] # Calculate the maxmin score for the region of interest diff --git a/tests/test_MetaModel.py b/tests/test_MetaModel.py index bf6c3c39ccd8a7251cdb04e1437c583194c7c2dc..f7a300e8eec36ed1be5762c9f0bb465c20e8395f 100644 --- a/tests/test_MetaModel.py +++ b/tests/test_MetaModel.py @@ -769,8 +769,7 @@ def test_adaptive_regression_fewsamples() -> None: with pytest.raises(AttributeError) as excinfo: mm.adaptive_regression(outputs, 0) - assert str( - excinfo.value) == ('There are too few samples for the corrected loo-cv error. Fit surrogate on at least as ' + assert str(excinfo.value) == ('There are too few samples for the corrected loo-cv error. Fit surrogate on at least as ' 'many samples as parameters to use this') diff --git a/tests/test_SequentialDesign.py b/tests/test_SequentialDesign.py index fe9ad5338172541996b39bba20447954c383f1f9..5d713e747d47425f45e3fcbed8ace16073b53192 100644 --- a/tests/test_SequentialDesign.py +++ b/tests/test_SequentialDesign.py @@ -298,9 +298,14 @@ def test_choose_next_sample_vor_space() -> None: engine.start_engine() seqDes = SequentialDesign(mm, mod, expdes, engine) seqDes.out_names = ['Z'] - x, nan = seqDes.choose_next_sample() - assert x.shape[0] == 1 and x.shape[1] == 1 + #x, nan = seqDes.choose_next_sample() + #assert x.shape[0] == 1 and x.shape[1] == 1 + + # TODO: removed this functionality for v1.1.0 + with pytest.raises(AttributeError) as excinfo: + x, nan = seqDes.choose_next_sample() + assert str(excinfo.value) == ('Exploration with voronoi currently not supported!') def test_choose_next_sample_latin_space() -> None: """ @@ -581,7 +586,11 @@ def test_choose_next_sample_vor_BODMI() -> None: # seqDes.choose_next_sample(sigma2=None, n_candidates=5, var='DKL') sigma2Dict = {'Z': np.array([0.05])} sigma2Dict = pd.DataFrame(sigma2Dict, columns=['Z']) - seqDes.choose_next_sample(sigma2=sigma2Dict, var=expdes.util_func) + + # TODO: removed this functionality for v1.1.0 + with pytest.raises(AttributeError) as excinfo: + seqDes.choose_next_sample(sigma2=sigma2Dict, var=expdes.util_func) + assert str(excinfo.value) == ('Exploration with voronoi currently not supported!')