From d6d92010e0b42f5da4fb300d152d09e8bdc2f78a Mon Sep 17 00:00:00 2001 From: xuyige Date: Tue, 28 Aug 2018 13:39:28 +0800 Subject: [PATCH] add test code for testing action.py --- test/core/test_action.py | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) create mode 100644 test/core/test_action.py diff --git a/test/core/test_action.py b/test/core/test_action.py new file mode 100644 index 00000000..6ad1bd29 --- /dev/null +++ b/test/core/test_action.py @@ -0,0 +1,18 @@ +import os + +import unittest + +from fastNLP.core.action import Action, Batchifier, SequentialSampler + +class TestAction(unittest.TestCase): + def test_case_1(self): + x = [1, 2, 3, 4, 5, 6, 7, 8] + y = [1, 1, 1, 1, 2, 2, 2, 2] + data = [] + for i in range(len(x)): + data.append([[x[i]], [y[i]]]) + data = Batchifier(SequentialSampler(data), batch_size=2, drop_last=False) + action = Action() + for batch_x in action.make_batch(data, use_cuda=False, output_length=True, max_len=None): + print(batch_x) +