Skip to content

Commit af48840

Browse files
jduerholtmeta-codesync[bot]
authored andcommitted
prevent warning (#3078)
Summary: <!-- Thank you for sending the PR! We appreciate you spending the time to make BoTorch better. Help us understand your motivation by explaining why you decided to make this change. You can learn more about contributing to BoTorch here: https://github.com/meta-pytorch/botorch/blob/main/CONTRIBUTING.md --> ## Motivation Fixes the issue described in #3071. ### Have you read the [Contributing Guidelines on pull requests](https://github.com/meta-pytorch/botorch/blob/main/CONTRIBUTING.md#pull-requests)? Yes. Pull Request resolved: #3078 Test Plan: Unit tests. Reviewed By: hvarfner Differential Revision: D86792344 Pulled By: Balandat fbshipit-source-id: 6d5e4886b81e304efbea814847b3fe03674c799c
1 parent 50f6bdc commit af48840

File tree

2 files changed

+9
-8
lines changed

2 files changed

+9
-8
lines changed

botorch/models/deterministic.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,12 @@
4040
class DeterministicModel(EnsembleModel):
4141
"""Abstract base class for deterministic models."""
4242

43+
def _set_transformed_inputs(self):
44+
"""Overwrites the parent method to prevent raise of
45+
warning "Could not update `train_inputs` with transformed inputs."
46+
"""
47+
return None
48+
4349
@abstractmethod
4450
def forward(self, X: Tensor) -> Tensor:
4551
r"""Compute the (deterministic) model output at X.

test/models/test_deterministic.py

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44
# This source code is licensed under the MIT license found in the
55
# LICENSE file in the root directory of this source tree.
66

7-
import warnings
87

98
import torch
109
from botorch.acquisition.objective import ScalarizedPosteriorTransform
@@ -149,15 +148,11 @@ def test_with_transforms(self):
149148
# check that the posterior output agrees with the manually transformed one
150149
test_X = torch.rand(3, dim)
151150
expected_Y, _ = octf.untransform(model.forward(intf(test_X)))
152-
with warnings.catch_warnings(record=True) as ws:
153-
posterior = model.posterior(test_X)
154-
msg = "does not have a `train_inputs` attribute"
155-
self.assertTrue(any(msg in str(w.message) for w in ws))
151+
posterior = model.posterior(test_X)
156152
self.assertAllClose(expected_Y, posterior.mean)
157-
# check that model.train/eval works and raises the warning
153+
# check that model.train/eval works
158154
model.train()
159-
with self.assertWarns(RuntimeWarning):
160-
model.eval()
155+
model.eval()
161156

162157
def test_posterior_transform(self):
163158
def f(X):

0 commit comments

Comments
 (0)