Hi! If one implements a new parent P and "forgets" to override sage.structure.parent_gens.ParentWithGens.gen, and then calls P.gen(), one will usually see a very disturbing error.
The error is raised by the cdef inline function check_old_coerce. The problem with this function: The error message states: "... still using old coercion framework", but in fact it is raised if you use the *new* coercion framework, implementing _element_constructor_ and _coerce_map_from_ and so on. That's totally misleading! check_old_coerce just tests that self._element_constructor (without trailing underscore) is not None. However, it seems that self._element_constructor defaults to self._element_constructor_ (WITH trailing underscore), which is supposed to be implement in the new coercion framework: sage: P = ZZ[['x']] sage: P._element_constructor <bound method PowerSeriesRing_domain_with_category._element_constructor_ of Power Series Ring in x over Integer Ring> Turning check_old_coerce into a Python function, one gets sage: def check_old_coerce(p): ....: if p._element_constructor is not None: ....: raise RuntimeError, "%s still using old coercion framework" % p ....: sage: check_old_coerce(QQ[['x']]) Traceback (most recent call last): ... RuntimeError: Power Series Ring in x over Rational Field still using old coercion framework sage: check_old_coerce(SymmetricFunctionAlgebra(QQ)) Traceback (most recent call last) ... RuntimeError: Symmetric Functions over Rational Field in the Schur basis still using old coercion framework In addition to that, it seems to me that this check is not needed at all: check_old_coerce is used in four places in sage.structure.parent_gens, namely in ParentWithGens.gen(), ParentWithGens.ngens(), ParentWithAdditiveAbelianGens.generator_orders() and ParentWithMultiplicativeAbelianGens.generator_orders(). In the case of generator_orders(), it seems not to make sense to check coercion in this place (besides, it is a waste of time to check it before trying to return a previously cached result). The case of gen() and ngens() is worse, because right after check_old_coerce, a NotImplementedError is raised anyway! But since it is time-honoured code, I'm asking before removing it: Does anyone has nostalgic feelings about check_old_coerce? Best regards, Simon -- 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 [email protected]. To post to this group, send email to [email protected]. Visit this group at http://groups.google.com/group/sage-devel?hl=en. For more options, visit https://groups.google.com/groups/opt_out.
