本文整理汇总了Python中sympy.printing.StrPrinter类的典型用法代码示例。如果您正苦于以下问题:Python StrPrinter类的具体用法?Python StrPrinter怎么用?Python StrPrinter使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了StrPrinter类的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: _print_Derivative
def _print_Derivative(self, expr):
if not isinstance(expr.args[1], (_AppliedUndef, sp.Symbol)):
error("Can only print Derivative code with a single dependent "\
"variabe. Got: {0}".format(sympycode(expr.args[1])))
if isinstance(expr.args[0], _AppliedUndef):
return "d%s_d%s" % (expr.args[0].func.__name__, "_".join(\
self._print(arg) for arg in expr.args[1:]))
return _StrPrinter._print_Derivative(self, expr)
示例2: _print_Float
def _print_Float(self, expr):
# If not finite we use parent printer
if expr.is_zero:
return "0"
if not expr.is_finite:
return _StrPrinter._print_Float(self, expr)
return str(float(expr))
示例3: test_empty_printer
def test_empty_printer():
str_printer = StrPrinter()
assert str_printer.emptyPrinter("foo") == "foo"
assert str_printer.emptyPrinter(x*y) == "x*y"
assert str_printer.emptyPrinter(32) == "32"
示例4: __init__
def __init__(self, namespace=""):
assert(namespace in ["", "math", "np", "numpy", "ufl"])
self._namespace = namespace if not namespace else namespace + "."
_StrPrinter.__init__(self, settings=dict(order=_order))