Hi all,

I want to redefine comparison for modules by using python like comparisons
__eq__, __lt__ etc.

See #23978
https://trac.sagemath.org/ticket/23978

So I have deleted the __richcmp__ methods and added a method

    def __eq__(self, other):
        return type(self) == type(other)


I get the following error in sage:

See #23978
https://trac.sagemath.org/ticket/23978

sage: A = ZZ^2
sage: A == A
---------------------------------------------------------------------------
AttributeError                            Traceback (most recent call last)
<ipython-input-2-17b2cdf5c541> in <module>()
----> 1 A == A

/home/agag/sbrandhorst/sage/sage/src/sage/structure/richcmp.pyx in 
sage.structure.richcmp.slot_tp_richcompare 
(build/cythonized/sage/structure/richcmp.c:1414)()
    110     Function to put in the ``tp_richcompare`` slot.
    111     """
--> 112     return self.__richcmp__(other, op)
    113 
    114 

/home/agag/sbrandhorst/sage/sage/src/sage/structure/category_object.pyx in 
sage.structure.category_object.CategoryObject.__getattr__ 
(build/cythonized/sage/structure/category_object.c:7910)()
    846             AttributeError: 'PrimeNumbers_with_category' object has 
no attribute 'sadfasdf'
    847         """
--> 848         return self.getattr_from_category(name)
    849 
    850     cdef getattr_from_category(self, name):

/home/agag/sbrandhorst/sage/sage/src/sage/structure/category_object.pyx in 
sage.structure.category_object.CategoryObject.getattr_from_category 
(build/cythonized/sage/structure/category_object.c:8073)()
    861                 cls = self._category.parent_class
    862 
--> 863             attr = getattr_from_other_class(self, cls, name)
    864             self.__cached_methods[name] = attr
    865             return attr

/home/agag/sbrandhorst/sage/sage/src/sage/cpython/getattr.pyx in 
sage.cpython.getattr.getattr_from_other_class 
(build/cythonized/sage/cpython/getattr.c:1831)()
    247         dummy_error_message.cls = type(self)
    248         dummy_error_message.name = name
--> 249         raise dummy_attribute_error
    250     cdef PyObject* attr = _PyType_Lookup(<type>cls, name)
    251     if attr is NULL:

AttributeError: 'FreeModule_ambient_pid_with_category' object has no 
attribute '__richcmp__'


So somehow it insists on using __richcmp__. How can I teach it to use the 
python style methods?

-- 
You received this message because you are subscribed to the Google Groups 
"sage-devel" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to sage-devel+unsubscr...@googlegroups.com.
To post to this group, send email to sage-devel@googlegroups.com.
Visit this group at https://groups.google.com/group/sage-devel.
For more options, visit https://groups.google.com/d/optout.

Reply via email to