Skip to content

Commit bba835c

Browse files
chrisyeh96facebook-github-bot
authored andcommitted
Export NumericsWarning and UserInputWarning from botorch.exceptions (#2761)
Summary: ## Motivation Using `botorch.acquisition.ExpectedImprovement` (instead of LogEI) now triggers a `botorch.exceptions.warnings.NumericsWarning`. I'd like to be able to suppress this warning in cases that I actually intend to use EI instead of LogEI, such as when I am comparing the two. I'd like to be able to write the following: ```python import warnings import botorch with warnings.catch_warnings(): warnings.filterwarnings('ignore', category=botorch.exceptions.NumericsWarning) acqf = botorch.acquisition.ExpectedImprovement(...) ``` However, `botorch.exceptions` does not export `NumericsWarning` as a symbol, so code editors (_e.g._, Visual Studio Code) complain that the symbol `botorch.exceptions.NumericsWarning` is not found. This pull request updates `botorch/exceptions/__init__.py` to export `NumericsWarning` and `UserInputWarning`, the only two warnings from `botorch/exceptions/warnings.py` that were previously unexported. ### Have you read the [Contributing Guidelines on pull requests](https://github.com/pytorch/botorch/blob/main/CONTRIBUTING.md#pull-requests)? Yes. Pull Request resolved: #2761 Test Plan: N/A ## Related PRs I believe it may have been a simple oversight of commit 6892be9 (from pull request #2429) to add `NumericsWarning` to the list of exported symbols in `botorch/exceptions/__init__.py`. Reviewed By: saitcakmak Differential Revision: D70799344 Pulled By: SebastianAment fbshipit-source-id: 9548b62492a2c18fc9515d161cfe026cd55e0236
1 parent 326b604 commit bba835c

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

botorch/exceptions/__init__.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,10 @@
1919
BotorchWarning,
2020
CostAwareWarning,
2121
InputDataWarning,
22+
NumericsWarning,
2223
OptimizationWarning,
2324
SamplingWarning,
25+
UserInputWarning,
2426
)
2527

2628

@@ -36,8 +38,10 @@
3638
"BadInitialCandidatesWarning",
3739
"CandidateGenerationError",
3840
"ModelFittingError",
41+
"NumericsWarning",
3942
"OptimizationTimeoutError",
4043
"OptimizationWarning",
4144
"SamplingWarning",
4245
"UnsupportedError",
46+
"UserInputWarning",
4347
]

0 commit comments

Comments
 (0)