Exemplo n.º 1
0
def test_from_config_to_config(mm):
    mm.is_objective = True
    config = mm.to_config()
    mm2 = Metric.from_config(config)
    assert mm2.name == 'name'
    assert mm2.direction == 'min'
    assert mm2.get_history() == [10, 11]
    assert mm2.is_objective
Exemplo n.º 2
0
    def from_config(config, with_values=True):
        """Generate a MetricsCollection from a configuration dictionary

        Args:
            config - (dict) The configuration dict returned from to_config.
            with_values - (bool) If True, metric values are copied. If False,
                only the metadata is copied. Defaults to True.

        Returns:
            (MetricsCollection) The collection of metrics defined by the config.
        """
        col = MetricsCollection()
        for metric_config in config:
            metric = Metric.from_config(metric_config, with_values=with_values)

            col.add(metric)
            if metric.is_objective:
                col._objective_name = metric.name
        return col