#15303: Coercion discovery fails to be transitive
-------------------------------------+-------------------------------------
Reporter: nbruin | Owner:
Type: defect | Status: needs_review
Priority: major | Milestone: sage-6.0
Component: coercion | Resolution:
Keywords: | Merged in:
Authors: Simon King | Reviewers:
Report Upstream: N/A | Work issues: Crash in permgroup.py
Branch: | Commit:
u/SimonKing/ticket/15303 | 528a03535447d67f04dc16d0a22cc38def54f9f1
Dependencies: #14711, #15329, | Stopgaps:
#15331 |
-------------------------------------+-------------------------------------
Comment (by SimonKing):
Replying to [comment:117 mmezzarobba]:
> > Didn't you also do something with
`src/sage/combinat/ncsf_qsym/ncsf.py`?
>
> No, there was no conflict there either.
Then I show you what `git show HEAD` shows me:
{{{
#!diff
commit 2712c53cb68d2668b47ccc923b5a77421ff04bbd
Merge: 528a035 0c6fcdf
Author: Marc Mezzarobba <[email protected]>
Date: Sat Nov 30 14:10:11 2013 +0100
Merge 'trac/master' into ticket/15303
Conflicts:
src/sage/misc/weak_dict.pyx
src/sage/schemes/generic/morphism.py
diff --cc src/sage/categories/morphism.pyx
index 74f600f,47aa188..a9f44c8
--- a/src/sage/categories/morphism.pyx
+++ b/src/sage/categories/morphism.pyx
@@@ -249,8 -214,58 +290,58 @@@ garbage collection. Please use a copy."
sage: ZZ(x)
-1
"""
- self.codomain().register_conversion(self)
+ self._codomain.register_conversion(self)
+ # You *must* override this method in all cython classes
+ # deriving from this class.
+ # If you are happy with this implementation (typically
+ # is your domain has generators), simply write:
+ # def __hash__(self):
+ # return Morphism.__hash__(self)
+ def __hash__(self):
+ """
+ Return a hash of this morphism.
+
+ It is the hash of the triple (domain, codomain, definition)
+ where ``definition`` is:
+
+ - a tuple consisting of the images of the generators
+ of the domain if domain has generators
+
+ - the string representation of this morphism otherwise
+
+ AUTHOR:
+
+ - Xavier Caruso (2012-07-09)
+ """
+ domain = self.domain()
+ codomain = self.codomain()
+ try:
+ gens = domain.gens()
+ definition = tuple([self(x) for x in gens])
+ except (AttributeError, NotImplementedError):
+ definition = self.__repr__()
+ return hash((domain, codomain, definition))
+
+ def __richcmp__(left, right, int op):
+ return (<Element>left)._richcmp(right, op)
+
+ cdef int _cmp_c_impl(left, Element right) except -2:
+ if left is right: return 0
+ domain = left.domain()
+ c = cmp(domain, right.domain())
+ if c: return c
+ c = cmp(left.codomain(), right.codomain())
+ if c: return c
+ try:
+ gens = domain.gens()
+ for x in gens:
+ c = cmp(left(x), right(x))
+ if c: return c
+ except (AttributeError, NotImplementedError):
+ raise NotImplementedError
+
+
cdef class FormalCoercionMorphism(Morphism):
def __init__(self, parent):
Morphism.__init__(self, parent)
diff --cc src/sage/combinat/ncsf_qsym/ncsf.py
index 6478d46,7d84562..febf995
--- a/src/sage/combinat/ncsf_qsym/ncsf.py
+++ b/src/sage/combinat/ncsf_qsym/ncsf.py
@@@ -238,12 -249,11 +249,12 @@@ class NonCommutativeSymmetricFunctions(
sage: elementary(ribbon[2,1,2,1])
L[1, 3, 2] - L[1, 5] - L[4, 2] + L[6]
- TODO: explain the other changes of bases!
+ .. TODO:: explain the other changes of bases!
- Here is how to fetch the conversion morphisms::
+ Here is how to fetch the coerce morphisms. Note that by
:trac:`15303`, we
+ should use a copy of the maps being used in the coercion system::
- sage: f = complete.coerce_map_from(elementary); f
+ sage: f = copy(complete.coerce_map_from(elementary)); f
Generic morphism:
From: NCSF in the Elementary basis
To: NCSF in the Complete basis
diff --cc src/sage/schemes/generic/morphism.py
index 3a6c351,09c6bc3..ab59866
--- a/src/sage/schemes/generic/morphism.py
+++ b/src/sage/schemes/generic/morphism.py
@@@ -79,10 -75,12 +79,12 @@@ AUTHORS
#*****************************************************************************
-from sage.structure.element import AdditiveGroupElement, RingElement,
Element, generic_power
+from sage.structure.element import AdditiveGroupElement, RingElement,
Element, generic_power, parent
from sage.structure.sequence import Sequence
-from sage.categories.homset import Homset
+from sage.categories.homset import Homset, Hom
- from sage.rings.all import is_RingHomomorphism,
is_CommutativeRing, Integer
+ from sage.rings.all import Integer
+ from sage.rings.commutative_ring import is_CommutativeRing
+ from sage.rings.morphism import is_RingHomomorphism
from point import is_SchemeTopologicalPoint
from sage.rings.infinity import infinity
import scheme
}}}
`git blame` shows me that the change in ncsf.py seems to be authored by
me. But why is `git show HEAD` showing it?
--
Ticket URL: <http://trac.sagemath.org/ticket/15303#comment:118>
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/groups/opt_out.