Skip to content

Commit

Permalink
Export NumericsWarning and UserInputWarning from botorch.exceptions (#…
Browse files Browse the repository at this point in the history
…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
  • Loading branch information
chrisyeh96 authored and facebook-github-bot committed Mar 7, 2025
1 parent 326b604 commit bba835c
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions botorch/exceptions/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,10 @@
BotorchWarning,
CostAwareWarning,
InputDataWarning,
NumericsWarning,
OptimizationWarning,
SamplingWarning,
UserInputWarning,
)


Expand All @@ -36,8 +38,10 @@
"BadInitialCandidatesWarning",
"CandidateGenerationError",
"ModelFittingError",
"NumericsWarning",
"OptimizationTimeoutError",
"OptimizationWarning",
"SamplingWarning",
"UnsupportedError",
"UserInputWarning",
]

0 comments on commit bba835c

Please sign in to comment.