On Tue, 28 Oct 2014 13:24:18 -0700 (PDT) Volker Braun <vbraun.n...@gmail.com> wrote:
> The language is explained here > > http://www.sagemath.org/doc/tutorial/tour_coercion.html#conversion-versus- coercion Thanks! > On Tuesday, October 28, 2014 8:06:44 PM UTC, Erik Massop wrote: > > > > sage: s = Sequence([], QQ) > > sage: s.append(QQ(3)) # no coercion or conversion > > sage: s.extend([int(1), ZZ(2)]) # 2 conversions > > > > sage: s = Sequence([QQ(3)]) # no coercion or conversion > > sage: s.extend([int(1), ZZ(2)]) # 2 coercions > > > > I guess so. The Sequence has a fixed universe once its created afair, so > extending it is somewhat of a special case though. Having read the webpage above, I would argue that append and extend of Sequence do conversions: sage: R.<x> = QQ[] sage: S.<y> = QQ[] sage: s = Sequence([x]) sage: s.universe().has_coerce_map_from(y.parent()) False sage: s.append(y) # would error if it did only coercion sage: s [x,x] Anyway, I have learnt something. P.S. Addition (concatenation) of sequences converts to lists. Is that the intended behavior? sage: s = Sequence([x]) sage: s.__class__, s.parent() (<class 'sage.structure.sequence.Sequence_generic'>, Category of sequences in Univariate Polynomial Ring in x over Rational Field) sage: (s+s).__class__ <type 'list'> This also allows concatenation of sequences with incompatible parents: sage: s = Sequence([x]) sage: t = Sequence([y]) sage: sage.structure.element.canonical_coercion(s,t) TypeError: no common canonical parent for objects with parents: 'Category of sequences in Univariate Polynomial Ring in x over Rational Field' and 'Category of sequences in Univariate Polynomial Ring in y over Rational Field' sage: s+t [x, y] -- 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 sage-devel+unsubscr...@googlegroups.com. To post to this group, send email to sage-devel@googlegroups.com. Visit this group at http://groups.google.com/group/sage-devel. For more options, visit https://groups.google.com/d/optout.