def test_configuration_none_HI(self): c = LSHNearestNeighborIndex.get_default_config() # Check that default is in JSON format and is decoded to the same # result. self.assertEqual(json.loads(json.dumps(c)), c) # Make a simple configuration c['lsh_functor'][ 'type'] = 'smqtk.algorithms.nn_index.lsh.functors.itq.ItqFunctor' c['descriptor_set'][ 'type'] = 'smqtk.representation.descriptor_set.memory.MemoryDescriptorSet' c['hash2uuids_kvstore'][ 'type'] = 'smqtk.representation.key_value.memory.MemoryKeyValueStore' c['hash_index']['type'] = None index = LSHNearestNeighborIndex.from_config(c) self.assertIsInstance(index.lsh_functor, ItqFunctor) self.assertIsInstance(index.descriptor_set, MemoryDescriptorSet) self.assertIsNone(index.hash_index) self.assertIsInstance(index.hash2uuids_kvstore, MemoryKeyValueStore) # Can convert instance config to JSON self.assertEqual(json.loads(json.dumps(index.get_config())), index.get_config())
def test_configuration(self): c = LSHNearestNeighborIndex.get_default_config() # Check that default is in JSON format and is decoded to the same # result. self.assertEqual(json.loads(json.dumps(c)), c) # Make a simple configuration # - ItqFunctor should always be available since it has no dependencies. c['lsh_functor']['type'] = 'ItqFunctor' c['descriptor_index']['type'] = 'MemoryDescriptorIndex' c['hash2uuids_kvstore']['type'] = 'MemoryKeyValueStore' c['hash_index']['type'] = 'LinearHashIndex' index = LSHNearestNeighborIndex.from_config(c) self.assertIsInstance(index.lsh_functor, ItqFunctor) self.assertIsInstance(index.descriptor_index, MemoryDescriptorIndex) self.assertIsInstance(index.hash_index, LinearHashIndex) self.assertIsInstance(index.hash2uuids_kvstore, MemoryKeyValueStore) # Can convert instance config to JSON self.assertEqual( json.loads(json.dumps(index.get_config())), index.get_config() )
def test_configuration(self): c = LSHNearestNeighborIndex.get_default_config() ntools.assert_equal(json.loads(json.dumps(c)), c) # Make a simple configuration c["lsh_functor"]["type"] = "ItqFunctor" c["descriptor_index"]["type"] = "MemoryDescriptorIndex" c["hash_index"]["type"] = "LinearHashIndex" index = LSHNearestNeighborIndex.from_config(c) ntools.assert_is_instance(index.lsh_functor, ItqFunctor) ntools.assert_is_instance(index.descriptor_index, MemoryDescriptorIndex) ntools.assert_is_instance(index.hash_index, LinearHashIndex) # Can convert instance config to JSON ntools.assert_equal(json.loads(json.dumps(index.get_config())), index.get_config())
def test_configuration(self): c = LSHNearestNeighborIndex.get_default_config() ntools.assert_equal(json.loads(json.dumps(c)), c) # Make a simple configuration c['lsh_functor']['type'] = 'ItqFunctor' c['descriptor_index']['type'] = 'MemoryDescriptorIndex' c['hash_index']['type'] = 'LinearHashIndex' index = LSHNearestNeighborIndex.from_config(c) ntools.assert_is_instance(index.lsh_functor, ItqFunctor) ntools.assert_is_instance(index.descriptor_index, MemoryDescriptorIndex) ntools.assert_is_instance(index.hash_index, LinearHashIndex) # Can convert instance config to JSON ntools.assert_equal(json.loads(json.dumps(index.get_config())), index.get_config())
def test_configuration_none_HI(self): c = LSHNearestNeighborIndex.get_default_config() # Check that default is in JSON format and is decoded to the same # result. ntools.assert_equal(json.loads(json.dumps(c)), c) # Make a simple configuration c['lsh_functor']['type'] = 'ItqFunctor' c['descriptor_index']['type'] = 'MemoryDescriptorIndex' c['hash2uuids_kvstore']['type'] = 'MemoryKeyValueStore' c['hash_index']['type'] = None index = LSHNearestNeighborIndex.from_config(c) ntools.assert_is_instance(index.lsh_functor, ItqFunctor) ntools.assert_is_instance(index.descriptor_index, MemoryDescriptorIndex) ntools.assert_is_none(index.hash_index) ntools.assert_is_instance(index.hash2uuids_kvstore, MemoryKeyValueStore) # Can convert instance config to JSON ntools.assert_equal(json.loads(json.dumps(index.get_config())), index.get_config())
def test_configuration_none_HI(self): c = LSHNearestNeighborIndex.get_default_config() # Check that default is in JSON format and is decoded to the same # result. self.assertEqual(json.loads(json.dumps(c)), c) # Make a simple configuration c['lsh_functor']['type'] = 'ItqFunctor' c['descriptor_index']['type'] = 'MemoryDescriptorIndex' c['hash2uuids_kvstore']['type'] = 'MemoryKeyValueStore' c['hash_index']['type'] = None index = LSHNearestNeighborIndex.from_config(c) self.assertIsInstance(index.lsh_functor, ItqFunctor) self.assertIsInstance(index.descriptor_index, MemoryDescriptorIndex) self.assertIsNone(index.hash_index) self.assertIsInstance(index.hash2uuids_kvstore, MemoryKeyValueStore) # Can convert instance config to JSON self.assertEqual( json.loads(json.dumps(index.get_config())), index.get_config() )