|
4 | 4 |
|
5 | 5 | import math |
6 | 6 | import unittest |
| 7 | +import warnings |
7 | 8 |
|
8 | 9 | import torch |
9 | | -from botorch import fit_gpytorch_model |
| 10 | +from botorch.exceptions.warnings import OptimizationWarning |
| 11 | +from botorch.fit import fit_gpytorch_model |
10 | 12 | from botorch.models.multitask import FixedNoiseMultiTaskGP, MultiTaskGP |
11 | 13 | from botorch.posteriors import GPyTorchPosterior |
12 | 14 | from gpytorch.distributions import MultitaskMultivariateNormal, MultivariateNormal |
@@ -82,7 +84,9 @@ def test_MultiTaskGP(self, cuda=False): |
82 | 84 |
|
83 | 85 | # test model fitting |
84 | 86 | mll = ExactMarginalLogLikelihood(model.likelihood, model) |
85 | | - mll = fit_gpytorch_model(mll, options={"maxiter": 1}, max_retries=1) |
| 87 | + with warnings.catch_warnings(): |
| 88 | + warnings.filterwarnings("ignore", category=OptimizationWarning) |
| 89 | + mll = fit_gpytorch_model(mll, options={"maxiter": 1}, max_retries=1) |
86 | 90 |
|
87 | 91 | # test posterior |
88 | 92 | test_x = torch.rand(2, 1, **tkwargs) |
@@ -155,7 +159,9 @@ def test_MultiTaskGP_single_output(self, cuda=False): |
155 | 159 |
|
156 | 160 | # test model fitting |
157 | 161 | mll = ExactMarginalLogLikelihood(model.likelihood, model) |
158 | | - mll = fit_gpytorch_model(mll, options={"maxiter": 1}, max_retries=1) |
| 162 | + with warnings.catch_warnings(): |
| 163 | + warnings.filterwarnings("ignore", category=OptimizationWarning) |
| 164 | + mll = fit_gpytorch_model(mll, options={"maxiter": 1}, max_retries=1) |
159 | 165 |
|
160 | 166 | # test posterior |
161 | 167 | test_x = torch.rand(2, 1, **tkwargs) |
@@ -197,7 +203,9 @@ def test_FixedNoiseMultiTaskGP(self, cuda=False): |
197 | 203 |
|
198 | 204 | # test model fitting |
199 | 205 | mll = ExactMarginalLogLikelihood(model.likelihood, model) |
200 | | - mll = fit_gpytorch_model(mll, options={"maxiter": 1}, max_retries=1) |
| 206 | + with warnings.catch_warnings(): |
| 207 | + warnings.filterwarnings("ignore", category=OptimizationWarning) |
| 208 | + mll = fit_gpytorch_model(mll, options={"maxiter": 1}, max_retries=1) |
201 | 209 |
|
202 | 210 | # test posterior |
203 | 211 | test_x = torch.rand(2, 1, **tkwargs) |
@@ -268,7 +276,9 @@ def test_FixedNoiseMultiTaskGP_single_output(self, cuda=False): |
268 | 276 |
|
269 | 277 | # test model fitting |
270 | 278 | mll = ExactMarginalLogLikelihood(model.likelihood, model) |
271 | | - mll = fit_gpytorch_model(mll, options={"maxiter": 1}, max_retries=1) |
| 279 | + with warnings.catch_warnings(): |
| 280 | + warnings.filterwarnings("ignore", category=OptimizationWarning) |
| 281 | + mll = fit_gpytorch_model(mll, options={"maxiter": 1}, max_retries=1) |
272 | 282 |
|
273 | 283 | # test posterior |
274 | 284 | test_x = torch.rand(2, 1, **tkwargs) |
|
0 commit comments