• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Python printing.srepr函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Python中sympy.printing.srepr函数的典型用法代码示例。如果您正苦于以下问题:Python srepr函数的具体用法?Python srepr怎么用?Python srepr使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了srepr函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。

示例1: test_Symbol_two_assumptions

def test_Symbol_two_assumptions():
    x = Symbol('x', negative=0, integer=1)
    # order could vary
    s1 = "Symbol('x', integer=True, negative=False)"
    s2 = "Symbol('x', negative=False, integer=True)"
    assert srepr(x) in (s1, s2)
    assert eval(srepr(x), ENV) == x
开发者ID:KonstantinTogoi,项目名称:sympy,代码行数:7,代码来源:test_repr.py


示例2: test_PolynomialRingBase

def test_PolynomialRingBase():
    assert srepr(ZZ.old_poly_ring(x)) == \
        "GlobalPolynomialRing(ZZ, Symbol('x'))"
    assert srepr(ZZ[x].old_poly_ring(y)) == \
        "GlobalPolynomialRing(ZZ[x], Symbol('y'))"
    assert srepr(QQ.frac_field(x).old_poly_ring(y)) == \
        "GlobalPolynomialRing(FractionField(FracField((Symbol('x'),), QQ, lex)), Symbol('y'))"
开发者ID:KonstantinTogoi,项目名称:sympy,代码行数:7,代码来源:test_repr.py


示例3: test_printmethod

def test_printmethod():
    class R(oo.__class__):
        def _sympyrepr(self, printer):
            return "foo"
    assert srepr(R()) == "foo"
    class R(Abs):
        def _sympyrepr(self, printer):
            return "foo(%s)" % printer._print(self.args[0])
    assert srepr(R(x)) == "foo(Symbol('x'))"
开发者ID:101man,项目名称:sympy,代码行数:9,代码来源:test_repr.py


示例4: test_Dummy_from_Symbol

def test_Dummy_from_Symbol():
    # should not get the full dictionary of assumptions
    n = Symbol('n', integer=True)
    d = n.as_dummy()
    s1 = "Dummy('n', dummy_index=%s, integer=True)" % str(d.dummy_index)
    s2 = "Dummy('n', integer=True, dummy_index=%s)" % str(d.dummy_index)
    assert srepr(d) in (s1, s2)
开发者ID:KonstantinTogoi,项目名称:sympy,代码行数:7,代码来源:test_repr.py


示例5: sT

def sT(expr, string):
    """
    sT := sreprTest
    from sympy/printing/tests/test_repr.py
    """
    assert srepr(expr) == string
    assert eval(string) == expr
开发者ID:B-Rich,项目名称:sympy,代码行数:7,代码来源:test_printing.py


示例6: sT

def sT(expr, string):
    """
    sT := sreprTest

    Tests that srepr delivers the expected string and that
    the condition eval(srepr(expr))==expr holds.
    """
    assert srepr(expr) == string
    assert eval(string, ENV) == expr
开发者ID:KonstantinTogoi,项目名称:sympy,代码行数:9,代码来源:test_repr.py


示例7: test_settins

def test_settins():
    raises(TypeError, lambda: srepr(x, method="garbage"))
开发者ID:KonstantinTogoi,项目名称:sympy,代码行数:2,代码来源:test_repr.py


示例8: test_FracElement

def test_FracElement():
    F, x, y = field("x,y", ZZ)
    assert srepr((3*x**2*y + 1)/(x - y**2)) == "FracElement(FracField((Symbol('x'), Symbol('y')), ZZ, lex), [((2, 1), 3), ((0, 0), 1)], [((1, 0), 1), ((0, 2), -1)])"
开发者ID:KonstantinTogoi,项目名称:sympy,代码行数:3,代码来源:test_repr.py


示例9: test_FractionField

def test_FractionField():
    assert srepr(QQ.frac_field(x)) == \
        "FractionField(FracField((Symbol('x'),), QQ, lex))"
    assert srepr(QQ.frac_field(x, y, order=grlex)) == \
        "FractionField(FracField((Symbol('x'), Symbol('y')), QQ, grlex))"
开发者ID:KonstantinTogoi,项目名称:sympy,代码行数:5,代码来源:test_repr.py


示例10: test_FracField

def test_FracField():
    assert srepr(field("x", ZZ, lex)[0]) == "FracField((Symbol('x'),), ZZ, lex)"
    assert srepr(field("x,y", QQ, grlex)[0]) == "FracField((Symbol('x'), Symbol('y')), QQ, grlex)"
    assert srepr(field("x,y,z", ZZ["t"], lex)[0]) == "FracField((Symbol('x'), Symbol('y'), Symbol('z')), ZZ[t], lex)"
开发者ID:KonstantinTogoi,项目名称:sympy,代码行数:4,代码来源:test_repr.py


示例11: test_PolyElement

def test_PolyElement():
    R, x, y = ring("x,y", ZZ)
    assert srepr(3*x**2*y + 1) == "PolyElement(PolyRing((Symbol('x'), Symbol('y')), ZZ, lex), [((2, 1), 3), ((0, 0), 1)])"
开发者ID:KonstantinTogoi,项目名称:sympy,代码行数:3,代码来源:test_repr.py


示例12: test_Add

def test_Add():
    sT(x + y, "Add(Symbol('x'), Symbol('y'))")
    assert srepr(x**2 + 1, order='lex') == "Add(Pow(Symbol('x'), Integer(2)), Integer(1))"
    assert srepr(x**2 + 1, order='old') == "Add(Integer(1), Pow(Symbol('x'), Integer(2)))"
开发者ID:KonstantinTogoi,项目名称:sympy,代码行数:4,代码来源:test_repr.py


示例13: test_Dummy_from_Symbol

def test_Dummy_from_Symbol():
    # should not get the full dictionary of assumptions
    n = Symbol('n', integer=True)
    d = n.as_dummy()
    assert srepr(d) == "Dummy('n', integer=True)"
开发者ID:arghdos,项目名称:sympy,代码行数:5,代码来源:test_repr.py


示例14: test_ExtensionElement

def test_ExtensionElement():
    A = FiniteExtension(Poly(x**2 + 1, x))
    assert srepr(A.generator) == \
        "ExtElem(DMP([1, 0], ZZ, ring=GlobalPolynomialRing(ZZ, Symbol('x'))), FiniteExtension(Poly(x**2 + 1, x, domain='ZZ')))"
开发者ID:KonstantinTogoi,项目名称:sympy,代码行数:4,代码来源:test_repr.py


示例15: test_DMP

def test_DMP():
    assert srepr(DMP([1, 2], ZZ)) == 'DMP([1, 2], ZZ)'
    assert srepr(ZZ.old_poly_ring(x)([1, 2])) == \
        "DMP([1, 2], ZZ, ring=GlobalPolynomialRing(ZZ, Symbol('x')))"
开发者ID:KonstantinTogoi,项目名称:sympy,代码行数:4,代码来源:test_repr.py


示例16: __repr__

 def __repr__(self):
     from sympy.printing import srepr
     return type(self).__name__ + srepr(tuple(self))
开发者ID:KevinGoodsell,项目名称:sympy,代码行数:3,代码来源:entity.py


示例17: test_Dummy_assumption

def test_Dummy_assumption():
    d = Dummy('d', nonzero=True)
    assert d == eval(srepr(d))
    s1 = "Dummy('d', dummy_index=%s, nonzero=True)" % str(d.dummy_index)
    s2 = "Dummy('d', nonzero=True, dummy_index=%s)" % str(d.dummy_index)
    assert srepr(d) in (s1, s2)
开发者ID:KonstantinTogoi,项目名称:sympy,代码行数:6,代码来源:test_repr.py


示例18: test_more_than_255_args_issue_10259

def test_more_than_255_args_issue_10259():
    from sympy import Add, Mul
    for op in (Add, Mul):
        expr = op(*symbols('x:256'))
        assert eval(srepr(expr)) == expr
开发者ID:bjodah,项目名称:sympy,代码行数:5,代码来源:test_repr.py


示例19: test_FiniteExtension

def test_FiniteExtension():
    assert srepr(FiniteExtension(Poly(x**2 + 1, x))) == \
        "FiniteExtension(Poly(x**2 + 1, x, domain='ZZ'))"
开发者ID:KonstantinTogoi,项目名称:sympy,代码行数:3,代码来源:test_repr.py


示例20: test_Mul

def test_Mul():
    sT(3*x**3*y, "Mul(Integer(3), Pow(Symbol('x'), Integer(3)), Symbol('y'))")
    assert srepr(3*x**3*y, order='old') == "Mul(Integer(3), Symbol('y'), Pow(Symbol('x'), Integer(3)))"
开发者ID:KonstantinTogoi,项目名称:sympy,代码行数:3,代码来源:test_repr.py



注:本文中的sympy.printing.srepr函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python printing.sstr函数代码示例发布时间:2022-05-27
下一篇:
Python printing.ccode函数代码示例发布时间:2022-05-27
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap