def sort_func(self,item): assert self.selected != None selected_sig = self.selected['signature'] item_sig = self.images[item[0]]['signature'] return -wavelet.signature_compare(selected_sig, item_sig)
def cluster_renderables(self): """cluster renderables by their score against the 2 base lines""" self.renderables_key_func = self.cluster_func key = 0 filename_sigs = [(filename, data['signature']) for filename, data in self.images.items()] seed = filename_sigs[0][0] del filename_sigs[0] done = False while len(filename_sigs): key+=1 sig = self.images[seed]['signature'] filename_sigs.sort(key = lambda x: -wavelet.signature_compare(sig, x[1])) f = filename_sigs[0][0] self.images[f]['cluster key']=key del filename_sigs[0] seed = f self.update_renderables()