mirror of
https://github.com/facebookresearch/fairseq.git
synced 2024-08-17 04:20:36 +03:00
Fix flake8 warnings
This commit is contained in:
parent
7333d04d3f
commit
cb0d7b2ad1
@ -7,3 +7,5 @@
|
||||
#
|
||||
|
||||
from .multiprocessing_pdb import pdb
|
||||
|
||||
__all__ = ['pdb']
|
||||
|
@ -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]]
|
||||
|
@ -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
|
||||
|
@ -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]
|
||||
|
@ -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())
|
||||
|
||||
|
@ -1,3 +1,4 @@
|
||||
#!/usr/bin/env python3
|
||||
# Copyright (c) 2017-present, Facebook, Inc.
|
||||
# All rights reserved.
|
||||
#
|
||||
|
@ -1,3 +1,4 @@
|
||||
#!/usr/bin/env python3
|
||||
# Copyright (c) 2017-present, Facebook, Inc.
|
||||
# All rights reserved.
|
||||
#
|
||||
|
1
score.py
1
score.py
@ -1,3 +1,4 @@
|
||||
#!/usr/bin/env python3
|
||||
# Copyright (c) 2017-present, Facebook, Inc.
|
||||
# All rights reserved.
|
||||
#
|
||||
|
1
setup.py
1
setup.py
@ -1,3 +1,4 @@
|
||||
#!/usr/bin/env python3
|
||||
# Copyright (c) 2017-present, Facebook, Inc.
|
||||
# All rights reserved.
|
||||
#
|
||||
|
Loading…
Reference in New Issue
Block a user