Commit cb0d7b2a authored by Louis Martin's avatar Louis Martin Committed by Myle Ott
Browse files

Fix flake8 warnings

parent 7333d04d
...@@ -7,3 +7,5 @@ ...@@ -7,3 +7,5 @@
# #
from .multiprocessing_pdb import pdb from .multiprocessing_pdb import pdb
__all__ = ['pdb']
...@@ -97,7 +97,7 @@ class Scorer(object): ...@@ -97,7 +97,7 @@ class Scorer(object):
def result_string(self, order=4): def result_string(self, order=4):
assert order <= 4, "BLEU scores for order > 4 aren't supported" assert order <= 4, "BLEU scores for order > 4 aren't supported"
fmt = 'BLEU{} = {:2.2f}, {:2.1f}' fmt = 'BLEU{} = {:2.2f}, {:2.1f}'
for i in range(1, order): for _ in range(1, order):
fmt += '/{:2.1f}' fmt += '/{:2.1f}'
fmt += ' (BP={:.3f}, ratio={:.3f}, syslen={}, reflen={})' fmt += ' (BP={:.3f}, ratio={:.3f}, syslen={}, reflen={})'
bleup = [p * 100 for p in self.precision()[:order]] bleup = [p * 100 for p in self.precision()[:order]]
......
...@@ -326,7 +326,7 @@ def shuffled_batches_by_size(src, dst, max_tokens=None, epoch=1, sample=0, max_p ...@@ -326,7 +326,7 @@ def shuffled_batches_by_size(src, dst, max_tokens=None, epoch=1, sample=0, max_p
batches = result batches = result
else: else:
for i in range(epoch - 1): for _ in range(epoch - 1):
np.random.shuffle(batches) np.random.shuffle(batches)
return batches return batches
......
...@@ -126,7 +126,7 @@ class SequenceGenerator(object): ...@@ -126,7 +126,7 @@ class SequenceGenerator(object):
# helper function for allocating buffers on the fly # helper function for allocating buffers on the fly
buffers = {} buffers = {}
def buffer(name, type_of=tokens): def buffer(name, type_of=tokens): # noqa
if name not in buffers: if name not in buffers:
buffers[name] = type_of.new() buffers[name] = type_of.new()
return buffers[name] return buffers[name]
......
...@@ -41,7 +41,7 @@ def torch_persistent_save(*args, **kwargs): ...@@ -41,7 +41,7 @@ def torch_persistent_save(*args, **kwargs):
for i in range(3): for i in range(3):
try: try:
return torch.save(*args, **kwargs) return torch.save(*args, **kwargs)
except: except Exception:
if i == 2: if i == 2:
logging.error(traceback.format_exc()) logging.error(traceback.format_exc())
......
#!/usr/bin/env python3
# Copyright (c) 2017-present, Facebook, Inc. # Copyright (c) 2017-present, Facebook, Inc.
# All rights reserved. # All rights reserved.
# #
......
#!/usr/bin/env python3
# Copyright (c) 2017-present, Facebook, Inc. # Copyright (c) 2017-present, Facebook, Inc.
# All rights reserved. # All rights reserved.
# #
......
#!/usr/bin/env python3
# Copyright (c) 2017-present, Facebook, Inc. # Copyright (c) 2017-present, Facebook, Inc.
# All rights reserved. # All rights reserved.
# #
......
#!/usr/bin/env python3
# Copyright (c) 2017-present, Facebook, Inc. # Copyright (c) 2017-present, Facebook, Inc.
# All rights reserved. # All rights reserved.
# #
......
#!/usr/bin/env python3
# Copyright (c) 2017-present, Facebook, Inc. # Copyright (c) 2017-present, Facebook, Inc.
# All rights reserved. # All rights reserved.
# #
......
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