示例#1
0
        Morphism.__init__(self, Hom(mpz, ZZ, ZZ.category(), check=False))

    def _call_(self, x):
        return ZZ(x.get_str())


mpz.is_exact = lambda: True
ZZ.register_conversion(ConversionZZMpz())


class ConversionQQMpq(Morphism):
    r"""
    Conversion from our mpq type to SageMath rationals.

    EXAMPLES::

        sage: from gmpxxyy import mpq
        sage: QQ(mpq(1, 2))
        1/2

    """
    def __init__(self):
        Morphism.__init__(self, Hom(mpq, QQ, QQ.category(), check=False))

    def _call_(self, x):
        return QQ(x.get_str())


mpq.is_exact = lambda: True
QQ.register_conversion(ConversionQQMpq())