def _print_Function(self, expr):
"""Print a Function object.
:param expr: The expression.
:rtype : str
:return: The printed string.
:raise RuntimeError: Raise if the function is not supported.
"""
assert isinstance(expr, _sympy.Function)
# Check the function.
fn_object = _mexp_function.find_sympy_function(expr.func.__name__)
if fn_object is None:
raise RuntimeError("Unsupported function: \"%s\"." % expr.func.__name__)
if fn_object.get_argument_count() != len(expr.args):
raise RuntimeError("Argument count mismatch.")
# Stringify the arguments.
arg_text = ""
for arg_id in range(0, len(expr.args)):
arg_text += self.doprint(expr.args[arg_id])
if arg_id + 1 != len(expr.args):
arg_text += ","
return "%s(%s)" % (fn_object.get_function_name(), arg_text)
评论列表
文章目录