On Sep 16, 2007, at 6:20 PM, William Stein wrote: > I'm implementing a subfields command that returns > a list of all subfields of a number field K. It should be possible > to make it so each subfield canonically coerces into K. > How do I do that with your new coercion code? Is enough > written to make that possible? > > For now, I'm just writing a lot of functions that return > object, map from object to ambient > and we can change it to just set a canonical coercion when > you explain the above.
On 9/17/07, Robert Bradshaw <[EMAIL PROTECTED]> wrote: > > Every parent has a _coerce_from_list (cdef) attribute. To set up > coercion, all you need to do is create a Morphism object that does > subfield -> K and append it to K. _coerce_from_list. Perhaps this > should be made into a(n underscore) method. Is there one example in the entire SAGE codebase that actually does this? I suspect not, since: sage: search_src('_coerce_from_list') ---------------------------------------------------------------------- | SAGE Version 2.8.4.2, Release Date: 2007-09-13 | | Type notebook() for the GUI, and license() for information. | ---------------------------------------------------------------------- structure/parent.pyx: self._coerce_from_list = list(coerce_from) structure/parent.pyx: other._coerce_from_list.append(mor) structure/parent.pyx: self._coerce_from_list = [] structure/parent.pyx: for mor in self._coerce_from_list: structure/parent.pyx: i = self._coerce_from_list.index(R) structure/parent.pyx: self._coerce_from_list[i] = mor # cache in case we need it again structure/parent.pxd: cdef _coerce_from_list One issue is that might not affect the __call__ method of K being > able to interpret things correctly. It might be a good thing to re- > write __call__ methods to try coercion first, and only do non- > canonical things if that fails. We really need a __call__ infrastructure. It's been suggesting a few times before (most recently by Joel Mohler, I think), and I hope it will get some discussion now. - Robert > > > > -- William Stein Associate Professor of Mathematics University of Washington http://wstein.org --~--~---------~--~----~------------~-------~--~----~ To post to this group, send email to sage-devel@googlegroups.com 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/ -~----------~----~----~----~------~----~------~--~---