standard.py 文件源码

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

项目:femtocode 作者: diana-hep 项目源码 文件源码
def pythonast(self, args, tonative=False):
        arg, = args
        justlog = ast.Call(ast.Attribute(ast.Name("$math", ast.Load()), "log", ast.Load()), [arg], [], None, None)
        if self.base == math.e:
            if tonative:
                return justlog
            else:
                return ast.IfExp(ast.Compare(arg, [ast.Gt()], [ast.Num(0)]), justlog, ast.Num(-inf))
        else:
            scaled = ast.BinOp(justlog, ast.Div(), ast.Num(math.log(self.base)))
            if tonative:
                return scaled
            else:
                return ast.IfExp(ast.Compare(arg, [ast.Gt()], [ast.Num(0)]), scaled, ast.Num(-inf))
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号