Skip to content
This repository has been archived by the owner on Jan 30, 2023. It is now read-only.

Commit

Permalink
Changing ElementWrapper.__richcmp__ to _richcmp_.
Browse files Browse the repository at this point in the history
  • Loading branch information
Travis Scrimshaw committed Aug 27, 2016
1 parent 18307b3 commit 6f36d1a
Show file tree
Hide file tree
Showing 4 changed files with 35 additions and 41 deletions.
40 changes: 20 additions & 20 deletions src/sage/combinat/crystals/affine.py
Original file line number Diff line number Diff line change
Expand Up @@ -477,42 +477,42 @@ def _richcmp_(self, other, op):
sage: b = K(rows=[[1]])
sage: c = K(rows=[[2]])
sage: b==c
sage: b == c
False
sage: b==b
sage: b == b
True
sage: b!=c
sage: b != c
True
sage: b!=b
sage: b != b
False
sage: c<b
sage: c < b
False
sage: b<b
False
sage: b<c
sage: b < b
False
sage: b < c
True
sage: b>c
sage: b > c
False
sage: b>b
False
sage: c>b
sage: b > b
False
sage: c > b
True
sage: b<=c
False
sage: b<=b
sage: b <= c
True
sage: b <= b
True
sage: c<=b
sage: c <= b
False
sage: c>=b
False
sage: b>=b
sage: c >= b
True
sage: b >= b
True
sage: b>=c
sage: b >= c
False
"""
return richcmp(self.value, other.value, op)
Expand Down
9 changes: 3 additions & 6 deletions src/sage/combinat/crystals/affinization.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
from sage.structure.parent import Parent
from sage.structure.unique_representation import UniqueRepresentation
from sage.structure.element import Element
from sage.structure.sage_object import richcmp
from sage.categories.regular_crystals import RegularCrystals
from sage.categories.infinite_enumerated_sets import InfiniteEnumeratedSets
from sage.rings.infinity import Infinity
Expand Down Expand Up @@ -200,7 +201,7 @@ def __hash__(self):
"""
return hash(self._b) ^ hash(self._m)

def __cmp__(self, other):
def _richcmp_(self, other, op):
"""
Comparison.
Expand Down Expand Up @@ -236,12 +237,8 @@ def __cmp__(self, other):
[[1, 2], [2, 3]](1),
[[1, 2], [3, 3]](1),
[[2, 2], [3, 3]](2)]
"""
if parent(self) is parent(other):
return cmp(self._m, other._m) or cmp(self._b, other._b)
else:
return cmp(parent(self), parent(other))
return richcmp((self._m, self._b), (other._m, other._b), op)

def e(self, i):
"""
Expand Down
22 changes: 11 additions & 11 deletions src/sage/combinat/crystals/subcrystal.py
Original file line number Diff line number Diff line change
Expand Up @@ -315,17 +315,17 @@ def _richcmp_(self, other, op):
sage: S = A.subcrystal(max_depth=2)
sage: sorted(S)
[[[1, 1]](-1),
[[1, 2]](-1),
[](0),
[[1, 1]](0),
[[1, 2]](0),
[[1, -2]](0),
[[2, 2]](0),
[](1),
[[2, -1]](1),
[[-2, -1]](1),
[[-1, -1]](1),
[[-1, -1]](2)]
[[1, 2]](-1),
[](0),
[[1, 1]](0),
[[1, 2]](0),
[[1, -2]](0),
[[2, 2]](0),
[[2, -1]](1),
[[-1, -1]](1),
[](1),
[[-2, -1]](1),
[[-1, -1]](2)]
For != operator::
Expand Down
5 changes: 1 addition & 4 deletions src/sage/structure/element_wrapper.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -248,7 +248,7 @@ cdef class ElementWrapper(Element):
"""
return hash(self.value)

def __richcmp__(left, right, int op):
cpdef _richcmp_(left, right, int op):
"""
Return ``True`` if ``left`` compares with ``right`` based on ``op``.
Expand Down Expand Up @@ -319,9 +319,6 @@ cdef class ElementWrapper(Element):
"""
cdef ElementWrapper self
self = left
if self.__class__ != right.__class__ \
or self._parent != (<ElementWrapper>right)._parent:
return op == Py_NE
if op == Py_EQ or op == Py_LE or op == Py_GE:
return self.value == (<ElementWrapper>right).value
if op == Py_NE:
Expand Down

0 comments on commit 6f36d1a

Please sign in to comment.