Sorry I misuded the word automatically. I meant generically. I meant
to say
that coercion of a constant polynomial to its base ring
should be something generic, which should not depend
on the particular base ring involved.

I looked at the various __call__ methods (which I had of course
already done) but I can't figure it out yet. I probably will.

Michel


On May 22, 12:53 am, "William Stein" <[EMAIL PROTECTED]> wrote:
> On 5/21/07, Michel <[EMAIL PROTECTED]> wrote:
>
>
>
> > Here is another coercion bug (or at least an inconsistency). Perhaps
> > it is not worth
> > fixing, given that everything is going to change.
>
> It is not the case that "everything is going to change".   The coercion
> system will iteratively improve with much thought and design, but most
> questions like the one you asking below would be unaffected.  There
> is no magic that makes the work of implementing coercions just disappear,
> especially if one wants coercions to be fast (!).
>
> > Anyway consider
>
> > sage: W=NumberField(z^2+1,'s')
> > sage: WXY.<X,Y>=W[]
> > sage: a=WXY(0)
> > sage: W(a)
> > ---------------------------------------------------------------------------
> > ...
> > <type 'exceptions.TypeError'>: Cannot coerce 0 into Number Field in s
> > with defining polynomial z^2 + 1
>
> I do not think this is a bug.  It is something that hasn't been implemented.
> There's never a guarantee that everything you can imagine can non-canonically
> be coerced to everything else.  In many cases something has been implemented,
> but in this case it hasn't.
>
> > The same example over the rationals is fine
>
> > sage: QUV.<U,V>=QQ[]
> > sage: a=QUV(0)
> > sage: QQ(a)
> > 0
> > I could probably fix this but it is not so clear to me yet where this
> > automatic coercion happens.
>
> It's not automatic.  You have to explicitly write W(a) above, which
> just calls the method W.__call__ with input a.  That's the code
> you should look at.
>
> I strongly encourage you to look at __call__ and maybe improve it
> so W(a) works.
>
> Implement it and send me a patch.
>
> William


--~--~---------~--~----~------------~-------~--~----~
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at http://groups.google.com/group/sage-devel
URLs: http://sage.scipy.org/sage/ and http://modular.math.washington.edu/sage/
-~----------~----~----~----~------~----~------~--~---

Reply via email to