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

Unified Diff: gm/rebaseline_server/imagepairset.py

Issue 178253010: rebaseline_server: use new intermediate JSON format (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: incorporate Ravi's suggestions 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « gm/rebaseline_server/imagepair_test.py ('k') | gm/rebaseline_server/imagepairset_test.py » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: gm/rebaseline_server/imagepairset.py
diff --git a/gm/rebaseline_server/imagepairset.py b/gm/rebaseline_server/imagepairset.py
index 2e173f537f14e78517e9c4c2c7fd94198251b1d4..26c833e1b0bd95e1c9c39ebb3103307209d5507a 100644
--- a/gm/rebaseline_server/imagepairset.py
+++ b/gm/rebaseline_server/imagepairset.py
@@ -12,7 +12,8 @@ ImagePairSet class; see its docstring below.
import column
# Keys used within dictionary representation of ImagePairSet.
-KEY__COLUMNHEADERS = 'columnHeaders'
+# NOTE: Keep these in sync with static/constants.js
+KEY__EXTRACOLUMNHEADERS = 'extraColumnHeaders'
KEY__IMAGEPAIRS = 'imagePairs'
KEY__IMAGESETS = 'imageSets'
KEY__IMAGESETS__BASE_URL = 'baseUrl'
@@ -55,7 +56,7 @@ class ImagePairSet(object):
extra_columns_dict = image_pair.extra_columns_dict
if extra_columns_dict:
for column_id, value in extra_columns_dict.iteritems():
- self._add_extra_column_entry(column_id, value)
+ self._add_extra_column_value_to_summary(column_id, value)
def set_column_header_factory(self, column_id, column_header_factory):
"""Overrides the default settings for one of the extraColumn headers.
@@ -80,19 +81,36 @@ class ImagePairSet(object):
self._column_header_factories[column_id] = column_header_factory
return column_header_factory
- def _add_extra_column_entry(self, column_id, value):
+ def ensure_extra_column_values_in_summary(self, column_id, values):
+ """Ensure this column_id/value pair is part of the extraColumns summary.
+
+ Args:
+ column_id: string; unique ID of this column
+ value: string; a possible value for this column
+ """
+ for value in values:
+ self._add_extra_column_value_to_summary(
+ column_id=column_id, value=value, addend=0)
+
+ def _add_extra_column_value_to_summary(self, column_id, value, addend=1):
"""Records one column_id/value extraColumns pair found within an ImagePair.
We use this information to generate tallies within the column header
(how many instances we saw of a particular value, within a particular
extraColumn).
+
+ Args:
+ column_id: string; unique ID of this column (must match a key within
+ an ImagePair's extra_columns dictionary)
+ value: string; a possible value for this column
+ addend: integer; how many instances to add to the tally
"""
known_values_for_column = self._extra_column_tallies.get(column_id, None)
if not known_values_for_column:
known_values_for_column = {}
self._extra_column_tallies[column_id] = known_values_for_column
instances_of_this_value = known_values_for_column.get(value, 0)
- instances_of_this_value += 1
+ instances_of_this_value += addend
known_values_for_column[value] = instances_of_this_value
def _column_headers_as_dict(self):
@@ -110,7 +128,7 @@ class ImagePairSet(object):
Uses the KEY__* constants as keys.
"""
return {
- KEY__COLUMNHEADERS: self._column_headers_as_dict(),
+ KEY__EXTRACOLUMNHEADERS: self._column_headers_as_dict(),
KEY__IMAGEPAIRS: self._image_pair_dicts,
KEY__IMAGESETS: [{
KEY__IMAGESETS__BASE_URL: self._base_url,
« no previous file with comments | « gm/rebaseline_server/imagepair_test.py ('k') | gm/rebaseline_server/imagepairset_test.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698