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

Side by Side Diff: tools/telemetry/telemetry/util/color_histogram.py

Issue 1458083003: [Telemetry + tools/perf] Modify the pylint disable message to use symbolic name (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 1 month 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 # Copyright 2014 The Chromium Authors. All rights reserved. 1 # Copyright 2014 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 """Color Histograms and implementations of functions operating on them.""" 5 """Color Histograms and implementations of functions operating on them."""
6 6
7 from __future__ import division 7 from __future__ import division
8 8
9 import collections 9 import collections
10 10
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
46 remainder += value1 * n2 - value2 * n1 46 remainder += value1 * n2 - value2 * n1
47 total += abs(remainder) 47 total += abs(remainder)
48 assert remainder == 0, ( 48 assert remainder == 0, (
49 '%s pixel(s) left over after computing histogram distance.' 49 '%s pixel(s) left over after computing histogram distance.'
50 % abs(remainder)) 50 % abs(remainder))
51 return abs(float(total) / n1 / n2) 51 return abs(float(total) / n1 / n2)
52 52
53 53
54 class ColorHistogram( 54 class ColorHistogram(
55 collections.namedtuple('ColorHistogram', ['r', 'g', 'b', 'default_color'])): 55 collections.namedtuple('ColorHistogram', ['r', 'g', 'b', 'default_color'])):
56 # pylint: disable=W0232 56 # pylint: disable=no-init
57 # pylint: disable=E1002 57 # pylint: disable=E1002
58 58
59 def __new__(cls, r, g, b, default_color=None): 59 def __new__(cls, r, g, b, default_color=None):
60 return super(ColorHistogram, cls).__new__(cls, r, g, b, default_color) 60 return super(ColorHistogram, cls).__new__(cls, r, g, b, default_color)
61 61
62 def Distance(self, other): 62 def Distance(self, other):
63 total = 0 63 total = 0
64 for i in xrange(3): 64 for i in xrange(3):
65 default_color = self[3][i] if self[3] is not None else None 65 default_color = self[3][i] if self[3] is not None else None
66 total += HistogramDistance(self[i], other[i], default_color) 66 total += HistogramDistance(self[i], other[i], default_color)
67 return total 67 return total
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698