Commit 0b05467d authored by Liezl Puzon's avatar Liezl Puzon Committed by Facebook Github Bot
Browse files

Black formatting in fairseq/test_noising (#341)

Summary:
Pull Request resolved: https://github.com/pytorch/fairseq/pull/341

Use black formatting in test_noising.py

Reviewed By: xianxl

Differential Revision: D12810285

fbshipit-source-id: 5517dd5d2f086831f487d88acf6bc2fa18820297
parent 726a47dc
Loading
Loading
Loading
Loading
+7 −10
Original line number Diff line number Diff line
@@ -5,17 +5,17 @@
# 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()