Coverage for mlos_bench/mlos_bench/tests/optimizers/manual_opt_test.py: 100%

9 statements  

« 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 mock mlos_bench optimizer.""" 

6 

7from mlos_bench.environments.status import Status 

8from mlos_bench.optimizers.manual_optimizer import ManualOptimizer 

9 

10# pylint: disable=redefined-outer-name 

11 

12 

13def test_manual_optimizer(manual_opt: ManualOptimizer, mock_configs: list) -> None: 

14 """Make sure that manual optimizer produces consistent suggestions.""" 

15 

16 i = 0 

17 while manual_opt.not_converged(): 

18 tunables = manual_opt.suggest() 

19 assert tunables.get_param_values() == mock_configs[i % len(mock_configs)] 

20 manual_opt.register(tunables, Status.SUCCEEDED, {"score": 123.0}) 

21 i += 1