Exemple #1
0
    def test_init_consistency(self):
        # Test that constructing an instance with a configuration yields the
        # same config via ``get_config``.

        # - Default config should be a valid configuration for this impl.
        c = SkLearnBallTreeHashIndex.get_default_config()
        self.assertEqual(
            SkLearnBallTreeHashIndex.from_config(c).get_config(), c)
        # With non-null cache element
        c['cache_element']['type'] = 'DataMemoryElement'
        self.assertEqual(
            SkLearnBallTreeHashIndex.from_config(c).get_config(), c)
Exemple #2
0
def main():
    args = cli_parser().parse_args()
    config = smqtk.utils.bin_utils.utility_main_helper(default_config, args)
    log = logging.getLogger(__name__)

    # Loading from configurations
    bit_len = int(config['itq_bit_length'])
    log.info("Loading hash2uuid KeyValue store")
    #: :type: smqtk.representation.KeyValueStore
    hash2uuid_kv_store = smqtk.utils.plugin.from_plugin_config(
        config['hash2uuid_kv_store'],
        smqtk.representation.get_key_value_store_impls()
    )
    log.info("Initializing ball tree")
    btree = SkLearnBallTreeHashIndex.from_config(config['sklearn_balltree'])

    log.info("Computing hash-code vectors")
    hash_vectors = []
    reporter = smqtk.utils.bin_utils.ProgressReporter(log.debug, 1.0)
    reporter.start()
    for h in hash2uuid_kv_store.keys():
        hash_vectors.append(
            smqtk.utils.bit_utils.int_to_bit_vector_large(h, bit_len))
        reporter.increment_report()
    reporter.report()

    log.info("Building ball tree index")
    btree.build_index(hash_vectors)
Exemple #3
0
def main():
    args = cli_parser().parse_args()
    config = smqtk.utils.bin_utils.utility_main_helper(default_config, args)
    log = logging.getLogger(__name__)

    # Loading from configurations
    bit_len = int(config['itq_bit_length'])
    log.info("Loading hash2uuid KeyValue store")
    #: :type: smqtk.representation.KeyValueStore
    hash2uuid_kv_store = smqtk.utils.plugin.from_plugin_config(
        config['hash2uuid_kv_store'],
        smqtk.representation.get_key_value_store_impls())
    log.info("Initializing ball tree")
    btree = SkLearnBallTreeHashIndex.from_config(config['sklearn_balltree'])

    log.info("Computing hash-code vectors")
    hash_vectors = []
    reporter = smqtk.utils.bin_utils.ProgressReporter(log.debug, 1.0)
    reporter.start()
    for h in hash2uuid_kv_store.keys():
        hash_vectors.append(
            smqtk.utils.bit_utils.int_to_bit_vector_large(h, bit_len))
        reporter.increment_report()
    reporter.report()

    log.info("Building ball tree index")
    btree.build_index(hash_vectors)