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