LoginSignup
1
2

More than 5 years have passed since last update.

Python > coding rule > PEP8 > read_chpoint.py:20:1: E302 expected 2 blank lines, found 1

Last updated at Posted at 2016-12-22
動作環境
GeForce GTX 1070 (8GB)
ASRock Z170M Pro4S [Intel Z170chipset]
Ubuntu 14.04 LTS desktop amd64
TensorFlow v0.11
cuDNN v5.1 for Linux
CUDA v8.0
Python 2.7.6
IPython 5.1.0 -- An enhanced Interactive Python.
gcc (Ubuntu 4.8.4-2ubuntu1~14.04.3) 4.8.4

Pythonで書いたコードのPEP8チェックを試している。
参考 http://qiita.com/clarinet758/items/312e95ee1513560dfdd1

実行
$ pep8 read_chpoint.py | head
read_chpoint.py:20:1: E302 expected 2 blank lines, found 1
read_chpoint.py:21:1: E101 indentation contains mixed spaces and tabs
read_chpoint.py:21:1: W191 indentation contains tabs
...

コードの該当部分は以下のwrap_fromfile()のdefの行。

read_chpoint.py
import numpy as np
import array
import sys

'''
v0.5 Dec. 23, 2016
    - wrap_fromfile() takes [num] arg
v0.4 Dec. 21, 2016
    - read from "auxiliary" file [auxfp]
        + add read_auxiliary_info()
v0.3 Dec. 19, 2016
    - add wrap_fromfile()
    - read [inprodR],[prev_err],[resid_scale]
v0.2 Dec. 19, 2016
    - fix bug > read [local_nRows] for "size_t" type
v0.1 Dec. 18, 2016
    - read_chpoint_file() > read [ind_m],[local_nRows],[niter],[counter]
'''

def wrap_fromfile(rfp, typecode, num):
    res = array.array(typecode)
...

対処

コメントの下は1行の空白行にしていたが、2行にするようだ。

read_chpoint.py
import numpy as np
import array
import sys

'''
v0.5 Dec. 23, 2016
    - wrap_fromfile() takes [num] arg
v0.4 Dec. 21, 2016
    - read from "auxiliary" file [auxfp]
        + add read_auxiliary_info()
v0.3 Dec. 19, 2016
    - add wrap_fromfile()
    - read [inprodR],[prev_err],[resid_scale]
v0.2 Dec. 19, 2016
    - fix bug > read [local_nRows] for "size_t" type
v0.1 Dec. 18, 2016
    - read_chpoint_file() > read [ind_m],[local_nRows],[niter],[counter]
'''


def wrap_fromfile(rfp, typecode, num):
    res = array.array(typecode)
    res.fromfile(rfp, num)
...

上記の修正により関連エラーがなくなった。

実行
$ pep8 read_chpoint.py | head
read_chpoint.py:22:1: E101 indentation contains mixed spaces and tabs
read_chpoint.py:22:1: W191 indentation contains tabs
read_chpoint.py:23:1: W191 indentation contains tabs
read_chpoint.py:24:1: W191 indentation contains tabs
read_chpoint.py:26:1: E302 expected 2 blank lines, found 1
read_chpoint.py:27:1: W191 indentation contains tabs
read_chpoint.py:28:1: W191 indentation contains tabs
read_chpoint.py:28:35: E261 at least two spaces before inline comment
read_chpoint.py:28:36: E262 inline comment should start with '# '
read_chpoint.py:29:1: W191 indentation contains tabs
1
2
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
2