Skip to content

Commit

Permalink
Remove deprecated botorch/generation/gen/minimize
Browse files Browse the repository at this point in the history
Summary: This has been deprecated since pytorch#1352.

Reviewed By: Balandat

Differential Revision: D54280813
  • Loading branch information
saitcakmak authored and facebook-github-bot committed Feb 28, 2024
1 parent 6395c8d commit bbe5943
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 26 deletions.
18 changes: 5 additions & 13 deletions botorch/generation/gen.py
Original file line number Diff line number Diff line change
Expand Up @@ -283,7 +283,9 @@ def f(x):
candidates = torch.from_numpy(x0).to(candidates).reshape(shapeX)
warnings.warn(
"SLSQP failed to converge to a solution the satisfies the "
"non-linear constraints. Returning the feasible starting point."
"non-linear constraints. Returning the feasible starting point.",
OptimizationWarning,
stacklevel=2,
)
break

Expand Down Expand Up @@ -462,6 +464,7 @@ def _process_scipy_result(res: OptimizeResult, options: Dict[str, Any]) -> None:
"Optimization failed within `scipy.optimize.minimize` with no "
"status returned to `res.`",
OptimizationWarning,
stacklevel=3,
)
elif not res.success:
if (
Expand All @@ -486,16 +489,5 @@ def _process_scipy_result(res: OptimizeResult, options: Dict[str, Any]) -> None:
f"Optimization failed within `scipy.optimize.minimize` with status "
f"{res.status} and message {res.message}.",
OptimizationWarning,
stacklevel=3,
)


def minimize(*args, **kwargs):
"""Deprecated, use `botorch.generation.gen.minimize_with_timeout`."""
# TODO: Reap this after the next stable Ax release.
warnings.warn(
"`botorch.generation.gen.minimize` is an alias for "
"`botorch.generation.gen.minimize_with_timeout` and will "
"be removed in a future release.",
DeprecationWarning,
)
return minimize_with_timeout(*args, **kwargs)
13 changes: 0 additions & 13 deletions test/generation/test_gen.py
Original file line number Diff line number Diff line change
Expand Up @@ -371,16 +371,3 @@ def test_random_restart_optimization(self):
batch_candidates=batch_candidates, batch_values=batch_acq_values
)
self.assertTrue(-EPS <= candidates <= 1 + EPS)


class TestDeprecateMinimize(BotorchTestCase):
def test_deprecate_minimize(self):
from botorch.generation.gen import minimize

with self.assertWarnsRegex(
DeprecationWarning, "botorch.generation.gen.minimize_with_timeout"
):
try:
minimize(None, None)
except Exception:
pass

0 comments on commit bbe5943

Please sign in to comment.