本文整理汇总了Python中smqtk.representation.descriptor_index.memory.MemoryDescriptorIndex.from_config方法的典型用法代码示例。如果您正苦于以下问题:Python MemoryDescriptorIndex.from_config方法的具体用法?Python MemoryDescriptorIndex.from_config怎么用?Python MemoryDescriptorIndex.from_config使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类smqtk.representation.descriptor_index.memory.MemoryDescriptorIndex
的用法示例。
在下文中一共展示了MemoryDescriptorIndex.from_config方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_from_config
# 需要导入模块: from smqtk.representation.descriptor_index.memory import MemoryDescriptorIndex [as 别名]
# 或者: from smqtk.representation.descriptor_index.memory.MemoryDescriptorIndex import from_config [as 别名]
def test_from_config(self):
inst = MemoryDescriptorIndex.from_config({'file_cache': None})
ntools.assert_is_none(inst.file_cache)
fp = '/doesnt/exist/yet'
inst = MemoryDescriptorIndex.from_config({'file_cache': fp})
ntools.assert_equal(inst.file_cache, fp)
示例2: test_from_config_null_cache_elem
# 需要导入模块: from smqtk.representation.descriptor_index.memory import MemoryDescriptorIndex [as 别名]
# 或者: from smqtk.representation.descriptor_index.memory.MemoryDescriptorIndex import from_config [as 别名]
def test_from_config_null_cache_elem(self):
inst = MemoryDescriptorIndex.from_config({'cache_element': None})
self.assertIsNone(inst.cache_element)
self.assertEqual(inst._table, {})
inst = MemoryDescriptorIndex.from_config({
'cache_element': {
'type': None
}
})
self.assertIsNone(inst.cache_element)
self.assertEqual(inst._table, {})
示例3: test_from_config_null_cache_elem_type
# 需要导入模块: from smqtk.representation.descriptor_index.memory import MemoryDescriptorIndex [as 别名]
# 或者: from smqtk.representation.descriptor_index.memory.MemoryDescriptorIndex import from_config [as 别名]
def test_from_config_null_cache_elem_type(self):
# An empty cache should not trigger loading on construction.
expected_empty_cache = DataMemoryElement()
inst = MemoryDescriptorIndex.from_config({
'cache_element': {
'type': 'DataMemoryElement',
'DataMemoryElement': {'bytes': ''}
}
})
self.assertEqual(inst.cache_element, expected_empty_cache)
self.assertEqual(inst._table, {})
示例4: test_from_config
# 需要导入模块: from smqtk.representation.descriptor_index.memory import MemoryDescriptorIndex [as 别名]
# 或者: from smqtk.representation.descriptor_index.memory.MemoryDescriptorIndex import from_config [as 别名]
def test_from_config(self):
# Configured cache with some picked bytes
expected_table = dict(a=1, b=2, c=3)
expected_cache = DataMemoryElement(bytes=pickle.dumps(expected_table))
inst = MemoryDescriptorIndex.from_config({
'cache_element': {
'type': 'DataMemoryElement',
'DataMemoryElement': {'bytes': expected_cache.get_bytes()}
}
})
self.assertEqual(inst.cache_element, expected_cache)
self.assertEqual(inst._table, expected_table)
示例5: test_default_config
# 需要导入模块: from smqtk.representation.descriptor_index.memory import MemoryDescriptorIndex [as 别名]
# 或者: from smqtk.representation.descriptor_index.memory.MemoryDescriptorIndex import from_config [as 别名]
def test_default_config(self):
# Default should be valid for constructing a new instance.
c = MemoryDescriptorIndex.get_default_config()
self.assertEqual(MemoryDescriptorIndex.from_config(c).get_config(), c)