MCPcopy Create free account
hub / github.com/Project-MONAI/MONAI / test_cache

Method test_cache

tests/data/test_lmdbdataset.py:93–101  ·  view source on GitHub ↗

Testing no inplace change to the hashed item.

(self, hash_func)

Source from the content-addressed store, hash-verified

91class 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):

Callers

nothing calls this directly

Calls 3

infoMethod · 0.95
LMDBDatasetClass · 0.90
_InplaceXformClass · 0.70

Tested by

no test coverage detected