当前位置: 首页>>代码示例>>Python>>正文


Python DescriptorMemoryElement.uuid方法代码示例

本文整理汇总了Python中smqtk.representation.descriptor_element.local_elements.DescriptorMemoryElement.uuid方法的典型用法代码示例。如果您正苦于以下问题:Python DescriptorMemoryElement.uuid方法的具体用法?Python DescriptorMemoryElement.uuid怎么用?Python DescriptorMemoryElement.uuid使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在smqtk.representation.descriptor_element.local_elements.DescriptorMemoryElement的用法示例。


在下文中一共展示了DescriptorMemoryElement.uuid方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: test_known_descriptors_euclidean_ordered

# 需要导入模块: from smqtk.representation.descriptor_element.local_elements import DescriptorMemoryElement [as 别名]
# 或者: from smqtk.representation.descriptor_element.local_elements.DescriptorMemoryElement import uuid [as 别名]
    def test_known_descriptors_euclidean_ordered(self):
        index = self._make_inst('euclidean')

        # make vectors to return in a known euclidean distance order
        i = 1000
        test_descriptors = []
        for j in xrange(i):
            d = DescriptorMemoryElement('ordered', j)
            d.set_vector(numpy.array([j, j*2], float))
            test_descriptors.append(d)
        random.shuffle(test_descriptors)
        index.build_index(test_descriptors)

        # Since descriptors were build in increasing distance from (0,0),
        # returned descriptors for a query of [0,0] should be in index order.
        q = DescriptorMemoryElement('query', i)
        q.set_vector(numpy.array([0, 0], float))
        # top result should have UUID == 0 (nearest to query)
        r, dists = index.nn(q, 5)
        ntools.assert_equal(r[0].uuid(), 0)
        ntools.assert_equal(r[1].uuid(), 1)
        ntools.assert_equal(r[2].uuid(), 2)
        ntools.assert_equal(r[3].uuid(), 3)
        ntools.assert_equal(r[4].uuid(), 4)
        # global search should be in complete order
        r, dists = index.nn(q, i)
        for j, d, dist in zip(range(i), r, dists):
            ntools.assert_equal(d.uuid(), j)
开发者ID:msarahan,项目名称:SMQTK,代码行数:30,代码来源:test_NNI_itq.py

示例2: _known_ordered_euclidean

# 需要导入模块: from smqtk.representation.descriptor_element.local_elements import DescriptorMemoryElement [as 别名]
# 或者: from smqtk.representation.descriptor_element.local_elements.DescriptorMemoryElement import uuid [as 别名]
    def _known_ordered_euclidean(self, hash_ftor, hash_idx,
                                 ftor_train_hook=lambda d: None):
        # make vectors to return in a known euclidean distance order
        i = 1000
        test_descriptors = []
        for j in range(i):
            d = DescriptorMemoryElement('ordered', j)
            d.set_vector(np.array([j, j*2], float))
            test_descriptors.append(d)
        random.shuffle(test_descriptors)

        ftor_train_hook(test_descriptors)

        di = MemoryDescriptorIndex()
        kvstore = MemoryKeyValueStore()
        index = LSHNearestNeighborIndex(hash_ftor, di, kvstore,
                                        hash_index=hash_idx,
                                        distance_method='euclidean')
        index.build_index(test_descriptors)

        # Since descriptors were built in increasing distance from (0,0),
        # returned descriptors for a query of [0,0] should be in index order.
        q = DescriptorMemoryElement('query', i)
        q.set_vector(np.array([0, 0], float))
        # top result should have UUID == 0 (nearest to query)
        r, dists = index.nn(q, 5)
        self.assertEqual(r[0].uuid(), 0)
        self.assertEqual(r[1].uuid(), 1)
        self.assertEqual(r[2].uuid(), 2)
        self.assertEqual(r[3].uuid(), 3)
        self.assertEqual(r[4].uuid(), 4)
        # global search should be in complete order
        r, dists = index.nn(q, i)
        for j, d, dist in zip(range(i), r, dists):
            self.assertEqual(d.uuid(), j)
开发者ID:Kitware,项目名称:SMQTK,代码行数:37,代码来源:test_NNI_lsh.py

示例3: test_set_state_version_1

# 需要导入模块: from smqtk.representation.descriptor_element.local_elements import DescriptorMemoryElement [as 别名]
# 或者: from smqtk.representation.descriptor_element.local_elements.DescriptorMemoryElement import uuid [as 别名]
    def test_set_state_version_1(self):
        # Test support of older state version
        expected_type = 'test-type'
        expected_uid = 'test-uid'
        expected_v = numpy.array([1, 2, 3])
        expected_v_b = BytesIO()
        # noinspection PyTypeChecker
        numpy.save(expected_v_b, expected_v)
        expected_v_dump = expected_v_b.getvalue()

        e = DescriptorMemoryElement(None, None)
        e.__setstate__((expected_type, expected_uid, expected_v_dump))
        self.assertEqual(e.type(), expected_type)
        self.assertEqual(e.uuid(), expected_uid)
        numpy.testing.assert_array_equal(e.vector(), expected_v)
开发者ID:Kitware,项目名称:SMQTK,代码行数:17,代码来源:test_DescriptorMemoryElement.py

示例4: test_known_descriptors_euclidean_ordered

# 需要导入模块: from smqtk.representation.descriptor_element.local_elements import DescriptorMemoryElement [as 别名]
# 或者: from smqtk.representation.descriptor_element.local_elements.DescriptorMemoryElement import uuid [as 别名]
        def test_known_descriptors_euclidean_ordered(self):
            index = self._make_inst('euclidean')

            # make vectors to return in a known euclidean distance order
            i = 10
            test_descriptors = []
            for j in xrange(i):
                d = DescriptorMemoryElement('ordered', j)
                d.set_vector(numpy.array([j, j*2], float))
                test_descriptors.append(d)
            random.shuffle(test_descriptors)
            index.build_index(test_descriptors)

            # Since descriptors were build in increasing distance from (0,0),
            # returned descriptors for a query of [0,0] should be in index order.
            q = DescriptorMemoryElement('query', 99)
            q.set_vector(numpy.array([0, 0], float))
            r, dists = index.nn(q, i)
            for j, d, dist in zip(range(i), r, dists):
                ntools.assert_equal(d.uuid(), j)
开发者ID:mrG7,项目名称:SMQTK,代码行数:22,代码来源:test_NNI_FLANN.py


注:本文中的smqtk.representation.descriptor_element.local_elements.DescriptorMemoryElement.uuid方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。