def __init__(self, page, name, units, raw_value=None, raw_value_json=None, important=True, description=None, tir_label=None, improvement_direction=None, grouping_keys=None): super(HistogramValue, self).__init__(page, name, units, important, description, tir_label, improvement_direction, grouping_keys) if raw_value_json: assert raw_value == None, \ 'Don\'t specify both raw_value and raw_value_json' raw_value = json.loads(raw_value_json) if raw_value: self.buckets = [] for bucket in histogram_util.GetHistogramBucketsFromRawValue( raw_value): self.buckets.append( HistogramValueBucket(low=bucket['low'], high=bucket['high'], count=bucket['count'])) else: self.buckets = []
def testGetHistogramBucketsFromRawValue_Max(self): raw_value = {'buckets': [ {'count': 4, 'low': 10, 'high': 15,}, {'count': 6, 'low': 16, 'high': 18,}, {'count': 8, 'low': 19}, ]} buckets = histogram_util.GetHistogramBucketsFromRawValue(raw_value) self.assertEquals([ {'count': 4, 'low': 10, 'high': 15,}, {'count': 6, 'low': 16, 'high': 18,}, {'count': 8, 'low': 19, 'high': 19},], buckets)