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

Side by Side Diff: gm/rebaseline_server/imagepair.py

Issue 139343018: rebaseline_server: create ImagePairSet-- holds a number of ImagePairs to examine (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Created 6 years, 10 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 #!/usr/bin/python 1 #!/usr/bin/python
2 2
3 """ 3 """
4 Copyright 2014 Google Inc. 4 Copyright 2014 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 ImagePair class (see class docstring for details) 9 ImagePair class (see class docstring for details)
10 """ 10 """
11 11
12 import posixpath 12 import posixpath
13 13
14 # Keys used within ImagePair dictionary representations. 14 # Keys used within ImagePair dictionary representations.
15 KEY_DIFFERENCE_DATA = 'differenceData' 15 KEY__DIFFERENCE_DATA = 'differenceData'
16 KEY_EXPECTATIONS_DATA = 'expectationsData' 16 KEY__EXPECTATIONS_DATA = 'expectations'
epoger 2014/02/11 06:15:40 I started using two underscores to delineate betwe
rmistry 2014/02/12 19:23:56 Sorry I do not follow, single underscores within w
epoger 2014/02/12 19:59:16 I mean, so it's clear that this should be parsed a
rmistry 2014/02/13 12:10:02 Thanks for the explanation.
17 KEY_EXTRA_COLUMN_VALUES = 'extraColumnValues' 17 KEY__EXTRA_COLUMN_VALUES = 'extraColumns'
18 KEY_IMAGE_A_URL = 'imageAUrl' 18 KEY__IMAGE_A_URL = 'imageAUrl'
19 KEY_IMAGE_B_URL = 'imageBUrl' 19 KEY__IMAGE_B_URL = 'imageBUrl'
20 KEY_IS_DIFFERENT = 'isDifferent' 20 KEY__IS_DIFFERENT = 'isDifferent'
21 21
22 22
23 class ImagePair(object): 23 class ImagePair(object):
24 """ 24 """
25 Describes a pair of images, along with optional metadata (pixel difference 25 Describes a pair of images, along with optional metadata (pixel difference
26 metrics, whether to ignore mismatches, etc.) 26 metrics, whether to ignore mismatches, etc.)
27 """ 27 """
28 28
29 def __init__(self, image_diff_db, 29 def __init__(self, image_diff_db,
30 base_url, imageA_relative_url, imageB_relative_url, 30 base_url, imageA_relative_url, imageB_relative_url,
(...skipping 27 matching lines...) Expand all
58 expected_image_url=posixpath.join(base_url, imageA_relative_url), 58 expected_image_url=posixpath.join(base_url, imageA_relative_url),
59 actual_image_locator=imageB_relative_url, 59 actual_image_locator=imageB_relative_url,
60 actual_image_url=posixpath.join(base_url, imageB_relative_url)) 60 actual_image_url=posixpath.join(base_url, imageB_relative_url))
61 self.diff_record = image_diff_db.get_diff_record( 61 self.diff_record = image_diff_db.get_diff_record(
62 expected_image_locator=imageA_relative_url, 62 expected_image_locator=imageA_relative_url,
63 actual_image_locator=imageB_relative_url) 63 actual_image_locator=imageB_relative_url)
64 64
65 def as_dict(self): 65 def as_dict(self):
66 """ 66 """
67 Return a dictionary describing this ImagePair, as needed when constructing 67 Return a dictionary describing this ImagePair, as needed when constructing
68 the JSON representation. Uses the KEY_* constants as keys. 68 the JSON representation. Uses the KEY__* constants as keys.
69 """ 69 """
70 asdict = { 70 asdict = {
71 KEY_IMAGE_A_URL: self.imageA_relative_url, 71 KEY__IMAGE_A_URL: self.imageA_relative_url,
72 KEY_IMAGE_B_URL: self.imageB_relative_url, 72 KEY__IMAGE_B_URL: self.imageB_relative_url,
73 } 73 }
74 if self.expectations_dict: 74 if self.expectations_dict:
75 asdict[KEY_EXPECTATIONS_DATA] = self.expectations_dict 75 asdict[KEY__EXPECTATIONS_DATA] = self.expectations_dict
76 if self.extra_columns_dict: 76 if self.extra_columns_dict:
77 asdict[KEY_EXTRA_COLUMN_VALUES] = self.extra_columns_dict 77 asdict[KEY__EXTRA_COLUMN_VALUES] = self.extra_columns_dict
78 if self.diff_record and (self.diff_record.get_num_pixels_differing() > 0): 78 if self.diff_record and (self.diff_record.get_num_pixels_differing() > 0):
79 asdict[KEY_IS_DIFFERENT] = True 79 asdict[KEY__IS_DIFFERENT] = True
80 asdict[KEY_DIFFERENCE_DATA] = self.diff_record.as_dict() 80 asdict[KEY__DIFFERENCE_DATA] = self.diff_record.as_dict()
81 else: 81 else:
82 asdict[KEY_IS_DIFFERENT] = False 82 asdict[KEY__IS_DIFFERENT] = False
83 return asdict 83 return asdict
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698