printer_text.py 文件源码

python
阅读 22 收藏 0 点赞 0 评论 0

项目:bce 作者: bce-toolkit 项目源码 文件源码
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)
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号