Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion pySOT/surrogate/gp.py
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ def predict(self, xx):
"""
self._fit()
xx = to_unit_box(np.atleast_2d(xx), self.lb, self.ub)
return self._mu + self._sigma * self.model.predict(xx)
return self._mu + self._sigma * np.expand_dims(self.model.predict(xx), axis=1)

def predict_std(self, xx):
"""Predict standard deviation at points xx.
Expand Down
3 changes: 3 additions & 0 deletions tests/test_surrogates.py
Original file line number Diff line number Diff line change
Expand Up @@ -174,6 +174,9 @@ def test_gp():
np.random.seed(0)
Xs = np.random.rand(10, 2)
fhx = gp.predict(Xs)
assert fhx.shape == (Xs.shape[0], 1)
assert gp.predict_std(Xs).shape == fhx.shape
assert gp.predict(Xs[0]).shape == (1, 1)
fx = f(Xs)
assert np.max(np.abs(fx - fhx)) < 1e-2

Expand Down