Chromium Code Reviews| OLD | NEW |
|---|---|
| 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 collections | 5 import collections |
| 6 import logging | 6 import logging |
| 7 import os | 7 import os |
| 8 | 8 |
| 9 from google.appengine.api import taskqueue | 9 from google.appengine.api import taskqueue |
| 10 from google.appengine.ext import ndb | 10 from google.appengine.ext import ndb |
| (...skipping 252 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 263 result_values = [] | 263 result_values = [] |
| 264 for change in self._changes: | 264 for change in self._changes: |
| 265 change_result_values = [] | 265 change_result_values = [] |
| 266 | 266 |
| 267 change_results_per_quest = _CombineResultsPerQuest(self._attempts[change]) | 267 change_results_per_quest = _CombineResultsPerQuest(self._attempts[change]) |
| 268 for quest in self._quests: | 268 for quest in self._quests: |
| 269 change_result_values.append(change_results_per_quest[quest]) | 269 change_result_values.append(change_results_per_quest[quest]) |
| 270 | 270 |
| 271 result_values.append(change_result_values) | 271 result_values.append(change_result_values) |
| 272 | 272 |
| 273 execution_details = [] | |
|
dtu
2017/08/21 23:52:52
I don't see a clear advantage of this format over
shatch
2017/08/22 01:23:55
Done.
| |
| 274 for change in self._changes: | |
| 275 change_results_per_quest = _CombineExecutionDetailsPerQuest( | |
| 276 self._attempts[change]) | |
| 277 | |
| 278 change_result_values = [] | |
| 279 for quest in self._quests: | |
| 280 change_result_values.append(change_results_per_quest[quest]) | |
| 281 | |
| 282 execution_details.append(change_result_values) | |
| 283 | |
| 273 return { | 284 return { |
| 274 'quests': map(str, self._quests), | 285 'quests': map(str, self._quests), |
| 275 'changes': map(str, self._changes), | 286 'changes': map(str, self._changes), |
| 276 'comparisons': comparisons, | 287 'comparisons': comparisons, |
| 277 'result_values': result_values, | 288 'result_values': result_values, |
| 289 'execution_details': execution_details, | |
|
dtu
2017/08/21 23:52:52
nit: executions
| |
| 278 } | 290 } |
| 279 | 291 |
| 280 def _Compare(self, change_a, change_b): | 292 def _Compare(self, change_a, change_b): |
| 281 attempts_a = self._attempts[change_a] | 293 attempts_a = self._attempts[change_a] |
| 282 attempts_b = self._attempts[change_b] | 294 attempts_b = self._attempts[change_b] |
| 283 | 295 |
| 284 if any(not attempt.completed for attempt in attempts_a + attempts_b): | 296 if any(not attempt.completed for attempt in attempts_a + attempts_b): |
| 285 return _PENDING | 297 return _PENDING |
| 286 | 298 |
| 287 results_a = _CombineResultsPerQuest(attempts_a) | 299 results_a = _CombineResultsPerQuest(attempts_a) |
| (...skipping 18 matching lines...) Expand all Loading... | |
| 306 for attempt in attempts: | 318 for attempt in attempts: |
| 307 if not attempt.completed: | 319 if not attempt.completed: |
| 308 continue | 320 continue |
| 309 | 321 |
| 310 for quest, results in attempt.result_values.iteritems(): | 322 for quest, results in attempt.result_values.iteritems(): |
| 311 aggregate_results[quest] += results | 323 aggregate_results[quest] += results |
| 312 | 324 |
| 313 return aggregate_results | 325 return aggregate_results |
| 314 | 326 |
| 315 | 327 |
| 328 def _CombineExecutionDetailsPerQuest(attempts): | |
| 329 aggregate_results = collections.defaultdict(list) | |
| 330 for attempt in attempts: | |
| 331 for quest, results in attempt.AsDictPerQuest().iteritems(): | |
| 332 aggregate_results[quest].append(results) | |
| 333 | |
| 334 return aggregate_results | |
| 335 | |
| 336 | |
| 316 def _CompareResults(results_a, results_b): | 337 def _CompareResults(results_a, results_b): |
| 317 if len(results_a) == 0 or len(results_b) == 0: | 338 if len(results_a) == 0 or len(results_b) == 0: |
| 318 return _UNKNOWN | 339 return _UNKNOWN |
| 319 | 340 |
| 320 try: | 341 try: |
| 321 p_value = mann_whitney_u.MannWhitneyU(results_a, results_b) | 342 p_value = mann_whitney_u.MannWhitneyU(results_a, results_b) |
| 322 except ValueError: | 343 except ValueError: |
| 323 return _UNKNOWN | 344 return _UNKNOWN |
| 324 | 345 |
| 325 if p_value < _SIGNIFICANCE_LEVEL: | 346 if p_value < _SIGNIFICANCE_LEVEL: |
| 326 return _DIFFERENT | 347 return _DIFFERENT |
| 327 else: | 348 else: |
| 328 return _UNKNOWN | 349 return _UNKNOWN |
| OLD | NEW |