diff --git a/smt/surrogate_models/krg_based.py b/smt/surrogate_models/krg_based.py index d8c853bb8..c17bcd856 100644 --- a/smt/surrogate_models/krg_based.py +++ b/smt/surrogate_models/krg_based.py @@ -307,6 +307,14 @@ def set_training_values( Matrix specifying which of the design variables is acting in a hierarchical design space """ super().set_training_values(xt, yt, name=name) + if self.ny > 1: + warnings.warn( + "Kriging-based surrogate is not intended to handle multiple " + f"training output data (yt dim should be 1, got {self.ny}). " + "The quality of the resulting surrogate might not be as good as " + "if each training output is used separately to build a dedicated surrogate. " + "This warning might become a hard error in future SMT versions." + ) if is_acting is not None: self.is_acting_points[name] = is_acting @@ -397,6 +405,7 @@ def _new_train(self): # Sampling points X and y X = self.training_points[None][0][0] y = self.training_points[None][0][1] + # Get is_acting status from design space model if needed (might correct training points) is_acting = self.is_acting_points.get(None) if is_acting is None and not self.is_continuous: diff --git a/smt/surrogate_models/tests/test_krg_based.py b/smt/surrogate_models/tests/test_krg_based.py index 47fe9accd..a1c2652ae 100644 --- a/smt/surrogate_models/tests/test_krg_based.py +++ b/smt/surrogate_models/tests/test_krg_based.py @@ -40,6 +40,11 @@ def test_theta0_erroneous_init(self): krg.set_training_values(np.array([[1, 2, 3]]), np.array([[1]])) # erroneous self.assertRaises(ValueError, krg._check_param) + def test_multiple_training_outputs_warning(self): + krg = KrgBased() + with self.assertWarns(UserWarning): + krg.set_training_values(np.array([[1, 2, 3]]), np.array([[1, 1]])) + def test_less_almost_squar_exp(self): nobs = 50 # number of obsertvations np.random.seed(0) # a seed for reproducibility