File size: 1,411 Bytes
a5f760c |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 |
import unittest
import numpy as np
from . import metric
def to_numpy_list(x: list[list[list[int]]]) -> list[list[np.ndarray]]:
return [[np.array(z) for z in y] for y in x]
class TestEosMethods(unittest.TestCase):
def helper(self, data_arr, x, y) -> None:
expected = {
"EoS Token Pesent": x,
"EoS Padding": y,
}
for data in data_arr:
res = metric.end_of_sentence(data)
self.assertEqual(res, expected)
def test_false_false(self):
data_arr = to_numpy_list(
[
[
[1, 2, 3],
[1, 2, 4],
],
[
[1, 2, 0],
[0, 2, 0],
],
]
)
self.helper(data_arr, False, False)
def test_true_false(self):
data_arr = to_numpy_list(
[
[
[1, 2, 0],
[1, 2, 0],
],
]
)
self.helper(data_arr, True, False)
def test_true_true(self):
data_arr = to_numpy_list(
[
[
[1, 2, 0],
[1, 0, 0],
],
]
)
self.helper(data_arr, True, True)
def test_true(self):
pass
if __name__ == "__main__":
unittest.main()
|