"""Temporary dispatching functionality for backward compatibility."""importwarningsfromtypingimportAny,Literalfrombaybe.objectives.desirabilityimportDesirabilityObjectivefrombaybe.objectives.singleimportSingleTargetObjectivefrombaybe.targets.baseimportTarget
[docs]defObjective(mode:Literal["SINGLE","DESIRABILITY"],targets:list[Target],weights:list[float]|None=None,combine_func:Literal["MEAN","GEOM_MEAN"]|None=None,):"""Return the appropriate new-style class depending on the mode."""warnings.warn("The use of `baybe.objective` is deprecated and will be disabled in ""a future version. Use the classes defined in `baybe.objectives` instead.",DeprecationWarning,)ifmode=="SINGLE":iflen(targets)!=1:raiseValueError("In 'SINGLE' mode, you must provide exactly one target.")returnSingleTargetObjective(targets[0])elifmode=="DESIRABILITY":kwargs:dict[str,Any]={}ifweightsisnotNone:kwargs["weights"]=weightsifcombine_funcisnotNone:kwargs["scalarizer"]=combine_funcreturnDesirabilityObjective(targets,**kwargs)else:raiseValueError(f"Unknown mode: {mode}")