On 4 March 2015 at 08:11, Nicolas M. Thiery <[email protected]> wrote: > On Sat, Feb 21, 2015 at 08:47:40PM +0000, Simon King wrote: >> > How should I fix this? >> >> By providing a starting point for the summation: >> sage: sum([myElement]).parent() >> ModularFormsRing(n=3) over Integer Ring >> sage: myElement.parent() >> ModularForms(n=3, k=4, ep=1) over Integer Ring >> sage: sum([myElement], myElement.parent().zero()).parent() >> ModularForms(n=3, k=4, ep=1) over Integer Ring > > Alternatively, you can use the form: > > parent.sum(elements) > > whose role is precisely to use the zero of the parent just when needed > (that is if the list is empty).
That is a very nice idiom! I did not know that, but I will use it a lot from now on. John > > Cheers, > Nicolas > -- > Nicolas M. ThiƩry "Isil" <[email protected]> > http://Nicolas.Thiery.name/ > > -- > 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. > For more options, visit https://groups.google.com/d/optout. -- 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. For more options, visit https://groups.google.com/d/optout.
