style_checker.py 文件源码

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

项目:chainercv 作者: chainer 项目源码 文件源码
def check_reshape(node):
    if not isinstance(node, ast.Call):
        return
    if not isinstance(node.func, ast.Attribute):
        return
    if isinstance(node.func.value, ast.Name) and \
       node.func.value.id in {'np', 'cupy', 'F'}:
        return
    if not node.func.attr == 'reshape':
        return

    if len(node.args) > 1:
        yield (node.lineno, 'reshape(A, B, ...)')

    if len(node.args) == 1 and \
       isinstance(node.args[0], ast.Tuple) and \
       len(node.args[0].elts) == 1:
        yield (node.lineno, 'reshape((A,))')
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号