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

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

Issue 2644543006: [Culprit-Finder] Add generator cache decorator. (Closed)
Patch Set: Rebase and fix nits. 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
« no previous file with comments | « no previous file | appengine/findit/gae_libs/gitiles/cached_gitiles_repository.py » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 import math 6 import math
7 7
8 from crash.loglinear.feature import ChangedFile 8 from crash.loglinear.feature import ChangedFile
9 from crash.loglinear.feature import Feature 9 from crash.loglinear.feature import Feature
10 from crash.loglinear.feature import FeatureValue 10 from crash.loglinear.feature import FeatureValue
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after
66 message = 'No AnalysisInfo for any file in suspect: %s' % str(suspect) 66 message = 'No AnalysisInfo for any file in suspect: %s' % str(suspect)
67 logging.warning(message) 67 logging.warning(message)
68 return FeatureValue(self.name, lmath.LOG_ZERO, message, None) 68 return FeatureValue(self.name, lmath.LOG_ZERO, message, None)
69 69
70 min_distance = min(per_file_analysis.min_distance 70 min_distance = min(per_file_analysis.min_distance
71 for per_file_analysis in analyses.itervalues()) 71 for per_file_analysis in analyses.itervalues())
72 72
73 return FeatureValue( 73 return FeatureValue(
74 name = self.name, 74 name = self.name,
75 value = LogLinearlyScaled(float(min_distance), float(self._maximum)), 75 value = LogLinearlyScaled(float(min_distance), float(self._maximum)),
76 reason = ('Minimum distance is %d' % min_distance), 76 reason = ('Minimum distance is %d' % min_distance
77 if not math.isinf(min_distance) else
78 'Minimum distance is infinity'),
77 changed_files = self._ChangedFiles(suspect), 79 changed_files = self._ChangedFiles(suspect),
78 ) 80 )
79 81
80 return FeatureValueGivenReport 82 return FeatureValueGivenReport
81 83
82 def _ChangedFiles(self, suspect): 84 def _ChangedFiles(self, suspect):
83 """Get all the changed files causing this feature to blame this suspect. 85 """Get all the changed files causing this feature to blame this suspect.
84 86
85 Arg: 87 Arg:
86 suspect (Suspect): the suspect being blamed. 88 suspect (Suspect): the suspect being blamed.
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
118 ) 120 )
119 121
120 if not index_to_changed_files: # pragma: no cover 122 if not index_to_changed_files: # pragma: no cover
121 logging.warning('Found no changed files for suspect: %s', str(suspect)) 123 logging.warning('Found no changed files for suspect: %s', str(suspect))
122 124
123 # Sort changed file by frame index. 125 # Sort changed file by frame index.
124 _, changed_files = zip(*sorted(index_to_changed_files.items(), 126 _, changed_files = zip(*sorted(index_to_changed_files.items(),
125 key=lambda x: x[0])) 127 key=lambda x: x[0]))
126 128
127 return list(changed_files) 129 return list(changed_files)
OLDNEW
« no previous file with comments | « no previous file | appengine/findit/gae_libs/gitiles/cached_gitiles_repository.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698