#18383: Coercion and comparison for alternating sign matrices
-------------------------------------+-------------------------------------
Reporter: vdelecroix | Owner:
Type: enhancement | Status: needs_work
Priority: major | Milestone: sage-6.7
Component: combinatorics | Resolution:
Keywords: | Merged in:
Authors: Vincent Delecroix | Reviewers:
Report Upstream: N/A | Work issues:
Branch: | Commit:
u/vdelecroix/18383 | 390e2d7cf57899cde4c7b096ef5b97f0be909574
Dependencies: | Stopgaps:
-------------------------------------+-------------------------------------
Comment (by tscrim):
Replying to [comment:16 vdelecroix]:
> Replying to [comment:15 tscrim]:
> > The uniform way would be to have the generic `_richcmp_` default back
to using the python `__eq__`, etc. It may not be simple to implement, but
it is the IMO correct way to do things as we should not be making
ourselves less Python3 compliant. Plus I thought by having `_richcmp_`
being a Python method, we could then call the `__lt__`, or at least use
`getattr`. Moreover, this is only a problem for doing comparisons with
`cmp`, which will be moot once we do switch.
>
> We can not do that. The method `__richcmp__` (and hence `_richcmp_`) is
not used at all if `__eq__`, `__lt__`, etc are implemented in a Python
class.
For rich comparisons, yes. However for `cmp`, the code path currently
completely bypasses the rich comparisons because it calls `__cmp__` (which
calls `_cmp` which calls `_cmp_` and errors out).
> > > The fact that there is a global `__cmp__` in `Element` might be a
problem but this is rather disjoint from the present ticket: for ASM we
want coercion to be involved.
> >
> > It's quite relevant because it is part of your proposal. In the
current version of Sage, if the other element is not an ASM, then it lifts
itself to the matrix space and does the comparison there (in that it
compares against its defining matrix).
>
> Do you have an example involving rich comparisons that differ?
I'm not sure what you're asking for. If you do an equality comparison
between an ASM and a regular matrix, then the comparison lifts the ASM to
a matrix and then does the comparison.
{{{
sage: ASM = AlternatingSignMatrices(3)
sage: x = ASM[3]
sage: x == x._matrix
True
}}}
Otherwise it returns `False`, which is a fair thing to do since these are
combinatorial objects, not honest matrices (or 2D arrays). (I think I
misread the code when I first looked.) I'm actually becoming more
convinced that the inequality comparisons should be done in the
corresponding lattices. Is this perhaps what you're asking about?
{{{
sage: ASM[1] < ASM[3] # Is True in the latice
False
}}}
--
Ticket URL: <http://trac.sagemath.org/ticket/18383#comment:17>
Sage <http://www.sagemath.org>
Sage: Creating a Viable Open Source Alternative to Magma, Maple, Mathematica,
and MATLAB
--
You received this message because you are subscribed to the Google Groups
"sage-trac" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/sage-trac.
For more options, visit https://groups.google.com/d/optout.