You can not select more than 25 topics Topics must start with a chinese character,a letter or number, can include dashes ('-') and can be up to 35 characters long.

test_dataset.py 598 B

1234567891011121314151617181920
  1. import unittest
  2. from fastNLP.core.dataset import DataSet
  3. class TestDataSet(unittest.TestCase):
  4. def test_case_1(self):
  5. ds = DataSet()
  6. ds.add_field(name="xx", fields=["a", "b", "e", "d"])
  7. self.assertTrue("xx" in ds.field_arrays)
  8. self.assertEqual(len(ds.field_arrays["xx"]), 4)
  9. self.assertEqual(ds.get_length(), 4)
  10. self.assertEqual(ds.get_fields(), ds.field_arrays)
  11. try:
  12. ds.add_field(name="yy", fields=["x", "y", "z", "w", "f"])
  13. except BaseException as e:
  14. self.assertTrue(isinstance(e, AssertionError))