def __new__(cls): """ This method actually is not needed for using :class:`RationalField`. But it is used to unpickle some very old pickles. TESTS:: sage: RationalField() in Fields() # indirect doctest True """ try: return QQ except BaseException: from sage.rings.number_field.number_field_base import NumberField return NumberField.__new__(cls)
def __new__(cls): """ This method actually is not needed for using :class:`RationalField`. But it is used to unpickle some very old pickles. TESTS:: sage: RationalField() in Fields() # indirect doctest True """ try: from sage.rings.rational_field import QQ return QQ except BaseException: from sage.rings.number_field.number_field_base import NumberField return NumberField.__new__(cls)
def extension(self, poly, names, **kwds): r""" Create a field extension of `\QQ`. EXAMPLES: We make a single absolute extension:: sage: K.<a> = QQ.extension(x^3 + 5); K Number Field in a with defining polynomial x^3 + 5 We make an extension generated by roots of two polynomials:: sage: K.<a,b> = QQ.extension([x^3 + 5, x^2 + 3]); K Number Field in a with defining polynomial x^3 + 5 over its base field sage: b^2 -3 sage: a^3 -5 """ from sage.rings.number_field.all import NumberField return NumberField(poly, names=names, **kwds)