On Tue, 28 Oct 2014 10:41:16 -0700 (PDT) Volker Braun <vbraun.n...@gmail.com> wrote:
> On Tuesday, October 28, 2014 5:16:47 PM UTC, Erik Massop wrote: > > > > class CoercingDict: > > def __init__(self, f): > > self.f = f > > self.data = dict() > > def __setitem__(self, key, value): > > self.data[self.f(key)] = value > > > Thats manual conversion, not coercion. This is: > > sage: s = Sequence([int(1), ZZ(2), QQ(3)]) > sage: s.universe() > Rational Field > sage: map(type, s) > [<type 'sage.rings.rational.Rational'>, > <type 'sage.rings.rational.Rational'>, > <type 'sage.rings.rational.Rational'>] I agree that the class name is a misnomer. Am I understanding correctly that the property that makes the Sequence example coercion is that Sequence determines the parent from the iterable that it is initialized with? Did I get the following right? 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 int main () { float foo[2]; foo[0] = 1.00; /* no coercion or conversion */ foo[1] = 2L; /* conversion */ return 0; } -- 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.