def test_count(self): expected_map = { 0: 'a', 75: 'b', 124769: 'c', } dms = DataMemorySet() dms._element_map = expected_map self.assertEqual(dms.count(), 3)
img_c_mem_factory = ClassificationElementFactory(MemoryClassificationElement, {}) img_prob_classifier = IndexLabelClassifier(CAFFE_LABELS) eval_data2descr = {} d_to_proc = set() for data in eval_data_set: if not img_prob_descr_index.has_descriptor(data.uuid()): d_to_proc.add(data) else: eval_data2descr[data] = img_prob_descr_index[data.uuid()] if d_to_proc: eval_data2descr.update(img_prob_gen.compute_descriptor_async(d_to_proc)) d_to_proc.clear() assert len(eval_data2descr) == eval_data_set.count() index_additions = [] for data in d_to_proc: index_additions.append(eval_data2descr[data]) print "Adding %d new descriptors to prob index" % len(index_additions) img_prob_descr_index.add_many_descriptors(index_additions) eval_descr2class = img_prob_classifier.classify_async(eval_data2descr.values(), img_c_mem_factory) ############################################################################### # The shas that were actually computed computed_shas = {e.uuid() for e in eval_data2descr} len(computed_shas)