Fix flake8 warnings

This commit is contained in:
Louis Martin 2017-09-25 10:17:43 -07:00 committed by Myle Ott
parent 7333d04d3f
commit cb0d7b2ad1
10 changed files with 11 additions and 4 deletions

View File

@ -7,3 +7,5 @@
#
from .multiprocessing_pdb import pdb
__all__ = ['pdb']

View File

@ -97,7 +97,7 @@ class Scorer(object):
def result_string(self, order=4):
assert order <= 4, "BLEU scores for order > 4 aren't supported"
fmt = 'BLEU{} = {:2.2f}, {:2.1f}'
for i in range(1, order):
for _ in range(1, order):
fmt += '/{:2.1f}'
fmt += ' (BP={:.3f}, ratio={:.3f}, syslen={}, reflen={})'
bleup = [p * 100 for p in self.precision()[:order]]

View File

@ -326,7 +326,7 @@ def shuffled_batches_by_size(src, dst, max_tokens=None, epoch=1, sample=0, max_p
batches = result
else:
for i in range(epoch - 1):
for _ in range(epoch - 1):
np.random.shuffle(batches)
return batches

View File

@ -126,7 +126,7 @@ class SequenceGenerator(object):
# helper function for allocating buffers on the fly
buffers = {}
def buffer(name, type_of=tokens):
def buffer(name, type_of=tokens): # noqa
if name not in buffers:
buffers[name] = type_of.new()
return buffers[name]

View File

@ -41,7 +41,7 @@ def torch_persistent_save(*args, **kwargs):
for i in range(3):
try:
return torch.save(*args, **kwargs)
except:
except Exception:
if i == 2:
logging.error(traceback.format_exc())

View File

@ -1,3 +1,4 @@
#!/usr/bin/env python3
# Copyright (c) 2017-present, Facebook, Inc.
# All rights reserved.
#

View File

@ -1,3 +1,4 @@
#!/usr/bin/env python3
# Copyright (c) 2017-present, Facebook, Inc.
# All rights reserved.
#

View File

@ -1,3 +1,4 @@
#!/usr/bin/env python3
# Copyright (c) 2017-present, Facebook, Inc.
# All rights reserved.
#

View File

@ -1,3 +1,4 @@
#!/usr/bin/env python3
# Copyright (c) 2017-present, Facebook, Inc.
# All rights reserved.
#

View File

@ -1,3 +1,4 @@
#!/usr/bin/env python3
# Copyright (c) 2017-present, Facebook, Inc.
# All rights reserved.
#