On Monday, 24 May 2021 at 14:44:09 UTC-7 ... wrote:

> On Sunday, 9 May 2021 at 02:50:06 UTC-6 vdelecroix wrote:
>
>> What is annoying in the above scenario is that it breaks 
>> badly the rule "same input parent" -> "same output parent". 
>> Here are three distinct output parents for the same substitution 
>> command
>>
>
> I completely agree with Vincent on this point. If you are going to do 
> something further with the output in your code, having potentially 
> different objects is very inconvenient. Since partial substitution (which 
> is supported by "subs" method) almost certainly has to live in the same 
> polynomial ring as the starting polynomial, I strongly favour the result of 
> subs to be in this ring whenever possible. Perhaps if there is a full 
> substitution and another natural ring to live in, as is the case with ring 
> homomorphisms, it can be there, but do not drop to the ring of coefficients 
> just because it is possible for a particular case.
>

+1 on letting the codomain only depend on the parents of the argument; not 
on the values themselves. Note, though, that currently

sage: R.<x,y>=QQ[] 
sage: f=x+y 
sage: f.subs(x=1.0) 
y + 1.00000000000000 
sage: f.subs(x=1.0).parent() 
Multivariate Polynomial Ring in x, y over Real Field with 53 bits of 
precision 

I don't think you'd want to break that. The parent here gets discovered 
because the coercion system can figure out that adding/multiplying elements 
from RR and from QQ['x','y'] can be performed using a base change and 
produce elements of RR['x','y']
 

> On the other hand, call method does not support partial substitution and 
> acts as an evaluation where it makes a lot of sense to use the coefficient 
> ring by default, but again one can consider natural subcases.
>

It does:

sage: f(x=1.0) 
y + 1.00000000000000 

I agree it's a bit redundant to have __call__ as well as subs, but that's a 
historic artefact by now. I'd say making them completely synonymous is the 
easiest way of dealing with this.

 

-- 
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 view this discussion on the web visit 
https://groups.google.com/d/msgid/sage-devel/1691ffe1-e631-4bb8-b8c0-2680e2e61303n%40googlegroups.com.

Reply via email to