Commit 8f943d4e authored by Kyryl Truskovskyi's avatar Kyryl Truskovskyi Committed by Soumith Chintala
Browse files

Fix Unused Variables and flake8 config (#635)

* cast mnist targer to int

* fix unused variables

* fix syntax in tests

* remove # noqa; rename l variable to line_split; use except OSError

* add W504

* add W504

* add W503,W504 tox.ini
parent b0acd55c
......@@ -9,5 +9,5 @@ max-line-length = 120
[flake8]
max-line-length = 120
ignore = F401,E402,F403
ignore = F401,E402,F403,W503,W504
exclude = venv
......@@ -2,7 +2,6 @@
import os
import io
import re
import shutil
import sys
from setuptools import setup, find_packages
from pkg_resources import get_distribution, DistributionNotFound
......
......@@ -65,5 +65,6 @@ class Tester(unittest.TestCase):
[class_b_idx] * len(Tester.class_b_images))
self.assertEqual(targets, sorted(args))
if __name__ == '__main__':
unittest.main()
......@@ -284,6 +284,5 @@ def read_image_file(path):
length = get_int(data[4:8])
num_rows = get_int(data[8:12])
num_cols = get_int(data[12:16])
images = []
parsed = np.frombuffer(data, dtype=np.uint8, offset=16)
return torch.from_numpy(parsed).view(length, num_rows, num_cols)
import os
import errno
import numpy as np
from PIL import Image
import torch
import torch.utils.data as data
from .utils import download_url, check_integrity
from .utils import download_url
class PhotoTour(data.Dataset):
......@@ -211,6 +210,6 @@ def read_matches_files(data_dir, matches_file):
matches = []
with open(os.path.join(data_dir, matches_file), 'r') as f:
for line in f:
l = line.split()
matches.append([int(l[0]), int(l[3]), int(l[1] == l[4])])
line_split = line.split()
matches.append([int(line_split[0]), int(line_split[3]), int(line_split[1] == line_split[4])])
return torch.LongTensor(matches)
......@@ -2,14 +2,7 @@ from __future__ import print_function
from PIL import Image
import os
import os.path
import errno
import numpy as np
import sys
if sys.version_info[0] == 2:
import cPickle as pickle
else:
import pickle
import torch.utils.data as data
from .utils import download_url, check_integrity
......
from __future__ import print_function
import torch.utils.data as data
from PIL import Image
import os
import os.path
import errno
import numpy as np
import sys
from .cifar import CIFAR10
......
......@@ -62,7 +62,7 @@ def download_url(url, root, filename, md5):
url, fpath,
reporthook=gen_bar_updater(tqdm(unit='B', unit_scale=True))
)
except:
except OSError:
if url[:5] == 'https':
url = url.replace('https:', 'http:')
print('Failed download. Trying https -> http instead.'
......
import math
import torch
import torch.nn as nn
import torch.nn.init as init
......
import torch.nn as nn
import torch.utils.model_zoo as model_zoo
import math
__all__ = [
......
......@@ -2,7 +2,6 @@ from __future__ import division
import torch
import sys
import math
import random
from PIL import Image, ImageOps, ImageEnhance, PILLOW_VERSION
try:
import accimage
......@@ -10,7 +9,6 @@ except ImportError:
accimage = None
import numpy as np
import numbers
import types
import collections
import warnings
......
......@@ -3,7 +3,7 @@ import torch
import math
import sys
import random
from PIL import Image, ImageOps, ImageEnhance
from PIL import Image
try:
import accimage
except ImportError:
......
[flake8]
max-line-length = 120
ignore = E305,E402,E721,E722,E741,F401,F403,F405,F821,F841,F999
ignore = F401,E402,F403,W503,W504
exclude = docs/src
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment