Skip to content

Commit

Permalink
Remove hypothesis dependency (#2774)
Browse files Browse the repository at this point in the history
Summary:
Pull Request resolved: #2774

Context: Hypothesis is not commonly used in Ax and is not part of the `UNITTEST_MINIMAL_REQUIRES` dependencies (although it is part of `UNITTEST_REQUIRES`). It is used in only one benchmarking test. Removing it will make it easier to build an environment that can run benchmark tests. We could have a broader discussion about removing it from Ax entirely.

This diff: Changes a unit test to not use hypothesis

Reviewed By: saitcakmak

Differential Revision: D63150787

fbshipit-source-id: daf732bb9effc45406816610f0d95f547d5ab192
  • Loading branch information
esantorella authored and facebook-github-bot committed Sep 20, 2024
1 parent a0fe4d3 commit 2e7291e
Showing 1 changed file with 16 additions and 21 deletions.
37 changes: 16 additions & 21 deletions ax/benchmark/tests/test_benchmark_problem.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
# pyre-strict

import math
from itertools import product
from math import pi
from typing import Optional, Union

Expand Down Expand Up @@ -34,7 +35,6 @@
ConstrainedHartmann,
Cosine8,
)
from hypothesis import given, strategies as st
from pyre_extensions import assert_is_instance


Expand Down Expand Up @@ -205,26 +205,21 @@ def _test_constrained_from_botorch(
observe_noise_sd,
)

# pyre-fixme[56]: Invalid decoration. Pyre was not able to infer the type of
# argument `hypothesis.strategies.booleans()` to decorator factory
# `hypothesis.given`.
@given(
st.booleans(),
st.one_of(st.none(), st.just(0.1)),
st.one_of(st.none(), st.just(0.2), st.just([0.3, 0.4])),
)
def test_constrained_soo_from_botorch(
self,
observe_noise_sd: bool,
objective_noise_std: Optional[float],
constraint_noise_std: Optional[Union[float, list[float]]],
) -> None:
self._test_constrained_from_botorch(
observe_noise_sd=observe_noise_sd,
objective_noise_std=objective_noise_std,
constraint_noise_std=constraint_noise_std,
test_problem_class=ConstrainedGramacy,
)
def test_constrained_soo_from_botorch(self) -> None:
for observe_noise_sd, objective_noise_std, constraint_noise_std in product(
[False, True], [None, 0.1], [None, 0.2, [0.3, 0.4]]
):
with self.subTest(
observe_noise_sd=observe_noise_sd,
objective_noise_std=objective_noise_std,
constraint_noise_std=constraint_noise_std,
):
self._test_constrained_from_botorch(
observe_noise_sd=observe_noise_sd,
objective_noise_std=objective_noise_std,
constraint_noise_std=constraint_noise_std,
test_problem_class=ConstrainedGramacy,
)

def test_constrained_moo_from_botorch(self) -> None:
self._test_constrained_from_botorch(
Expand Down

0 comments on commit 2e7291e

Please sign in to comment.