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

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

Issue 1861373003: [Findit] Initial code of findit for crash. Add scorers to apply heuristic rules. (Closed) Base URL: https://chromium.googlesource.com/infra/infra.git@master
Patch Set: Fix nits and doc strings. Created 4 years, 8 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 """MinDistance scorer applies to MatchResult objects.
6
7 It represents a heuristic rule:
8 1. Highest score if the result changed the crashed lines.
9 2. 0 score if changed lines are too far away from crashed lines.
10 """
11
12 import logging
13
14 from crash.scorers.scorer import Scorer
15
16 _MAX_DISTANCE = 50
17
18
19 class MinDistance(Scorer):
20 def __init__(self, max_distance=_MAX_DISTANCE):
21 self.max_distance = max_distance
22
23 def GetMetric(self, result):
24 if not hasattr(result, 'min_distance'):
Martin Barbella 2016/04/15 06:05:24 What would cause this to happen, other than an inc
Sharu 2016/04/15 22:59:47 I add this because I thought later I may add Blame
25 logging.warning('Scorer %s only applies to MatchResult' % self.name)
26 return None
27
28 return result.min_distance
29
30 def Score(self, min_distance):
31 if min_distance > self.max_distance:
32 return 0
33
34 if min_distance == 0:
35 return 1
36
37 return 0.8
stgao 2016/04/15 18:35:19 Where are these numbers from? Some comments in the
Sharu 2016/04/15 22:59:47 Added TODO, Done.
38
39 def Reason(self, min_distance, score):
40 if score == 0:
41 return ''
42
43 return 'Minimum distance to crashed line is %d' % min_distance
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698