def test_get_Z(self): Mt = SurrogateModel(d) Mt.trans_p = lambda p: p z = (3. + np.arange(Dx + Dp))[None, :] x = z[:, :Dx] p = z[:, Dx:] with pytest.raises(AssertionError): Z = Mt.get_Z(x) Z = Mt.get_Z(x, p) assert np.all(Z == z) Mt.pmean = p[0] Z = Mt.get_Z(x) assert np.all(Z == z)
def test_prediction(self): # Nothing given Mt = SurrogateModel(d) with pytest.raises(AssertionError): M, S = Mt.predict(X) # Give mean Mt.pmean = np.random.uniform(*p_bounds.T) with pytest.raises(AssertionError): M, S = Mt.predict(X) # Give training data Mt.set_training_data(Z, Y) with pytest.raises(AssertionError): M, S = Mt.predict(X) # Give hyperparameters Mt.hyp = [0] * Mt.num_outputs with pytest.raises(NotImplementedError): M, S = Mt.predict(X)