Skip to content

Commit 6756257

Browse files
committed
Improve handling of 'op' in __richcmp__ in coxeter.pyx
1 parent 21ce8b6 commit 6756257

File tree

1 file changed

+12
-4
lines changed

1 file changed

+12
-4
lines changed

src/sage/libs/coxeter3/coxeter.pyx

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,9 @@ cdef class String:
8787
True
8888
"""
8989
if type(other) is not type(self):
90-
return False
90+
if op in (Py_LT, Py_LE, Py_GT, Py_GE):
91+
return NotImplemented
92+
return op == Py_NE
9193

9294
s = repr(self)
9395
o = repr(other)
@@ -200,7 +202,9 @@ cdef class Type:
200202
True
201203
"""
202204
if type(other) is not type(self):
203-
return False
205+
if op in (Py_LT, Py_LE, Py_GT, Py_GE):
206+
return NotImplemented
207+
return op == Py_NE
204208

205209
s = repr(self)
206210
o = repr(other)
@@ -364,7 +368,9 @@ cdef class CoxGroup(SageObject):
364368
True
365369
"""
366370
if type(other) is not type(self):
367-
return False
371+
if op in (Py_LT, Py_LE, Py_GT, Py_GE):
372+
return NotImplemented
373+
return op == Py_NE
368374

369375
s_t = self.type()
370376
o_t = other.type()
@@ -840,7 +846,9 @@ cdef class CoxGroupElement:
840846
True
841847
"""
842848
if type(other) is not type(self):
843-
return False
849+
if op in (Py_LT, Py_LE, Py_GT, Py_GE):
850+
return NotImplemented
851+
return op == Py_NE
844852

845853
s_p = self.parent_group()
846854
o_p = other.parent_group()

0 commit comments

Comments
 (0)