On Apr 5, 3:44 pm, Rob Harron <
robert.har...@gmail.com> wrote:
> Yeah, I can see that. To me, this means we should redo categories for
> number fields. For instance:
>
> sage: K = NumberField(x^2+1, 'i')
> sage: L = K.extension(x^2-5, 'a')
> sage: L.base_field()
> Number Field in i with defining polynomial x^2 + 1
> sage: L.base_ring()
> Number Field in i with defining polynomial x^2 + 1
> sage: L.base()
> Rational Field
That does seem odd, but it's easily explained by looking at where the
routine comes from (never mind that base SHOULD have a docstring):
sage: [f for f in type(L).mro() if 'base_field' in f.__dict__]
[<class
'sage.rings.number_field.number_field_rel.NumberField_relative'>]
sage: [f for f in type(L).mro() if 'base' in f.__dict__]
[<type 'sage.structure.category_object.CategoryObject'>]
sage: [f for f in type(L).mro() if 'base_ring' in f.__dict__]
[<class
'sage.rings.number_field.number_field_rel.NumberField_relative'>,
<type 'sage.structure.category_object.CategoryObject'>]
so one routine comes from NumberFields itself, the other one from the
category framework. As you can see, `base_ring` is implemented at
both, so there we can really get contradictory answers. Of course, the
one on NumberField_relative shadows the more general one, so we get
sage: L.base_ring()
Number Field in i with defining polynomial x^2 + 1
sage:
sage.rings.number_field.number_field_rel.NumberField_relative.base_ring(L)
Number Field in i with defining polynomial x^2 + 1
but:
sage: sage.structure.category_object.CategoryObject.base_ring(L)
Rational Field
so the category framework at the moment is indeed not in agreement
with what the more specific class thinks about itself and since both
decide to implement base_ring, these two views could easily clash.
Incidentally, there IS a docstring that makes locating the source of
"base" a little easier:
sage: L.base.__doc__
'File: sage/structure/category_object.pyx (starting at line 564)'