Coverage for mlos_viz/mlos_viz/tests/test_mlos_viz.py: 100%
17 statements
« prev ^ index » next coverage.py v7.6.9, created at 2024-12-20 00:44 +0000
« prev ^ index » next coverage.py v7.6.9, created at 2024-12-20 00:44 +0000
1#
2# Copyright (c) Microsoft Corporation.
3# Licensed under the MIT License.
4#
5"""Unit tests for mlos_viz."""
7import random
8import warnings
9from unittest.mock import Mock, patch
11from mlos_bench.storage.base_experiment_data import ExperimentData
12from mlos_viz import MlosVizMethod, plot
13from mlos_viz.tests import BASE_MATPLOTLIB_SHOW_PATCH, SEABORN_BOXPLOT_PATCH
16def test_auto_method_type() -> None:
17 """Ensure the AUTO method is what we expect."""
18 assert MlosVizMethod.AUTO.value == MlosVizMethod.DABL.value
21@patch(BASE_MATPLOTLIB_SHOW_PATCH)
22@patch(SEABORN_BOXPLOT_PATCH)
23def test_plot(mock_show: Mock, mock_boxplot: Mock, exp_data: ExperimentData) -> None:
24 """Tests core plot() API."""
25 # For now, just ensure that no errors are thrown.
26 # TODO: Check that a plot was actually produced matching our specifications.
27 with warnings.catch_warnings():
28 warnings.simplefilter("error")
29 random.seed(42)
30 plot(exp_data, filter_warnings=True)
31 assert mock_show.call_count >= 2 # from the two base plots and anything dabl did
32 assert mock_boxplot.call_count >= 1 # from anything dabl did