Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(195)

Side by Side Diff: appengine/findit/crash/scorers/aggregators.py

Issue 2707603002: [Predator] Generate all changelogs in regression ranges instead of only matched changelogs (Closed)
Patch Set: . Created 3 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
(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 """Aggregator aggregates scorer results list passed in."""
6
7 class Aggregator(object):
8
9 def Aggregate(self, data_list):
10 raise NotImplementedError()
11
12 def __call__(self, data_list):
13 data_list = filter(lambda data: not data is None, data_list)
14 if not data_list:
15 return None
16
17 return self.Aggregate(data_list)
18
19
20 # TODO(katesonia): Compare this mutiply aggregator with a vector of scores
21 # aggregator later.
22 class Multiplier(Aggregator):
23
24 def Aggregate(self, data_list):
25 result = 1.0
26 for data in data_list:
27 result *= data
28
29 return result
30
31
32 class IdentityAggregator(Aggregator):
33
34 def Aggregate(self, data_list):
35 return data_list
36
37
38 # TODO(crbug.com/674231): DRY vs
39 # crash/loglinear/changelist_classifier.py's ``AggregateChangedFiles``.
40 class ChangedFilesAggregator(Aggregator):
41 """Aggregates a list of changed files got from many scorers.
42
43 Note: This Aggregator only aggregates the info part of each changed file.
44
45 For example, the data_list is:
46 [
47 [
48 {
49 'file': 'f1',
50 'blame_url': 'https://blame1',
51 'info': 'f1 info scorer1'
52 },
53 {
54 'file': 'f2',
55 'blame_url': 'https://blame2',
56 'info': 'f2 info scorer1'
57 }
58 ],
59 [
60 {
61 'file': 'f1',
62 'blame_url': 'https://blame1',
63 'info': 'f1 info scorer2'
64 },
65 {
66 'file': 'f2',
67 'blame_url': 'https://blame2',
68 'info': 'f2 info scorer2'
69 }
70 ]
71 ]
72
73 Aggregated result should be:
74 [
75 {
76 'file': 'f1',
77 'blame_url': 'https://blame1',
78 'info': 'f1 info scorer1\nf1 info scorer2'
79 },
80 {
81 'file': 'f2',
82 'blame_url': 'https://blame2',
83 'info': 'f2 info scorer1\nf2 info scorer2'
84 }
85 ]
86 """
87
88 def Aggregate(self, data_list):
89
90 def AggregateFileInfos(file_info_list):
91 """Aggregates file infos from different scorers for one file."""
92 infos = []
93 for file_info in file_info_list:
94 if file_info['info']:
95 infos.append(file_info['info'])
96
97 return {
98 'file': file_info_list[0]['file'],
99 'blame_url': file_info_list[0]['blame_url'],
100 'info': '\n'.join(infos)
101 }
102
103 aggregated_changed_files = []
104 for data in zip(*data_list):
105 aggregated_changed_files.append(AggregateFileInfos(data))
106
107 return aggregated_changed_files
OLDNEW
« no previous file with comments | « appengine/findit/crash/scorers/aggregated_scorer.py ('k') | appengine/findit/crash/scorers/min_distance.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698