def ensure_nn_index(hs, qdat, dcxs): # NNIndexes depend on the data cxs AND feature / chip configs feat_uid = qdat.cfg._feat_cfg.get_uid() dcxs_uid = helpers.hashstr_arr(dcxs, 'dcxs') + feat_uid if not dcxs_uid in qdat._dcxs2_index: # Make sure the features are all computed first print('[mc3] qdat._data_index[dcxs_uid]... cache miss') print('[mc3] dcxs_ is not in qdat cache') print('[mc3] hashstr(dcxs_) = %r' % dcxs_uid) print('[mc3] REFRESHING FEATURES') hs.refresh_features(dcxs) # Compute the FLANN Index data_index = ds.NNIndex(hs, dcxs) qdat._dcxs2_index[dcxs_uid] = data_index else: print('[mc3] qdat._data_index[dcxs_uid]... cache hit') qdat._data_index = qdat._dcxs2_index[dcxs_uid]
def make_nn_index(hs, sx2_cx=None): if sx2_cx is None: sx2_cx = hs.indexed_sample_cx data_index = ds.NNIndex(hs, sx2_cx) return data_index