I have implemented a new ring (parent/element structure) and now want to
do equality testing. I use the code below, which seems to me somehow
canonical for rings and equality testing (using coercions properly).
For short, the difference between self and other is built and then
compared for zero.
Note that there is no meaningful _lt_ etc. in this ring, so I am not
sure if richcmp is to be used here (but I just might be too unskilled
with richcmp).

What is the "best way" to do so? Are there any Sage-built-in shortcuts?

ad shortcuts: for richcmp there is
sage.structure.richcmp.richcmp_by_eq_and_lt.

Best,

Daniel

Here the relevant code of the element:

    def __bool__(self):
        return bool(self.polynomial) or bool(self.rhs)

    __nonzero__ = __bool__

    def __eq__(self, other):
        if other is None:
            return False
        try:
            return not bool(self - other)
        except (TypeError, ValueError):
            return False

    def __ne__(self, other):
        return not self == other

-- 
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.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/sage-devel/cb7cf934-747d-9f41-0f4e-62a4f9e1a3cf%40aon.at.
For more options, visit https://groups.google.com/d/optout.

Reply via email to