Skip to content

Commit 2cdbbd3

Browse files
committed
add __le__ and __ge__
1 parent 587235e commit 2cdbbd3

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

Diff for: test_methodcaller.py

+6-2
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,12 @@ def __repr__(self):
1212
return 'Point({!r:},{!r:},{!r:},{!r:})'.format(self.a, self.b, self.c, self.d)
1313
def __lt__(self, other):
1414
return (self.a < other.a if self.a != other.a else (self.b < other.b if self.b != other.b else (self.c < other.c if self.c != other.c else self.d < other.d)))
15+
def __le__(self, other):
16+
return (self.a, self.b, self.c, self.d) <= (other.a, other.b, other.c, other.d)
1517
def __gt__(self, other):
1618
return (self.a > other.a if self.a != other.a else (self.b > other.b if self.b != other.b else (self.c > other.c if self.c != other.c else self.d > other.d)))
19+
def __ge__(self, other):
20+
return (self.a, self.b, self.c, self.d) >= (other.a, other.b, other.c, other.d)
1721
def __eq__(self, other):
1822
return self.a == other.a and self.b == other.b and self.c == other.c and self.d == other.d
1923
def distance(self, a, b, c, d):
@@ -32,5 +36,5 @@ def distance(self, a, b, c, d):
3236
]
3337

3438
print(sortingx.heap(points, key=methodcaller('distance', 0, 0, 0, 0)))
35-
# print(sortingx.heap(points))
36-
# print(sortingx.heap(points, reverse=True))
39+
# print(sortingx.insert(points))
40+
# print(sortingx.insert(points, reverse=True))

0 commit comments

Comments
 (0)