While trying to subclass QuotientRing, I noticed that this class does not follow the coercion model: It overrides __call__ and _coerce_impl, which the reference manual frowns upon. So I tried to change QuotientRing to work via _coerce_map_from_ and _element_constructor_ (see first_attempt.patch at http://trac.sagemath.org/sage_trac/ticket/9429). That ends up working for QuotientRings, but apparently messes up coercion for everything else:
sage: FF = FiniteField(7) sage: P.<x> = PolynomialRing(FiniteField(7)) sage: x+1 --------------------------------------------------------------------------- TypeError Traceback (most recent call last) /home/vbraun/opt/sage-4.5.alpha1/devel/sage-main/<ipython console> in <module>() /home/vbraun/Sage/sage/local/lib/python2.6/site-packages/sage/ structure/element.so in sage.structure.element.RingElement.__add__ (sage/structure/element.c:10876)() /home/vbraun/Sage/sage/local/lib/python2.6/site-packages/sage/ structure/coerce.so in sage.structure.coerce.CoercionModel_cache_maps.bin_op (sage/structure/ coerce.c:6966)() TypeError: unsupported operand parent(s) for '+': 'Univariate Polynomial Ring in x over Finite Field of size 7' and 'Integer Ring' Note that I neither touched finite fields nor polynomial rings, I only changed QuotientRing. Moreover, the coercion model believes that it should work and no coercion to any quotient ring is involved: sage: cm = sage.structure.element.get_coercion_model() sage: cm.explain(P, ZZ, operator.add) Coercion on right operand via Composite map: From: Integer Ring To: Univariate Polynomial Ring in x over Finite Field of size 7 Defn: Conversion map: From: Integer Ring To: Finite Field of size 7 then Polynomial base injection morphism: From: Finite Field of size 7 To: Univariate Polynomial Ring in x over Finite Field of size 7 Arithmetic performed after coercions. Result lives in Univariate Polynomial Ring in x over Finite Field of size 7 Univariate Polynomial Ring in x over Finite Field of size 7 Can somebody who is more familiar with the coercion tell me what I am doing wrong? Volker -- 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