def test_get_config_no_cache(self) -> None: itq = ItqFunctor(bit_length=1, itq_iterations=2, normalize=3, random_seed=4) c = itq.get_config() self.assertEqual(c['bit_length'], 1) self.assertEqual(c['itq_iterations'], 2) self.assertEqual(c['normalize'], 3) self.assertEqual(c['random_seed'], 4) self.assertIsNone(c['mean_vec_cache']['type']) self.assertIsNone(c['rotation_cache']['type'])
def test_get_config_with_cache_elements(self) -> None: itq = ItqFunctor(bit_length=5, itq_iterations=6, normalize=7, random_seed=8) itq.mean_vec_cache_elem = DataMemoryElement(b'cached vec bytes') itq.rotation_cache_elem = DataMemoryElement(b'cached rot bytes') c = itq.get_config() self.assertEqual(c['bit_length'], 5) self.assertEqual(c['itq_iterations'], 6) self.assertEqual(c['normalize'], 7) self.assertEqual(c['random_seed'], 8) dme_key = 'smqtk_dataprovider.impls.data_element.memory.DataMemoryElement' self.assertEqual(c['mean_vec_cache']['type'], dme_key) # Check using string encodings of set bytes (JSON compliant). self.assertEqual(c['mean_vec_cache'][dme_key]['bytes'], 'cached vec bytes') self.assertEqual(c['rotation_cache'][dme_key]['bytes'], 'cached rot bytes')