On Tue, Jul 26, 2011 at 11:55 AM, Rob Beezer <goo...@beezer.cotse.net>wrote:
> I've built a class for vector space morphisms, aka linear > transformations. Mostly this just extends free module morphisms, > while making a few distinctions between behavior for vector spaces > versus modules over rings. Everything seems to be working fine, but I > cannot get equality testing to work. > > Equality testing of free module morphisms ends up in a __cmp__() > method for "matrix morphisms." My vector space morphisms extend free > module morphisms, which in turn extend matrix morphisms. If f and > g are two free module morphisms, then > > f == g, f.__eq__(g), f.__cmp__(g) > > all employ the matrix morphism method __cmp__() and do the right > thing. However, if f and g are two of my vector spaces morphisms, > then f.__cmp__(g) does the right thing, but f == g and > f.__eq__(g) give the wrong answer (False for equal morphisms) and > never "reach down" to employ the __cmp__ method in the base matrix > morphism class. > > Any hints, or places to look for guidance? No amount of searching the > developers guide, reference manual, or forums has landed me in the > right place. A 95%-complete patch is up at > http://trac.sagemath.org/sage_trac/ticket/11556 > which has all the details, but there is little point in wading through > all that, unless you were interested in reviewing it once > complete. ;-) > Did you overload *both* __cmp__ *and* __hash__? William > > Thanks, > Rob > > -- > To post to this group, send an email to sage-devel@googlegroups.com > To unsubscribe from this group, send an email to > sage-devel+unsubscr...@googlegroups.com > For more options, visit this group at > http://groups.google.com/group/sage-devel > URL: http://www.sagemath.org > -- William Stein Professor of Mathematics University of Washington http://wstein.org -- To post to this group, send an email to sage-devel@googlegroups.com To unsubscribe from this group, send an email to sage-devel+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/sage-devel URL: http://www.sagemath.org