OLD | NEW |
1 #!/usr/bin/python | 1 #!/usr/bin/python |
2 | 2 |
3 """ | 3 """ |
4 Copyright 2013 Google Inc. | 4 Copyright 2013 Google Inc. |
5 | 5 |
6 Use of this source code is governed by a BSD-style license that can be | 6 Use of this source code is governed by a BSD-style license that can be |
7 found in the LICENSE file. | 7 found in the LICENSE file. |
8 | 8 |
9 Repackage expected/actual GM results as needed by our HTML rebaseline viewer. | 9 Repackage expected/actual GM results as needed by our HTML rebaseline viewer. |
10 """ | 10 """ |
(...skipping 414 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
425 if expectations_per_test: | 425 if expectations_per_test: |
426 for field in FIELDS_PASSED_THRU_VERBATIM: | 426 for field in FIELDS_PASSED_THRU_VERBATIM: |
427 results_for_this_test[field] = expectations_per_test.get(field) | 427 results_for_this_test[field] = expectations_per_test.get(field) |
428 | 428 |
429 if updated_result_type == gm_json.JSONKEY_ACTUALRESULTS_NOCOMPARISON: | 429 if updated_result_type == gm_json.JSONKEY_ACTUALRESULTS_NOCOMPARISON: |
430 pass # no diff record to calculate at all | 430 pass # no diff record to calculate at all |
431 elif updated_result_type == gm_json.JSONKEY_ACTUALRESULTS_SUCCEEDED: | 431 elif updated_result_type == gm_json.JSONKEY_ACTUALRESULTS_SUCCEEDED: |
432 results_for_this_test['numDifferingPixels'] = 0 | 432 results_for_this_test['numDifferingPixels'] = 0 |
433 results_for_this_test['percentDifferingPixels'] = 0 | 433 results_for_this_test['percentDifferingPixels'] = 0 |
434 results_for_this_test['weightedDiffMeasure'] = 0 | 434 results_for_this_test['weightedDiffMeasure'] = 0 |
435 results_for_this_test['perceptualDifference'] = 0 | |
436 results_for_this_test['maxDiffPerChannel'] = 0 | 435 results_for_this_test['maxDiffPerChannel'] = 0 |
437 else: | 436 else: |
438 try: | 437 try: |
439 diff_record = self._image_diff_db.get_diff_record( | 438 diff_record = self._image_diff_db.get_diff_record( |
440 expected_image_locator=expected_image[1], | 439 expected_image_locator=expected_image[1], |
441 actual_image_locator=actual_image[1]) | 440 actual_image_locator=actual_image[1]) |
442 results_for_this_test['numDifferingPixels'] = ( | 441 results_for_this_test['numDifferingPixels'] = ( |
443 diff_record.get_num_pixels_differing()) | 442 diff_record.get_num_pixels_differing()) |
444 results_for_this_test['percentDifferingPixels'] = ( | 443 results_for_this_test['percentDifferingPixels'] = ( |
445 diff_record.get_percent_pixels_differing()) | 444 diff_record.get_percent_pixels_differing()) |
446 results_for_this_test['weightedDiffMeasure'] = ( | 445 results_for_this_test['weightedDiffMeasure'] = ( |
447 diff_record.get_weighted_diff_measure()) | 446 diff_record.get_weighted_diff_measure()) |
448 results_for_this_test['perceptualDifference'] = ( | |
449 diff_record.get_perceptual_difference()) | |
450 results_for_this_test['maxDiffPerChannel'] = ( | 447 results_for_this_test['maxDiffPerChannel'] = ( |
451 diff_record.get_max_diff_per_channel()) | 448 diff_record.get_max_diff_per_channel()) |
452 except KeyError: | 449 except KeyError: |
453 logging.warning('unable to find diff_record for ("%s", "%s")' % | 450 logging.warning('unable to find diff_record for ("%s", "%s")' % |
454 (expected_image[1], actual_image[1])) | 451 (expected_image[1], actual_image[1])) |
455 pass | 452 pass |
456 | 453 |
457 Results._add_to_category_dict(categories_all, results_for_this_test) | 454 Results._add_to_category_dict(categories_all, results_for_this_test) |
458 data_all.append(results_for_this_test) | 455 data_all.append(results_for_this_test) |
459 | 456 |
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
536 help='Directory within which to download images and generate diffs') | 533 help='Directory within which to download images and generate diffs') |
537 args = parser.parse_args() | 534 args = parser.parse_args() |
538 results = Results(actuals_root=args.actuals, | 535 results = Results(actuals_root=args.actuals, |
539 expected_root=args.expectations, | 536 expected_root=args.expectations, |
540 generated_images_root=args.workdir) | 537 generated_images_root=args.workdir) |
541 gm_json.WriteToFile(results.get_results_of_type(RESULTS_ALL), args.outfile) | 538 gm_json.WriteToFile(results.get_results_of_type(RESULTS_ALL), args.outfile) |
542 | 539 |
543 | 540 |
544 if __name__ == '__main__': | 541 if __name__ == '__main__': |
545 main() | 542 main() |
OLD | NEW |