Coverage for sparkle/configurator/implementations/__init__.py: 90%

10 statements  

« prev     ^ index     » next       coverage.py v7.10.7, created at 2025-09-29 10:17 +0000

1"""This package provides specific Configurator class implementations for Sparkle.""" 

2 

3from sparkle.configurator.configurator import Configurator 

4from sparkle.configurator.implementations.irace import IRACE, IRACEScenario 

5from sparkle.configurator.implementations.paramils import ParamILS, ParamILSScenario 

6from sparkle.configurator.implementations.smac2 import SMAC2, SMAC2Scenario 

7from sparkle.configurator.implementations.smac3 import SMAC3, SMAC3Scenario 

8 

9 

10def resolve_configurator(configurator_name: str) -> Configurator: 

11 """Returns the Configurator subclass by name.""" 

12 subclass_names = [ 

13 IRACE.__name__, 

14 ParamILS.__name__, 

15 SMAC2.__name__, 

16 SMAC3.__name__, 

17 ] 

18 if configurator_name in subclass_names: 

19 return eval(configurator_name) 

20 return None