Esempio n. 1
0
    def test_configuration(self):
        index_filepath = osp.abspath(osp.expanduser('index_filepath'))
        para_filepath = osp.abspath(osp.expanduser('param_fp'))

        # Make configuration based on default
        c = MRPTNearestNeighborsIndex.get_default_config()
        c['index_filepath'] = index_filepath
        c['parameters_filepath'] = para_filepath
        c['descriptor_set']['type'] = 'MemoryDescriptorIndex'

        # Build based on configuration
        index = MRPTNearestNeighborsIndex.from_config(c)
        ntools.assert_equal(index._index_filepath, index_filepath)
        ntools.assert_equal(index._index_param_filepath, para_filepath)

        # Test that constructing a new instance from ``index``'s config yields
        # an index with the same configuration (idempotent).
        index2 = MRPTNearestNeighborsIndex.from_config(index.get_config())
        ntools.assert_equal(index.get_config(), index2.get_config())
Esempio n. 2
0
    def test_configuration(self):
        index_filepath = osp.abspath(osp.expanduser('index_filepath'))
        para_filepath = osp.abspath(osp.expanduser('param_fp'))

        # Make configuration based on default
        c = MRPTNearestNeighborsIndex.get_default_config()
        c['index_filepath'] = index_filepath
        c['parameters_filepath'] = para_filepath
        c['descriptor_set']['type'] = 'MemoryDescriptorIndex'

        # Build based on configuration
        index = MRPTNearestNeighborsIndex.from_config(c)
        ntools.assert_equal(index._index_filepath, index_filepath)
        ntools.assert_equal(index._index_param_filepath, para_filepath)

        c2 = index.get_config()
        ntools.assert_equal(c, c2)