Skip to content

Mock out ax_parameter_sens in online/offline tests #3648

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 21 additions & 4 deletions ax/analysis/plotly/tests/test_sensitivity.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@

# pyre-strict

from unittest.mock import Mock, patch

from ax.analysis.analysis import (
AnalysisBlobAnnotation,
AnalysisCardCategory,
Expand Down Expand Up @@ -87,8 +89,17 @@ def test_compute(self) -> None:
self.assertEqual(len(card.df), 3) # 2 first order + 1 second order

@mock_botorch_optimize
@TestCase.ax_long_test(reason="Expensive to compute Sobol indicies")
def test_online(self) -> None:
@patch( # pyre-fixme[56]: Pyre was not able to infer the type of argument lambda
f"{SensitivityAnalysisPlot.__module__}.ax_parameter_sens",
wraps=lambda model_bridge, metrics, **kwargs: {
outcome: {parameter: 0 for parameter in model_bridge.parameters}
for outcome in (metrics if metrics is not None else model_bridge.outcomes)
},
)
def test_online(
self,
_sensitivity_mock: Mock,
) -> None:
# Test SensitivityAnalysisPlot can be computed for a variety of experiments
# which resemble those we see in an online setting.

Expand All @@ -114,8 +125,14 @@ def test_online(self) -> None:
)

@mock_botorch_optimize
@TestCase.ax_long_test(reason="Expensive to compute Sobol indicies")
def test_offline(self) -> None:
@patch( # pyre-fixme[56]: Pyre was not able to infer the type of argument lambda
f"{SensitivityAnalysisPlot.__module__}.ax_parameter_sens",
wraps=lambda model_bridge, metrics, **kwargs: {
outcome: {parameter: 0 for parameter in model_bridge.parameters}
for outcome in (metrics if metrics is not None else model_bridge.outcomes)
},
)
def test_offline(self, _sensitivity_mock: Mock) -> None:
# Test SensitivityAnalysisPlot can be computed for a variety of experiments
# which resemble those we see in an offline setting.

Expand Down
31 changes: 27 additions & 4 deletions ax/analysis/plotly/tests/test_top_surfaces.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,11 @@
# LICENSE file in the root directory of this source tree.

# pyre-strict

from unittest.mock import Mock, patch

from ax.analysis.plotly.sensitivity import SensitivityAnalysisPlot

from ax.analysis.plotly.top_surfaces import TopSurfacesAnalysis
from ax.api.client import Client
from ax.api.configs import (
Expand Down Expand Up @@ -149,8 +154,17 @@ def test_compute_categorical_parameters(self) -> None:
self.assertEqual(cards[1].title, "x1 vs. bar")

@mock_botorch_optimize
@TestCase.ax_long_test(reason="Expensive to compute Sobol indicies")
def test_online(self) -> None:
@patch( # pyre-fixme[56]: Pyre was not able to infer the type of argument lambda
f"{SensitivityAnalysisPlot.__module__}.ax_parameter_sens",
wraps=lambda model_bridge, metrics, **kwargs: {
outcome: {parameter: 0 for parameter in model_bridge.parameters}
for outcome in (metrics if metrics is not None else model_bridge.outcomes)
},
)
def test_online(
self,
_sensitivity_mock: Mock,
) -> None:
# Test TopSurfacesAnalysis can be computed for a variety of experiments
# which resemble those we see in an online setting.

Expand All @@ -174,8 +188,17 @@ def test_online(self) -> None:
)

@mock_botorch_optimize
@TestCase.ax_long_test(reason="Expensive to compute Sobol indicies")
def test_offline(self) -> None:
@patch( # pyre-fixme[56]: Pyre was not able to infer the type of argument lambda
f"{SensitivityAnalysisPlot.__module__}.ax_parameter_sens",
wraps=lambda model_bridge, metrics, **kwargs: {
outcome: {parameter: 0 for parameter in model_bridge.parameters}
for outcome in (metrics if metrics is not None else model_bridge.outcomes)
},
)
def test_offline(
self,
_sensitivity_mock: Mock,
) -> None:
# Test TopSurfacesAnalysis can be computed for a variety of experiments
# which resemble those we see in an offline setting.

Expand Down
Loading