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

Unified 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 side-by-side diff with in-line comments
Download patch
Index: appengine/findit/crash/loglinear/changelist_features/top_frame_index.py
diff --git a/appengine/findit/crash/loglinear/changelist_features/top_frame_index.py b/appengine/findit/crash/loglinear/changelist_features/top_frame_index.py
index 712554285cc93f5e166ccbfd1a1666b31db6a6a2..bc38da2ffa974d7726a062438555ae28d4583b9d 100644
--- a/appengine/findit/crash/loglinear/changelist_features/top_frame_index.py
+++ b/appengine/findit/crash/loglinear/changelist_features/top_frame_index.py
@@ -50,21 +50,38 @@ class TopFrameIndexFeature(Feature):
"""The minimum ``StackFrame.index`` across all files and stacks.
Args:
- report (CrashReport): the crash report being analyzed.
+ report (CrashReportWithDependencies): the crash report being analyzed.
Returns:
A function from ``Suspect`` to the scaled minimum frame index, as a
log-domain ``float``.
"""
- def FeatureValueGivenReport(result):
- if not result.file_to_stack_infos:
- logging.warning('No StackInfo for any file: %s' % str(result))
- return FeatureValue(self.name, lmath.LOG_ZERO,
- "No StackInfo for any file", None)
-
- top_frame_index = min(min(frame.index for frame, _ in stack_infos)
- for stack_infos
- in result.file_to_stack_infos.itervalues())
+ def FeatureValueGivenReport(
+ suspect, touched_file_to_stack_infos): # pylint: disable=W0613
+ """Computes ``FeatureValue`` for a suspect.
+
+ Args:
+ suspect (Suspect): The suspected changelog and some meta information
+ about it.
+ touched_file_to_stack_infos(dict): Dict mapping ``FileChangeInfo`` to
+ a list of ``StackInfo``s representing all the frames that the suspect
+ touched.
+
+ Returns:
+ The ``FeatureValue`` of this feature.
+ """
+ if not touched_file_to_stack_infos:
+ return FeatureValue(
+ self.name, lmath.LOG_ZERO,
+ 'No frame got touched by the suspect.', None)
+
+ def TopFrameIndexForTouchedFile(stack_infos):
+ return min([stack_info.frame.index for stack_info in stack_infos])
+
+ top_frame_index = min([
+ TopFrameIndexForTouchedFile(stack_infos) for _, stack_infos in
+ touched_file_to_stack_infos.iteritems()])
+
return FeatureValue(
name = self.name,
value = LogLinearlyScaled(float(top_frame_index),

Powered by Google App Engine
This is Rietveld 408576698