From 2ee9b40527fb2b1278a893d40a30e1f0862579c3 Mon Sep 17 00:00:00 2001 From: Sergei Trofimov Date: Wed, 10 Jun 2015 15:04:18 +0100 Subject: [PATCH] classifiers: usability updates - add IterationResult-level classifiers that get merged into every added metric (saves having to pass the same classifiers to each metric added). - Added a global alias to csv result processor's use_all_classifiers attribute. --- wlauto/core/result.py | 5 ++++- wlauto/result_processors/standard.py | 1 + 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/wlauto/core/result.py b/wlauto/core/result.py index 38a052b0..bacb228c 100644 --- a/wlauto/core/result.py +++ b/wlauto/core/result.py @@ -44,7 +44,7 @@ from datetime import datetime from wlauto.core.extension import Extension from wlauto.exceptions import WAError from wlauto.utils.types import numeric -from wlauto.utils.misc import enum_metaclass +from wlauto.utils.misc import enum_metaclass, merge_dicts class ResultManager(object): @@ -260,8 +260,11 @@ class IterationResult(object): self.events = [] self.metrics = [] self.artifacts = [] + self.classifiers = {} def add_metric(self, name, value, units=None, lower_is_better=False, classifiers=None): + classifiers = merge_dicts(self.classifiers, classifiers or {}, + list_duplicates='last', should_normalize=False) self.metrics.append(Metric(name, value, units, lower_is_better, classifiers)) def has_metric(self, name): diff --git a/wlauto/result_processors/standard.py b/wlauto/result_processors/standard.py index 6ff058e4..b96c5cdc 100644 --- a/wlauto/result_processors/standard.py +++ b/wlauto/result_processors/standard.py @@ -67,6 +67,7 @@ class CsvReportProcessor(ResultProcessor): parameters = [ Parameter('use_all_classifiers', kind=bool, default=False, + global_alias='use_all_classifiers', description=""" If set to ``True``, this will add a column for every classifier that features in at least one collected metric.