Skip to content

Commit bf5b607

Browse files
Ethan Chefacebook-github-bot
authored andcommitted
fixed documentation example for model.condition_on_observations. (#2978)
Summary: As pointed out in [issue #2446](#2446) the example for model.condition_on_observations is outdated and raises an error when run. The docstring is now updated with proper usage of the method. Reviewed By: Balandat Differential Revision: D80371177
1 parent b1097c6 commit bf5b607

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

botorch/models/gpytorch.py

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -231,10 +231,15 @@ def condition_on_observations(
231231
232232
Example:
233233
>>> train_X = torch.rand(20, 2)
234-
>>> train_Y = torch.sin(train_X[:, 0]) + torch.cos(train_X[:, 1])
234+
>>> train_Y = torch.sin(train_X[:, :1]) + torch.cos(train_X[:, 1:])
235235
>>> model = SingleTaskGP(train_X, train_Y)
236+
>>> model.eval()
237+
>>> test_X = torch.rand(10, 2)
238+
# Need to evaluate once to fill test independent caches
239+
# so that condition_on_observations works.
240+
>>> model(test_X)
236241
>>> new_X = torch.rand(5, 2)
237-
>>> new_Y = torch.sin(new_X[:, 0]) + torch.cos(new_X[:, 1])
242+
>>> new_Y = torch.sin(new_X[:, :1]) + torch.cos(new_X[:, 1:])
238243
>>> model = model.condition_on_observations(X=new_X, Y=new_Y)
239244
"""
240245
Yvar = noise

0 commit comments

Comments
 (0)