| OLD | NEW |
| (Empty) |
| 1 # Copyright 2016 The Chromium Authors. All rights reserved. | |
| 2 # Use of this source code is governed by a BSD-style license that can be | |
| 3 # found in the LICENSE file. | |
| 4 | |
| 5 """Aggregated scorer which uses aggregators to aggregate results from | |
| 6 different scorers.""" | |
| 7 | |
| 8 from crash.scorers import aggregators | |
| 9 | |
| 10 | |
| 11 class AggregatedScorer(object): | |
| 12 | |
| 13 def __init__(self, scorers): | |
| 14 self.scorers = scorers | |
| 15 | |
| 16 def Score(self, result, | |
| 17 score_aggregator=aggregators.Multiplier(), | |
| 18 reasons_aggregator=aggregators.IdentityAggregator(), | |
| 19 changed_files_aggregator=aggregators.ChangedFilesAggregator()): | |
| 20 """Aggregates score, reasons and changed_files from all the scorers. | |
| 21 | |
| 22 Note: This method sets confidence, reasons and changed_files of results. | |
| 23 """ | |
| 24 # Transforms array of [(score1, reason1, changed_files1), (score2, reason2, | |
| 25 # changed_files2)] to [(score1, score2), (reason1, reason2), | |
| 26 # (changed_files1, changed_files2)] for aggregators to aggregate. | |
| 27 scores, reasons, changed_files = zip(*[ | |
| 28 scorer(result) for scorer in self.scorers]) | |
| 29 | |
| 30 result.confidence = score_aggregator(list(scores)) | |
| 31 result.reasons = reasons_aggregator(list(reasons)) | |
| 32 result.changed_files = changed_files_aggregator(list(changed_files)) | |
| 33 | |
| 34 return result.confidence, result.reasons, result.changed_files | |
| OLD | NEW |