Skip to content

Commit

Permalink
Bug 1428045 - Replace cmp with modern ordering methods
Browse files Browse the repository at this point in the history
  • Loading branch information
ghickman authored and edmorley committed Mar 21, 2018
1 parent 8aaeb81 commit b987884
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions treeherder/perfalert/perfalert/__init__.py
@@ -1,4 +1,5 @@
import copy
import functools


def analyze(revision_data, weight_fn=None):
Expand Down Expand Up @@ -72,6 +73,7 @@ def calc_t(w1, w2, weight_fn=None):
return delta_s / (((s1['variance'] / s1['n']) + (s2['variance'] / s2['n'])) ** 0.5)


@functools.total_ordering
class RevisionDatum(object):
'''
This class represents a specific revision and the set of values for it
Expand All @@ -94,8 +96,11 @@ def __init__(self, push_timestamp, push_id, values):
# Whether a perf regression or improvement was found
self.change_detected = False

def __cmp__(self, o):
return cmp(self.push_timestamp, o.push_timestamp)
def __eq__(self, o):
return self.push_timestamp == o.push_timestamp

def __lt__(self, o):
return self.push_timestamp < o.push_timestamp

def __repr__(self):
values_str = '[ %s ]' % ', '.join(['%.3f' % value for value in
Expand Down

0 comments on commit b987884

Please sign in to comment.