當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。