Black formatting in fairseq/test_noising
Summary:
Pull Request resolved:
Use black formatting in test_noising.py
# the root directory of this source tree. An additional grant of patent rights
# can be found in the PATENTS file in the same directory.
-import torch
import unittest
import tests.utils as test_utils
+import torch
from fairseq import utils
from fairseq.data import (
AppendEosDataset,
Dictionary,
+ LanguagePairDataset,
data_utils,
noising,
- LanguagePairDataset,
)
@@ -74,7 +74,7 @@ class TestDataNoising(unittest.TestCase):
(
"Expected eos (token id {eos}) at the end of sentence {i} but "
"got {other} instead"
- ).format(i=i, eos=eos, other=x[i][-1])
+ ).format(i=i, eos=eos, other=x[i][-1]),
)
def assert_word_dropout_correct(self, x, x_noised, x_len, l_noised):
@@ -200,8 +200,8 @@ class TestDataNoising(unittest.TestCase):
x[x_len[i] - 1][i],
eos,
"Expected no eos (token id {eos}) at the end of sentence {i}.".format(
- eos=eos, i=i,
- )
+ eos=eos, i=i
+ ),
)
def test_word_dropout_without_eos(self):
@@ -273,10 +273,7 @@ class TestDataNoising(unittest.TestCase):
if use_append_eos_dataset:
tgt = AppendEosDataset(src_dataset, src_dict.eos())
language_pair_dataset = LanguagePairDataset(
- src=noising_dataset,
- tgt=tgt,
- src_sizes=None,
- src_dict=src_dict
+ src=noising_dataset, tgt=tgt, src_sizes=None, src_dict=src_dict
)
dataloader = torch.utils.data.DataLoader(
@@ -361,5 +358,5 @@ class TestDataNoising(unittest.TestCase):
self.assertEqual(t1.ne(t2).long().sum(), 0)
-if __name__ == '__main__':
+if __name__ == "__main__":
unittest.main()
