Ejemplo n.º 1
0
    def testClone(self):
        metric1 = Metric(name="m1", lower_is_better=False)
        self.assertEqual(metric1, metric1.clone())

        metric2 = get_branin_metric(name="branin")
        self.assertEqual(metric2, metric2.clone())

        metric3 = get_factorial_metric(name="factorial")
        self.assertEqual(metric3, metric3.clone())
Ejemplo n.º 2
0
    def __init__(
        self,
        metric: Metric,
        bound: float,
        relative: bool = False,
        op: Optional[ComparisonOp] = None,
    ) -> None:
        if metric.lower_is_better is None and op is None:
            raise ValueError((
                f"Metric {metric} must have attribute `lower_is_better` set or "
                f"op {op} must be manually specified."))
        elif op is None:
            op = ComparisonOp.LEQ if metric.lower_is_better else ComparisonOp.GEQ

        # It's likely that the metric passed into the ObjectiveThreshold constructor
        # is the same instance as the metric in the Objective. Thus, we have to clone
        # the metric passed in here to ensure a 1:1 relationship between user-facing
        # objects and DB objects.
        super().__init__(metric=metric.clone(),
                         op=op,
                         bound=bound,
                         relative=relative)
 def testClone(self):
     metric1 = Metric(name="m1", lower_is_better=False)
     self.assertEqual(metric1, metric1.clone())