本文整理汇总了Python中sympy.Symbol.__str__方法的典型用法代码示例。如果您正苦于以下问题:Python Symbol.__str__方法的具体用法?Python Symbol.__str__怎么用?Python Symbol.__str__使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类sympy.Symbol
的用法示例。
在下文中一共展示了Symbol.__str__方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: GeneralizedCoordinate
# 需要导入模块: from sympy import Symbol [as 别名]
# 或者: from sympy.Symbol import __str__ [as 别名]
def GeneralizedCoordinate(s, constant=False):
gc = Symbol(s)(Symbol("t"))
gc.is_gc = True
if constant == True:
gc.fdiff = lambda argindex: 0
gc.__repr__ = lambda self: PyDyStrPrinter().doprint(self)
gc.__str__ = lambda self: PyDyStrPrinter().doprint(self)
return gc
示例2: Expr
# 需要导入模块: from sympy import Symbol [as 别名]
# 或者: from sympy.Symbol import __str__ [as 别名]
#.........这里部分代码省略.........
@staticmethod
def get_plus_inf():
return Expr(S.Infinity)
@staticmethod
def get_minus_inf():
return Expr(-S.Infinity)
@staticmethod
def get_true():
return Expr(True)
@staticmethod
def get_false():
return Expr(False)
def __init__(self, val):
if not Expr.initialized:
Expr.initialized = True
Expr.init()
if isinstance(val, int) or isinstance(val, long):
self.expr = Integer(val)
elif isinstance(val, basestring):
self.expr = Symbol(val)
elif isinstance(val, bool) or isinstance(val, BooleanAtom):
self.expr = S.One if val else S.Zero
else:
assert isinstance(val, SymPyExpr) or isinstance(val, BooleanFunction) \
or (val == S.Infinity) or (val == -S.Infinity)
self.expr = val
def __str__(self):
return self.expr.__str__()
def __repr__(self):
r = self.__str__()
return r
def subs(self, expr_from, expr_to):
return Expr(self.expr.subs([(expr_from.expr, expr_to.expr)]))
def args(self):
return map(Expr, self.expr.args)
def sympy(self):
return self.expr
@staticmethod
def reduce_conditional(expr):
if isinstance(expr, And):
# And(x, y)
x, y = expr.args
# And(Or(a, b), y)
if isinstance(x, Or):
a, b = x.args
# And(Or(a, b), Or(c, d))
if isinstance(y, Or):
c, d = y.args
return [[a, c], [a, d], [b, c], [b, d]]
# And(Or(a, b), y)
red_args = map(reduce_contional, expr.args)
red_args = sum(red_args, [])
return red_args
elif isinstance(expr.expr, Or):