Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 10 additions & 8 deletions lib/orderedset/_orderedset.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -499,13 +499,15 @@ class OrderedSet(_OrderedSet, MutableSet):
return NotImplemented

def __ge__(self, other):
ret = self < other
if ret is NotImplemented:
return ret
return not ret
if isinstance(other, Set):
return len(self) >= len(other) and set(self) >= set(other)
elif isinstance(other, list):
return len(self) >= len(other) and list(self) >= list(other)
return NotImplemented

def __gt__(self, other):
ret = self <= other
if ret is NotImplemented:
return ret
return not ret
if isinstance(other, Set):
return len(self) > len(other) and set(self) > set(other)
elif isinstance(other, list):
return len(self) > len(other) and list(self) > list(other)
return NotImplemented
15 changes: 15 additions & 0 deletions tests/test_orderedset.py
Original file line number Diff line number Diff line change
Expand Up @@ -371,6 +371,21 @@ def test_ordering(self):
self.assertGreater(oset1, set(oset3))
self.assertGreater(oset1, list(oset3))

oset4 = OrderedSet(self.lst[1:])

self.assertFalse(oset3 < oset4)
self.assertFalse(oset3 < set(oset4))
self.assertFalse(oset3 < list(oset4))
self.assertFalse(oset3 >= oset4)
self.assertFalse(oset3 >= set(oset4))
self.assertFalse(oset3 >= list(oset4))
self.assertFalse(oset3 < oset4)
self.assertFalse(oset3 < set(oset4))
self.assertFalse(oset3 < list(oset4))
self.assertFalse(oset3 >= oset4)
self.assertFalse(oset3 >= set(oset4))
self.assertFalse(oset3 >= list(oset4))


if __name__ == '__main__':
unittest.main()