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

Side by Side Diff: appengine/findit/crash/loglinear/changelist_features/top_frame_index.py

Issue 2704843002: [Predator] Add TouchCrashedDirectory feature. (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
1 # Copyright 2016 The Chromium Authors. All rights reserved. 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 2 # Use of this source code is governed by a BSD-style license that can be
3 # found in the LICENSE file. 3 # found in the LICENSE file.
4 4
5 import logging 5 import logging
6 6
7 from crash.loglinear.feature import Feature 7 from crash.loglinear.feature import Feature
8 from crash.loglinear.feature import FeatureValue 8 from crash.loglinear.feature import FeatureValue
9 from crash.loglinear.feature import LogLinearlyScaled 9 from crash.loglinear.feature import LogLinearlyScaled
10 import libs.math.logarithms as lmath 10 import libs.math.logarithms as lmath
(...skipping 26 matching lines...) Expand all
37 self.max_frame_index = max_frame_index 37 self.max_frame_index = max_frame_index
38 38
39 @property 39 @property
40 def name(self): 40 def name(self):
41 return 'TopFrameIndex' 41 return 'TopFrameIndex'
42 42
43 def __call__(self, report): 43 def __call__(self, report):
44 """The minimum ``StackFrame.index`` across all files and stacks. 44 """The minimum ``StackFrame.index`` across all files and stacks.
45 45
46 Args: 46 Args:
47 report (CrashReportWithDependencies): the crash report being analyzed. 47 report (CrashReport): the crash report being analyzed.
48 48
49 Returns: 49 Returns:
50 A function from ``Suspect`` to the scaled minimum frame index, as a 50 A function from ``Suspect`` to the scaled minimum frame index, as a
51 log-domain ``float``. 51 log-domain ``float``.
52 """ 52 """
53 def FeatureValueGivenReport( 53 def FeatureValueGivenReport(suspect, matches): # pylint: disable=W0613
54 suspect, touched_file_to_stack_infos): # pylint: disable=W0613
55 """Computes ``FeatureValue`` for a suspect. 54 """Computes ``FeatureValue`` for a suspect.
56 55
57 Args: 56 Args:
58 suspect (Suspect): The suspected changelog and some meta information 57 suspect (Suspect): The suspected changelog and some meta information
59 about it. 58 about it.
60 touched_file_to_stack_infos(dict): Dict mapping ``FileChangeInfo`` to 59 matches(dict): Dict mapping crashed group(CrashedFile, CrashedDirectory)
61 a list of ``StackInfo``s representing all the frames that the suspect 60 to a list of ``Match``s representing all frames and all touched files
62 touched. 61 matched in the same crashed group(same crashed file or crashed
62 directory).
63 63
64 Returns: 64 Returns:
65 The ``FeatureValue`` of this feature. 65 The ``FeatureValue`` of this feature.
66 """ 66 """
67 if not touched_file_to_stack_infos: 67 if not matches:
68 return FeatureValue( 68 return FeatureValue(
69 self.name, lmath.LOG_ZERO, 69 self.name, lmath.LOG_ZERO,
70 'No frame got touched by the suspect.', None) 70 'No frame got touched by the suspect.', None)
71 71
72 def TopFrameIndexForTouchedFile(stack_infos): 72 def TopFrameIndexForTouchedFile(frame_infos):
73 return min([stack_info.frame.index for stack_info in stack_infos]) 73 return min([frame_info.frame.index for frame_info in frame_infos])
74 74
75 top_frame_index = min([ 75 top_frame_index = min([TopFrameIndexForTouchedFile(match.frame_infos)
76 TopFrameIndexForTouchedFile(stack_infos) for _, stack_infos in 76 for match in matches.itervalues()])
77 touched_file_to_stack_infos.iteritems()])
78 77
79 return FeatureValue( 78 return FeatureValue(
80 name = self.name, 79 name = self.name,
81 value = LogLinearlyScaled(float(top_frame_index), 80 value = LogLinearlyScaled(float(top_frame_index),
82 float(self.max_frame_index)), 81 float(self.max_frame_index)),
83 reason = ('Top frame is #%d' % top_frame_index), 82 reason = ('Top frame is #%d' % top_frame_index),
84 changed_files = None) 83 changed_files = None)
85 84
86 return FeatureValueGivenReport 85 return FeatureValueGivenReport
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698