Coverage for mlos_viz/mlos_viz/tests/test_base_plot.py: 100%
20 statements
« prev ^ index » next coverage.py v7.5.1, created at 2024-05-05 00:36 +0000
« prev ^ index » next coverage.py v7.5.1, created at 2024-05-05 00:36 +0000
1#
2# Copyright (c) Microsoft Corporation.
3# Licensed under the MIT License.
4#
5"""
6Unit tests for mlos_viz.
7"""
9import warnings
11from unittest.mock import patch, Mock
13from mlos_bench.storage.base_experiment_data import ExperimentData
15from mlos_viz.base import ignore_plotter_warnings, plot_optimizer_trends, plot_top_n_configs
17from mlos_viz.tests import BASE_MATPLOTLIB_SHOW_PATCH
20@patch(BASE_MATPLOTLIB_SHOW_PATCH)
21def test_plot_optimizer_trends(mock_show: Mock, exp_data: ExperimentData) -> None:
22 """Tests plotting optimizer trends."""
23 # For now, just ensure that no errors are thrown.
24 # TODO: Check that a plot was actually produced matching our specifications.
25 with warnings.catch_warnings():
26 warnings.simplefilter("error")
27 ignore_plotter_warnings()
28 plot_optimizer_trends(exp_data)
29 assert mock_show.call_count == 1
32@patch(BASE_MATPLOTLIB_SHOW_PATCH)
33def test_plot_top_n_configs(mock_show: Mock, exp_data: ExperimentData) -> None:
34 """Tests plotting top N configs."""
35 # For now, just ensure that no errors are thrown.
36 # TODO: Check that a plot was actually produced matching our specifications.
37 with warnings.catch_warnings():
38 warnings.simplefilter("error")
39 ignore_plotter_warnings()
40 plot_top_n_configs(exp_data)
41 assert mock_show.call_count == 1