test_convert.py 文件源码

python
阅读 27 收藏 0 点赞 0 评论 0

项目:py-openmath 作者: OpenMath 项目源码 文件源码
def test_rational(self):
        def to_om_rat(obj):
            return om.OMApplication(om.OMSymbol('rational', cd='nums1'),
                                    map(to_openmath, [obj.numerator, obj.denominator]))
        def to_py_rat(obj):
            return Fraction(to_python(obj.arguments[0]), to_python(obj.arguments[1]))
        register(Fraction, to_om_rat, 'nums1', 'rational', to_py_rat)

        a = Fraction(10, 12)
        self.assertEqual(a, to_python(to_openmath(a)))
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号