Re: [sage-devel] Re: Addition of zero in the coercion model

2015-03-04 Thread John Cremona
On 4 March 2015 at 08:11, Nicolas M. Thiery wrote: > On Sat, Feb 21, 2015 at 08:47:40PM +, 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

Re: [sage-devel] Re: Addition of zero in the coercion model

2015-03-04 Thread Nicolas M. Thiery
On Sat, Feb 21, 2015 at 08:47:40PM +, 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 Rin

Re: [sage-devel] Re: Addition of zero in the coercion model

2015-02-23 Thread Jonas Jermann
Hi In my case there is a cm.coercion_map(parent(myElement), parent(0)) (line 907) namely the coercions into the modular forms ring. These maps are then used to map both myElement and 0 to the modular forms ring (in contrast to the (vector) space myElement.parent()). Unfortunately the check for

Re: [sage-devel] Re: Addition of zero in the coercion model

2015-02-23 Thread Eric Gourgoulhon
Hi, Le dimanche 22 février 2015 21:25:02 UTC+1, Jeroen Demeyer a écrit : > > > On the other, this special case is consistent with the idea of the > "univeral 0 object" proposed by John Cremona. > Indeed. In this respect, it is probably safe to use the literal 0 provided one makes sure that it

Re: [sage-devel] Re: Addition of zero in the coercion model

2015-02-22 Thread Jeroen Demeyer
On 2015-02-22 15:24, Simon King wrote: Seriously? I didn't know that Sage's coercion model has such special cases. OK, it makes it possible to get a typical usecase with least effort. But my impression is that ultimately such special cases cause a lot more confusion than a clear model in the spir

Re: [sage-devel] Re: Addition of zero in the coercion model

2015-02-22 Thread John Cremona
On 22 February 2015 at 10:00, Eric Gourgoulhon wrote: > Hi Simon, > > Le dimanche 22 février 2015 00:28:42 UTC+1, Simon King a écrit : >> >> Hi Eric, >> >> On 2015-02-21, Eric Gourgoulhon wrote: >> > It seems that a possible way to have 0 + MyElement work even if ZZ does= >> >=20 >> > not coerce

Re: [sage-devel] Re: Addition of zero in the coercion model

2015-02-21 Thread Jonas Jermann
Hi In my case "0 + MyElement" does find a common parent, namely the modular forms _ring_. So basically in my case "0 + some_element" is the same as "some_element.as_ring_element()", unless the weight of some_element (resp. its parent) is 0 with multiplier 1 in which case ZZ coerces into the spac

Re: [sage-devel] Re: Addition of zero in the coercion model

2015-02-21 Thread Eric Gourgoulhon
Le samedi 21 février 2015 23:09:24 UTC+1, Jonas Jermann a écrit : > > Hi > > It's a good idea but it won't work (in fact the _element_constructor_ > does accept zero correctly in my case). The coercion framework _first_ > tries to find a common parent and _then_ the rest happens. > At least

Re: [sage-devel] Re: Addition of zero in the coercion model

2015-02-21 Thread Jonas Jermann
Hi It's a good idea but it won't work (in fact the _element_constructor_ does accept zero correctly in my case). The coercion framework _first_ tries to find a common parent and _then_ the rest happens. Best Jonas On 21.02.2015 22:59, Eric Gourgoulhon wrote: Hi, Le samedi 21 février 201

Re: [sage-devel] Re: Addition of zero in the coercion model

2015-02-21 Thread Eric Gourgoulhon
Hi, Le samedi 21 février 2015 21:59:05 UTC+1, Jonas Jermann a écrit : > > > The parent is a vector space / module not a ring. Every vector space > contains zero, so in my opinion from a conceptual point of view > adding zero should not change the parent space. > > However since it views 0 as an

Re: [sage-devel] Re: Addition of zero in the coercion model

2015-02-21 Thread Jonas Jermann
Hi On 21.02.2015 22:13, Nils Bruin wrote: On Saturday, February 21, 2015 at 12:57:44 PM UTC-8, Simon King wrote: I.e., if P is a commutative additive group, then P.coerce_map_from(ZZ) should return a morphism in the category of commutative additive groups. Then, x+0 should work

Re: [sage-devel] Re: Addition of zero in the coercion model

2015-02-21 Thread Jonas Jermann
Hi On 21.02.2015 21:57, Simon King wrote: On 2015-02-21, Simon King wrote: If ZZ does not coerce into the parent of your element, then the parent is not a (unitary) ring. PS: And if it is not a ring, then many things don't work as smoothly as they should. For example, if P is a commutative

Re: [sage-devel] Re: Addition of zero in the coercion model

2015-02-21 Thread Jonas Jermann
Hi Simon On 21.02.2015 21:47, Simon King wrote: Hi Jonas, On 2015-02-21, Jonas Jermann wrote: ZZ does not coerce into myElement.parent() so I end up in a much larger space than myElement.parent(). However I would prefer if adding zero didn't change the parent space. If ZZ does not coerce in