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

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

Issue 2613153006: [Predator] Add TouchCrashedFileMetaFeature. (Closed)
Patch Set: Created 3 years, 11 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 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
43 self.max_frame_index = max_frame_index 43 self.max_frame_index = max_frame_index
44 44
45 @property 45 @property
46 def name(self): 46 def name(self):
47 return 'TopFrameIndex' 47 return 'TopFrameIndex'
48 48
49 def __call__(self, report): 49 def __call__(self, report):
50 """The minimum ``StackFrame.index`` across all files and stacks. 50 """The minimum ``StackFrame.index`` across all files and stacks.
51 51
52 Args: 52 Args:
53 report (CrashReport): the crash report being analyzed. 53 report (CrashReportWithDependencies): the crash report being analyzed.
54 54
55 Returns: 55 Returns:
56 A function from ``Suspect`` to the scaled minimum frame index, as a 56 A function from ``Suspect`` to the scaled minimum frame index, as a
57 log-domain ``float``. 57 log-domain ``float``.
58 """ 58 """
59 def FeatureValueGivenReport(result): 59 def FeatureValueGivenReport(
60 if not result.file_to_stack_infos: 60 suspect, touched_file_to_stack_infos): # pylint: disable=W0613
61 logging.warning('No StackInfo for any file: %s' % str(result)) 61 """Computes ``FeatureValue`` for a suspect.
62 return FeatureValue(self.name, lmath.LOG_ZERO,
63 "No StackInfo for any file", None)
64 62
65 top_frame_index = min(min(frame.index for frame, _ in stack_infos) 63 Args:
66 for stack_infos 64 suspect (Suspect): The suspected changelog and some meta information
67 in result.file_to_stack_infos.itervalues()) 65 about it.
66 touched_file_to_stack_infos(dict): Dict mapping ``FileChangeInfo`` to
67 a list of ``StackInfo``s representing all the frames that the suspect
68 touched.
69
70 Returns:
71 The ``FeatureValue`` of this feature.
72 """
73 if not touched_file_to_stack_infos:
74 return FeatureValue(
75 self.name, lmath.LOG_ZERO,
76 'No frame got touched by the suspect.', None)
77
78 def TopFrameIndexForTouchedFile(stack_infos):
79 return min([stack_info.frame.index for stack_info in stack_infos])
80
81 top_frame_index = min([
82 TopFrameIndexForTouchedFile(stack_infos) for _, stack_infos in
83 touched_file_to_stack_infos.iteritems()])
84
68 return FeatureValue( 85 return FeatureValue(
69 name = self.name, 86 name = self.name,
70 value = LogLinearlyScaled(float(top_frame_index), 87 value = LogLinearlyScaled(float(top_frame_index),
71 float(self.max_frame_index)), 88 float(self.max_frame_index)),
72 reason = ('Top frame is #%d' % top_frame_index), 89 reason = ('Top frame is #%d' % top_frame_index),
73 changed_files = None) 90 changed_files = None)
74 91
75 return FeatureValueGivenReport 92 return FeatureValueGivenReport
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698