Testing no inplace change to the hashed item.
(self, hash_func)
| 91 | class TestLMDBDataset(unittest.TestCase): |
| 92 | @parameterized.expand([(pickle_hashing,), (json_hashing,)]) |
| 93 | def test_cache(self, hash_func): |
| 94 | """Testing no inplace change to the hashed item.""" |
| 95 | items = [[list(range(i))] for i in range(5)] |
| 96 | |
| 97 | with tempfile.TemporaryDirectory() as tempdir: |
| 98 | ds = LMDBDataset(items, transform=_InplaceXform(), cache_dir=tempdir, hash_func=hash_func, progress=False) |
| 99 | self.assertEqual(items, [[[]], [[0]], [[0, 1]], [[0, 1, 2]], [[0, 1, 2, 3]]], "Input dataset mutated.") |
| 100 | self.assertNotEqual(items, list(ds), "Output data unmodified by transform.") |
| 101 | self.assertIsInstance(ds.info(), dict) |
| 102 | |
| 103 | @parameterized.expand([TEST_CASE_1, TEST_CASE_2, TEST_CASE_3, TEST_CASE_4, TEST_CASE_5, TEST_CASE_6, TEST_CASE_7]) |
| 104 | def test_shape(self, transform, expected_shape, kwargs=None): |
nothing calls this directly
no test coverage detected