本文整理汇总了Python中sympy.printing.srepr函数的典型用法代码示例。如果您正苦于以下问题:Python srepr函数的具体用法?Python srepr怎么用?Python srepr使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了srepr函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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
示例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'))"
示例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'))"
示例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)
示例5: sT
def sT(expr, string):
"""
sT := sreprTest
from sympy/printing/tests/test_repr.py
"""
assert srepr(expr) == string
assert eval(string) == expr
示例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
示例7: test_settins
def test_settins():
raises(TypeError, lambda: srepr(x, method="garbage"))
示例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)])"
示例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))"
示例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)"
示例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)])"
示例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)))"
示例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)"
示例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')))"
示例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')))"