def _print_Function(self, e):
"""Print a Function object.
:param e: The expression.
:rtype : bce.dom.mathml.all.Base
:return: The printed MathML object.
"""
assert isinstance(e, _sympy.Function)
# Check the function.
fn_object = _mexp_function.find_sympy_function(e.func.__name__)
if fn_object is None:
raise RuntimeError("Unsupported function: \"%s\"." % e.func.__name__)
if fn_object.get_argument_count() != len(e.args):
raise RuntimeError("Argument count mismatch.")
# Build the node.
node = _mathml.RowComponent()
node.append_object(_mathml.TextComponent(fn_object.get_function_name()))
node.append_object(_mathml.OperatorComponent(_mathml.OPERATOR_LEFT_PARENTHESIS))
for arg_id in range(0, len(e.args)):
arg_value = e.args[arg_id]
node.append_object(self.doprint(arg_value))
if arg_id + 1 != len(e.args):
node.append_object(_mathml.OperatorComponent(_mathml.OPERATOR_SEPARATOR))
node.append_object(_mathml.OperatorComponent(_mathml.OPERATOR_RIGHT_PARENTHESIS))
return node
评论列表
文章目录