df2.set_figtitle('Show Chip (normal)') viz.show_chip(ibs, aid, in_image=True, fnum=3, **kpts_kwgs) df2.set_figtitle('Show Chip (in_image)') #---------------------- if not query_failed: print('Show Query') viz.show_matches(ibs, qres, aid2, fnum=4) df2.set_figtitle('Show Chipres') viz.show_qres(ibs, qres, fnum=5) df2.set_figtitle('Show QRes') ##---------------------- print('return test locals') return locals() if __name__ == '__main__': import ibeis multiprocessing.freeze_support() # For windows main_locals = ibeis.main(defaultdb='testdb1', gui=False) ibs = main_locals['ibs'] # IBEIS Control test_locals = utool.run_test(TEST_VIZ, ibs) execstr = utool.execstr_dict(test_locals, 'test_locals') exec(execstr) import sys if '--noshow' not in sys.argv: exec(df2.present()) exec(utool.ipython_execstr())
# Test regular computing if full_test: dx2_label, centers = clustering.akmeans(data, num_clusters, max_iters=max_iters) assert centers.shape == (num_clusters, dims), 'sanity check' assert dx2_label.shape == (nump,), 'sanity check' if False: # other test (development) import pyflann flann_lib_inst = pyflann.flann flann_class_inst = pyflann.FLANN() flann_class_inst.build_index(data) return locals() if __name__ == '__main__': testkw = { 'plot_test': utool.get_argflag('--plot-test'), 'full_test': utool.get_argflag('--full-test'), 'num_pca_dims': utool.get_argval('--num-pca-dims', type_=int, default=2), 'data_dim': utool.get_argval('--data-dim', type_=int, default=2), 'nump': utool.get_argval('--nump', type_=int, default=2000), } test_locals = utool.run_test(test_akmeans, **testkw) exec(utool.execstr_dict(test_locals, 'test_locals')) if testkw['plot_test']: from plottool import draw_func2 as df2 exec(df2.present()) else: exec(utool.ipython_execstr())
operation=''' SELECT name_rowid FROM names WHERE name_text=? ''', params_iter=((name,) for name in query_names)) # Get the parameter indexes that failed failx_list = [count for count, nid in enumerate(nid_list) if nid is None] assert failx_list == [3] failed_names = [query_names[failx] for failx in failx_list] # NOQA utool.printvar2('failed_names') # We selected a name not in the table. # Its return index is an empty list print('[TEST] nid_list=%r' % nid_list) print('[TEST] query_names=%r' % query_names) print('[TEST] test_names=%r' % test_names) # SQL INTEGERS START AT 1 APPARENTLY #expected_names = [test_names[nid - 1] for nid in nid_list] #assert expected_names == query_names, 'unexpected results from select names' return locals() if __name__ == '__main__': import multiprocessing multiprocessing.freeze_support() # For windows test_locals = utool.run_test(TEST_SQL_NAMES) execstr = utool.execstr_dict(test_locals, 'test_locals') exec(execstr)
assert bbox_list[0] == (50, 50, 100, 100) except AssertionError as ex: utool.printex(ex, key_list=['bbox_list', 'aid_list']) raise back.reselect_annotation(bbox=[51, 52, 103, 104]) assert ibs.get_annot_bboxes(aid_list[0]) == (51, 52, 103, 104) back.compute_encounters() unixtime_list = [100, 23, 24] ibs.set_image_unixtime(gid_list, unixtime_list) back.compute_encounters() # Change some ANNOTATIONs #add_annot(gid_list[2], None) # user selection #add_annot(None, [42, 42, 8, 8]) # back selection # I'm not sure how I want to integrate that IPython stuff return locals() if __name__ == '__main__': multiprocessing.freeze_support() # For windows main_locals = ibeis.main(defaultdb='testdb0', gui=True) gpath_list = grabdata.get_test_gpaths(names=['lena', 'zebra', 'jeff']) ibs = main_locals['ibs'] # IBEIS Control back = main_locals['back'] # IBEIS GUI backend test_locals = utool.run_test(TEST_GUI_ALL, ibs, back, gpath_list) execstr = utool.execstr_dict(test_locals, 'test_locals') exec(execstr)
#!/usr/bin/env python2.7 # TODO: ADD COPYRIGHT TAG from __future__ import absolute_import, division, print_function import multiprocessing import utool from ibeis.dev import sysres print, print_, printDBG, rrr, profile = utool.inject(__name__, '[TEST_GUI_OPEN_DATABASE]') def TEST_GUI_OPEN_DATABASE(ibs, back): testdb0 = sysres.db_to_dbdir('testdb0') testdb1 = sysres.db_to_dbdir('testdb1') print('[TEST] TEST_OPEN_DATABASE testdb1=%r' % testdb1) back.open_database(testdb1) print('[TEST] TEST_OPEN_DATABASE testdb0=%r' % testdb0) back.open_database(testdb0) return locals() if __name__ == '__main__': multiprocessing.freeze_support() # For windows import ibeis main_locals = ibeis.main(defaultdb='testdb0', gui=True) ibs = main_locals['ibs'] # IBEIS Control back = main_locals['back'] # IBEIS GUI backend test_locals = utool.run_test(TEST_GUI_OPEN_DATABASE, ibs, back) execstr = utool.execstr_dict(test_locals, 'test_locals') exec(execstr)
def TEST_DELETE_ANNOTATION_CHIPS(ibs, back): gpath_list = grabdata.get_test_gpaths(ndata=None)[0:4] gid_list = ibs.add_images(gpath_list) bbox_list = [(0, 0, 100, 100)] * len(gid_list) name_list = ['a', 'b', 'a', 'd'] aid_list = ibs.add_annots(gid_list, bbox_list=bbox_list, name_list=name_list) assert len(aid_list) != 0, "No annotations" aid = aid_list[0] gid = ibs.get_annot_gids(aid) assert gid is not None, "gid for aid=%r is None" % (aid,) gthumbpath = ibs.get_image_thumbpath(gid) annotation_thumbpath = ibs.get_annot_chip_thumbpath(aid) ibs.delete_annot_chips(aid) aid_list = ibs.get_valid_aids() assert aid in aid_list, "Error: Annotation deleted" assert not utool.checkpath(gthumbpath), "Image Thumbnail not deleted" assert not utool.checkpath(annotation_thumbpath), "Roi Thumbnail not deleted" return locals() if __name__ == '__main__': multiprocessing.freeze_support() # For windows import ibeis main_locals = ibeis.main(defaultdb='testdb_empty', gui=False, allow_newdir=True, delete_ibsdir=True) ibs = main_locals['ibs'] # IBEIS Control back = main_locals['back'] # IBEIS GUI backend test_locals = utool.run_test(TEST_DELETE_ANNOTATION_CHIPS, ibs, back) exec(utool.execstr_dict(test_locals, 'test_locals')) exec(utool.ipython_execstr())
def TEST_DELETE_CHIPS(ibs, back): gpath_list = grabdata.get_test_gpaths(ndata=None)[0:4] gid_list = ibs.add_images(gpath_list) bbox_list = [(0, 0, 100, 100)] * len(gid_list) name_list = ['a', 'b', 'a', 'd'] aid_list = ibs.add_annots(gid_list, bbox_list=bbox_list, name_list=name_list) cid_list = ibs.add_annot_chips(aid_list) cid = cid_list[0] _fid = ibs.get_chip_feat_rowid(cid, ensure=False) assert _fid is None, "_fid=%r should be None" % (_fid,) _fid = ibs.get_chip_feat_rowid(cid, ensure=True) assert _fid is not None, "_fid=%r should be computed" % (_fid,) ibs.delete_chips(cid) cid_list = ibs.get_valid_cids() assert cid not in cid_list, "CID not deleted" all_fids = ibs.get_valid_fids() assert _fid not in all_fids, "FID not deleted" return locals() if __name__ == '__main__': multiprocessing.freeze_support() # For windows import ibeis main_locals = ibeis.main(defaultdb='testdb_empty', gui=False, allow_newdir=True, delete_ibsdir=True) ibs = main_locals['ibs'] # IBEIS Control back = main_locals['back'] # IBEIS GUI backend test_locals = utool.run_test(TEST_DELETE_CHIPS, ibs, back) exec(utool.execstr_dict(test_locals, 'test_locals')) exec(utool.ipython_execstr())
cur, 'INSERT', alter_insert, isolation_level, transaction=trans)) status.append( test_query(connection, cur, 'INSERT', alter_insert, isolation_level, transaction=trans, commit=True)) if not all(status): raise Exception("Tests failed for %r" % (isolation_level)) # This will never happen unless SQLite 3 freaks out return locals() if __name__ == '__main__': import multiprocessing multiprocessing.freeze_support() # For windows test_locals = utool.run_test(TEST_SQL_REVERT) test_locals = utool.run_test(TEST_SQL_REVERT, isolation_level='DEFERRED') test_locals = utool.run_test(TEST_SQL_REVERT, isolation_level='IMMEDIATE') test_locals = utool.run_test(TEST_SQL_REVERT, isolation_level='EXCLUSIVE') execstr = utool.execstr_dict(test_locals, 'test_locals') exec(execstr)
assert alrids_list, 'alrids_list is empty' alrid_list = utool.flatten(alrids_list) orig_confidences = ibs.get_alr_confidence(alrid_list) new_confidences = range(len(alrid_list)) #ibs.print_alr_table() ibs.set_alr_confidence(alrid_list, new_confidences) #ibs.print_alr_table() new_confidences2 = ibs.get_alr_confidence(alrid_list) assert new_confidences == new_confidences2, 'new_confidences == new_confidences2 failed' ibs.set_alr_confidence(alrid_list, orig_confidences) assert orig_confidences == ibs.get_alr_confidence(alrid_list), 'alr confidences were not reset' """ test metadata """ #ibs.print_tables() ibs.print_lblannot_table() ibs.print_alr_table() return locals() if __name__ == '__main__': import multiprocessing multiprocessing.freeze_support() # For win32 import ibeis # Initialize database main_locals = ibeis.main(defaultdb='testdb1', gui=False) ibs = main_locals['ibs'] test_locals = utool.run_test(TEST_IBS_CONTROL, ibs) execstr = utool.execstr_dict(test_locals, 'test_locals') exec(execstr)
aids = aid_list[1:3] interact.ishow_image(ibs, gid, aids=aids, fnum=1) #---------------------- #print('Show Chip') interact.ishow_chip(ibs, aid, in_image=False, fnum=2) #interact.ishow_chip(ibs, aid, in_image=True, fnum=3) #---------------------- #print('Show Query') #aid1 = aid #qcid2_qres = ibs._query_chips4([qaid1], valid_aids) #qres = qcid2_qres.values()[0] #top_cids = qres.get_top_cids(ibs) #assert len(top_cids) > 0, 'there does not seem to be results' #cid2 = top_cids[0] # 294 #viz.show_matches(ibs, qres, cid2, fnum=4) #viz.show_qres(ibs, qres, fnum=5) return locals() if __name__ == '__main__': multiprocessing.freeze_support() # For windows import ibeis main_locals = ibeis.main(defaultdb='testdb0') ibs = main_locals['ibs'] # IBEIS Control test_locals = utool.run_test(TEST_INTERACT, ibs) #execstr = utool.execstr_dict(test_locals, 'test_locals') #exec(execstr)
gpath_list = [join(imgdir, gname) for gname in gname_list] gpath_list = gpath_list assert all(map(exists, gpath_list)), 'some images dont exist' #nImages = len(gpath_list) #with utool.Timer('Add %d Images' % nImages): gid_list = ibs.add_images(gpath_list) #with utool.Timer('Convert %d Images to annotations' % nImages): aid_list = ibsfuncs.use_images_as_annotations(ibs, gid_list) #with utool.Timer('Compute %d chips' % nImages): cid_list = ibs.add_chips(aid_list) #with utool.Timer('Compute %d features' % nImages): fid_list = ibs.add_feats(cid_list) #with utool.Timer('Getting %d nFeats' % nImages): nFeats_list = ibs.get_num_feats(fid_list) print('Total number of features in the database: %r' % sum(nFeats_list)) return locals() if __name__ == '__main__': multiprocessing.freeze_support() # For windows test_locals = utool.run_test(MAKE_BIG_DB) execstr = utool.execstr_dict(test_locals, 'test_locals') exec('execstr')
name_list = ['a', 'b', 'a', 'd'] aid_list = ibs.add_annots(gid_list, bbox_list=bbox_list, name_list=name_list) cid_list = ibs.add_annot_chips(aid_list) cid = cid_list[0] _fid = ibs.get_chip_feat_rowid(cid, ensure=False) assert _fid is None, "_fid=%r should be None" % (_fid, ) _fid = ibs.get_chip_feat_rowid(cid, ensure=True) assert _fid is not None, "_fid=%r should be computed" % (_fid, ) ibs.delete_chips(cid) cid_list = ibs.get_valid_cids() assert cid not in cid_list, "CID not deleted" all_fids = ibs.get_valid_fids() assert _fid not in all_fids, "FID not deleted" return locals() if __name__ == '__main__': multiprocessing.freeze_support() # For windows import ibeis main_locals = ibeis.main(defaultdb='testdb_empty', gui=False, allow_newdir=True, delete_ibsdir=True) ibs = main_locals['ibs'] # IBEIS Control back = main_locals['back'] # IBEIS GUI backend test_locals = utool.run_test(TEST_DELETE_CHIPS, ibs, back) exec(utool.execstr_dict(test_locals, 'test_locals')) exec(utool.ipython_execstr())
aids = aid_list[1:3] interact.ishow_image(ibs, gid, aids=aids, fnum=1) #---------------------- #print('Show Chip') interact.ishow_chip(ibs, aid, in_image=False, fnum=2) #interact.ishow_chip(ibs, aid, in_image=True, fnum=3) #---------------------- #print('Show Query') #aid1 = aid #qcid2_qres = ibs.query_all([aid1]) #qres = qcid2_qres.values()[0] #top_cids = qres.get_top_cids(ibs) #assert len(top_cids) > 0, 'there does not seem to be results' #cid2 = top_cids[0] # 294 #viz.show_matches(ibs, qres, cid2, fnum=4) #viz.show_qres(ibs, qres, fnum=5) return locals() if __name__ == '__main__': multiprocessing.freeze_support() # For windows import ibeis main_locals = ibeis.main(defaultdb='testdb0') ibs = main_locals['ibs'] # IBEIS Control test_locals = utool.run_test(TEST_INTERACT, ibs) execstr = utool.execstr_dict(test_locals, 'test_locals') exec(execstr)
aids_list = ibs.get_image_aids(gid) print(' * gid_list=%r' % gid_list) print(' * bbox_list=%r' % bbox_list) print(' * theta_list=%r' % theta_list) print(' * aids_list=%r' % aids_list) assert len(bbox_list) == len( theta_list), "len(bbox_list) != len(theta_list)" assert len(theta_list) == len(aid_list), "len(theta_list) != len(aid_list)" viz.show_image(ibs, gid) return locals() if __name__ == '__main__': import multiprocessing multiprocessing.freeze_support() # For win32 import ibeis # Initialize database try: main_locals = ibeis.main(defaultdb='testdb0', gui=False) ibs = main_locals['ibs'] test_locals = utool.run_test(TEST_IBS, ibs) except RuntimeError as ex: utool.printex(ex) import matplotlib as mpl backend = mpl.get_backend() print('[test] current backend is: %r' % backend) raise execstr = utool.execstr_dict(test_locals, 'test_locals') exec(execstr)
#!/usr/bin/env python2.7 # TODO: ADD COPYRIGHT TAG from __future__ import absolute_import, division, print_function import utool print, print_, printDBG, rrr, profile = utool.inject(__name__, '[TEST_IBS_INFO]') def TEST_IBS_INFO(ibs): print(ibs.get_infostr()) ibs.print_tables() ibs.print_stats() return locals() if __name__ == '__main__': import multiprocessing multiprocessing.freeze_support() # For win32 import ibeis # Initialize database main_locals = ibeis.main(defaultdb='testdb1', gui=False) ibs = main_locals['ibs'] test_locals = utool.run_test(TEST_IBS_INFO, ibs) execstr = utool.execstr_dict(test_locals, 'test_locals') exec(execstr) exec(utool.ipython_execstr())
max_iters=max_iters) assert centers.shape == (num_clusters, dims), 'sanity check' assert dx2_label.shape == (nump, ), 'sanity check' if False: # other test (development) import pyflann flann_lib_inst = pyflann.flann flann_class_inst = pyflann.FLANN() flann_class_inst.build_index(data) return locals() if __name__ == '__main__': testkw = { 'plot_test': utool.get_argflag('--plot-test'), 'full_test': utool.get_argflag('--full-test'), 'num_pca_dims': utool.get_argval('--num-pca-dims', type_=int, default=2), 'data_dim': utool.get_argval('--data-dim', type_=int, default=2), 'nump': utool.get_argval('--nump', type_=int, default=2000), } test_locals = utool.run_test(test_akmeans, **testkw) exec(utool.execstr_dict(test_locals, 'test_locals')) if testkw['plot_test']: from plottool import draw_func2 as df2 exec(df2.present()) else: exec(utool.ipython_execstr())
# Define the schema __define_schema(db) # # -------- RUN INSERTS -------------- print('[TEST] --- INSERT NAMES --- ') test_names = [ 'fred', 'sue', 'Robert\');DROP TABLE names;--', 'joe', 'rob', ] __insert_names(db, test_names) __insert_names(db, test_names[2:3]) # # -------- RUN SELECT NAMES -------------- print('[TEST] --- SELECT NAMES ---') name_text_results = db.executeone('SELECT name_text FROM names', []) print(' * name_text_results=%r' % name_text_results) #assert name_text_results == test_names, 'unexpected results from select names' return locals() if __name__ == '__main__': import multiprocessing multiprocessing.freeze_support() # For windows test_locals = utool.run_test(TEST_SQL_NAMES) execstr = utool.execstr_dict(test_locals, 'test_locals') exec(execstr)
print('3b) names_list = %s' % (utool.list_str(names_list),)) print('3b) target_name_text = %s' % (utool.list_str(target_name_text),)) print('') assert gids_test_list == gids_target_list, 'gids_test_list does not match gids_target_list' assert gid_uuids_list == target_gid_uuids, 'gid_uuids_list does not match target_gid_uuids' assert enctext_list == target_enctexts, 'enctext_list does not match target_enctexts' assert names_list == target_name_text, 'names_list does not match target_name_text' except AssertionError as ex: utool.printex(ex, 'failed test_encounter') raise gids_list2 = ibsfuncs.unflat_lookup(ibs.get_annot_gids, aids_list) assert gids_list2 == map(tuple, gids_list) return locals() if __name__ == '__main__': multiprocessing.freeze_support() # For windows import ibeis main_locals = ibeis.main(defaultdb='testdb1', gui=False) ibs = main_locals['ibs'] test_locals = utool.run_test(TEST_ENCOUNTERS, ibs) execstr = utool.execstr_dict(test_locals, 'test_locals') exec(execstr)
print, print_, printDBG, rrr, profile = utool.inject(__name__, '[TEST_DELETE_FEATURE]') def TEST_DELETE_FEATURE(ibs, back): gpath_list = grabdata.get_test_gpaths(ndata=None)[0:4] gid_list = ibs.add_images(gpath_list) bbox_list = [(0, 0, 100, 100)] * len(gid_list) name_list = ['a', 'b', 'a', 'd'] aid_list = ibs.add_annots(gid_list, bbox_list=bbox_list, name_list=name_list) cid_list = ibs.add_annot_chips(aid_list) assert len(cid_list) != 0, "No chips added" fid_list = ibs.add_chip_feat(cid_list) assert len(fid_list) != 0, "No features added" fid = fid_list[0] ibs.delete_features(fid) fid_list = ibs.get_valid_fids() assert fid not in fid_list, "FID not deleted" return locals() if __name__ == '__main__': multiprocessing.freeze_support() # For windows import ibeis main_locals = ibeis.main(defaultdb='testdb_empty', gui=False, allow_newdir=True, delete_ibsdir=True) ibs = main_locals['ibs'] # IBEIS Control back = main_locals['back'] # IBEIS GUI backend test_locals = utool.run_test(TEST_DELETE_FEATURE, ibs, back) exec(utool.execstr_dict(test_locals, 'test_locals')) exec(utool.ipython_execstr())
# TODO: ADD COPYRIGHT TAG from __future__ import absolute_import, division, print_function import multiprocessing import utool from vtool.tests import grabdata from ibeis.algo.preproc import preproc_image from PIL import Image print, print_, printDBG, rrr, profile = utool.inject(__name__, '[TEST_PIL_HASH]') def TEST_PIL_HASH(): print('[TEST] GET_TEST_IMAGE_PATHS') # The test api returns a list of interesting chip indexes gpath_list = grabdata.get_test_gpaths(ndata=None) pil_img_list = [Image.open(gpath, 'r') for gpath in gpath_list] # NOQA uuid_list = [ preproc_image.get_image_uuid(pil_img) for pil_img in pil_img_list ] unique_uuid_list = list(set(uuid_list)) assert len(uuid_list) == len( unique_uuid_list), 'Reinstall PIL, watch for libjpeg' return locals() if __name__ == '__main__': multiprocessing.freeze_support() # For win32 test_locals = utool.run_test(TEST_PIL_HASH) execstr = utool.execstr_dict(test_locals, 'test_locals') exec(execstr)
split_index = NNSplitIndex(ibs, daid_list, num_forests=num_forests) #nid_list = ibs.get_annot_nids(aid_list) ##flag_list = ibs.get_annot_exemplar_flag(aid_list) #nid2_aids = utool.group_items(aid_list, nid_list) #key_list = nid2_aids.keys() #val_list = nid2_aids.values() #isunknown_list = ibs.is_nid_unknown(key_list) #num_forests = 8 ## Put one name per forest #forest_aids, overflow_aids = utool.sample_zip(val_list, num_forests, allow_overflow=True) #forest_indexes = [] #for tx, aids in enumerate(forest_aids): # print('[nn] building forest %d/%d' % (tx + 1, num_forests)) # nn_index = NNIndex(ibs, aids) # forest_indexes.append(nn_index) return locals() if __name__ == '__main__': multiprocessing.freeze_support() # For win32 import ibeis main_locals = ibeis.main(defaultdb='GZ_ALL', gui=False) ibs = main_locals['ibs'] # IBEIS Control test_locals = utool.run_test(TEST_HOTS_SPLITTREE, ibs) execstr = utool.execstr_dict(test_locals, 'testdb1') exec(execstr)
# Drop column ##################### drop_column(db) # Verify table's schema colname_list = db.get_column_names('test3') coltype_list = db.get_column_types('test3') assert colname_list == ['test_rowid', 'test_text', 'test_integer' ], 'Actual values: %r ' % colname_list assert coltype_list == [u'INTEGER PRIMARY KEY', u'TEXT NOT NULL', u'TEXT'], 'Actual values: %r ' % coltype_list ##################### # Drop table ##################### drop_table(db) tablename_list = db.get_table_names() assert tablename_list == ['metadata', 'test'], 'Actual values: %r ' % tablename_list return locals() if __name__ == '__main__': import multiprocessing multiprocessing.freeze_support() # For windows test_locals = utool.run_test(TEST_SQL_MODIFY) execstr = utool.execstr_dict(test_locals, 'test_locals') exec(execstr)
print(' * commit time=%r sec' % utool.toc(tt)) print('[TEST] read from sql database') tt = utool.tic() db.cur.execute('SELECT temp_hash FROM temp', []) print(' * execute select time=%r sec' % utool.toc(tt)) tt = utool.tic() result_list = _results_gen(db.cur) print(' * iter results time=%r sec' % utool.toc(tt)) print(' * memory(result_list) = %s' % utool.byte_str2(utool.get_object_size(result_list))) del result_list #print('[TEST] result_list=%r' % result_list) print('[TEST] dump sql database') tt = utool.tic() db.dump('temp.dump.txt') print(' * dump time=%r sec' % utool.toc(tt)) #with open('temp.dump.txt') as file_: # print(file_.read()) return locals() if __name__ == '__main__': import multiprocessing multiprocessing.freeze_support() # For win32 test_locals = utool.run_test(TEST_SQL_NUMPY) execstr = utool.execstr_dict(test_locals, 'test_locals') exec(execstr)
print(lbl) fnum = df2.next_fnum() df2.figure(fnum=fnum, doclf=True) #viz_matches.show_matches(ibs, qres, aid2, fnum=fnum, in_image=True) #viz.show_qres(ibs, qres, fnum=fnum, top_aids=top_aids, ensure=False) interact.ishow_qres(ibs, qres, fnum=fnum, top_aids=top_aids, ensure=False) df2.set_figtitle(lbl) df2.adjust_subplots_safe(top=.8) fnum = df2.next_fnum() qaid2_svtups = comp_locals_['qaid2_svtups'] qaid2_chipmatch_FILT = comp_locals_['qaid2_chipmatch_FILT'] aid1 = qaid = comp_locals_['qaid'] aid2_svtup = qaid2_svtups[aid1] chipmatch_FILT = qaid2_chipmatch_FILT[aid1] viz.show_sver(ibs, aid1, aid2, chipmatch_FILT, aid2_svtup, fnum=fnum) return locals() if __name__ == '__main__': multiprocessing.freeze_support() # For windows import ibeis main_locals = ibeis.main(defaultdb='testdb1', gui=False) ibs = main_locals['ibs'] test_locals = utool.run_test(TEST_QUERY_COMP, ibs) if '--noshow' not in sys.argv: df2.present() execstr = utool.execstr_dict(test_locals, 'test_locals') exec(execstr)
print('3b) names_list = %s' % (utool.list_str(names_list),)) print('3b) target_name_texts = %s' % (utool.list_str(target_name_texts),)) print('') assert gids_test_list == gids_target_list, 'gids_test_list does not match gids_target_list' assert gid_uuids_list == target_gid_uuids, 'gid_uuids_list does not match target_gid_uuids' assert imagesettext_list == target_imagesettexts, 'imagesettext_list does not match target_imagesettexts' assert names_list == target_name_texts, 'names_list does not match target_name_texts' except AssertionError as ex: utool.printex(ex, 'failed test_imageset') raise gids_list2 = list(map(list, ibsfuncs.unflat_map(ibs.get_annot_gids, aids_list))) assert gids_list2 == list(map(list, gids_list)) return locals() if __name__ == '__main__': multiprocessing.freeze_support() # For windows import ibeis main_locals = ibeis.main(defaultdb='testdb1', gui=False) ibs = main_locals['ibs'] test_locals = utool.run_test(TEST_IMAGESETS, ibs) execstr = utool.execstr_dict(test_locals, 'test_locals') exec(execstr)
2, sue 3, newset_Robert');DROP TABLE names;-- 4, newset_joe 5, newset_rob 6, Robert');DROP TABLE names;-- 7, joe 8, rob '''.strip() csv_test = db.get_table_csv('names') print('test=') print(csv_test) try: assert csv_test.endswith(csv_target) except AssertionError as ex: print('target=') print(csv_target) utool.printex(ex) raise return locals() if __name__ == '__main__': import multiprocessing multiprocessing.freeze_support() # For windows test_locals = utool.run_test(TEST_SQL_CONTROL) execstr = utool.execstr_dict(test_locals, 'test_locals') exec(execstr)
from itertools import izip TEST_MODEL_URL = 'https://dl.dropbox.com/s/mbqovlwsk2j1tws/.learned_model.pickle' TEST_IMAGES_URL = 'https://dl.dropboxusercontent.com/s/of2s82ed4xf86m6/testdata.zip' def test_pygist(): print('[pygist] Testing pygist') # Ensure you have test data print('[pygist] Ensuring testdata') datafile = utool.grab_file_url(TEST_MODEL_URL, appname='utool') test_image_dir = utool.grab_zipped_url(TEST_IMAGES_URL, appname='utool') imgpaths = utool.list_images(test_image_dir, fullpath=True) # test image paths outdir = utool.get_app_resource_dir('pygist') # where to put results # Run pygist on test images print('[pygist] Running tests') test_results = pygist.test(imgpaths, outdir=outdir, datafile=datafile) # Print results target_results = [-1, -1, 1, -1, 1, -1, -1, -1, 1, 1, -1, 1, 1] assert target_results == target_results, 'results do not match' print('test_results = %r' % (test_results, )) print(utool.list_str(list(izip(imgpaths, test_results)))) return locals() if __name__ == '__main__': test_locals = utool.run_test(test_pygist) exec(utool.execstr_dict(test_locals, 'test_locals')) exec(utool.ipython_execstr())
assert alrids_list, 'alrids_list is empty' alrid_list = utool.flatten(alrids_list) orig_confidences = ibs.get_alr_confidence(alrid_list) new_confidences = list(range(len(alrid_list))) #ibs.print_alr_table() ibs.set_alr_confidence(alrid_list, new_confidences) #ibs.print_alr_table() new_confidences2 = ibs.get_alr_confidence(alrid_list) assert new_confidences == new_confidences2, 'new_confidences == new_confidences2 failed' ibs.set_alr_confidence(alrid_list, orig_confidences) assert orig_confidences == ibs.get_alr_confidence( alrid_list), 'alr confidences were not reset' """ test metadata """ #ibs.print_tables() #ibs.print_lblannot_table() #ibs.print_alr_table() return locals() if __name__ == '__main__': import multiprocessing multiprocessing.freeze_support() # For win32 import ibeis # Initialize database main_locals = ibeis.main(defaultdb='testdb1', gui=False) ibs = main_locals['ibs'] test_locals = utool.run_test(TEST_IBS_CONTROL, ibs) #execstr = utool.execstr_dict(test_locals, 'test_locals') #exec(execstr)
aid_list = ibs.add_annots(gids[0:1], bbox_list=bbox_list) vert_list = ibs.get_annot_verts(aid_list) bbox_list_new = geometry.bboxes_from_vert_list(vert_list) assert bbox_list_new == bbox_list, 'Original bbox does not match the returned one' bbox_list = [(0, 0, 100, 100)] aid_list = ibs.add_annots(gids[1:2], bbox_list=bbox_list) vert_list = ibs.get_annot_verts(aid_list) vert_list_new = geometry.verts_list_from_bboxes_list(bbox_list) assert vert_list_new == vert_list, 'Vertices and their bounding box do not match' vert_list = [((0, 50), (50, 100), (100, 50), (50, 0))] aid_list = ibs.add_annots(gids[2:3], vert_list=vert_list) bbox_list = ibs.get_annot_bboxes(aid_list) bbox_list_new = geometry.bboxes_from_vert_list(vert_list) assert bbox_list_new == bbox_list, 'Original bbox does not match the returned one' return locals() if __name__ == '__main__': multiprocessing.freeze_support() # For win32 import ibeis main_locals = ibeis.main(defaultdb='testdb0', gui=False, allow_newdir=False, delete_ibsdir=False) ibs = main_locals['ibs'] # IBEIS Control test_locals = utool.run_test(TEST_CONVERT_BBOX_POLY, ibs) #execstr = utool.execstr_dict(test_locals, 'test_locals') #execstr += '\n' + utool.ipython_execstr() #exec(execstr)
bbox_list_new = geometry.bboxes_from_vert_list(vert_list) assert bbox_list_new == bbox_list, 'Original bbox does not match the returned one' bbox_list = [(0, 0, 100, 100)] aid_list = ibs.add_annots(gids[1:2], bbox_list=bbox_list) vert_list = ibs.get_annot_verts(aid_list) vert_list_new = geometry.verts_list_from_bboxes_list(bbox_list) assert vert_list_new == vert_list, 'Vertices and their bounding box do not match' vert_list = [((0, 50), (50, 100), (100, 50), (50, 0))] aid_list = ibs.add_annots(gids[2:3], vert_list=vert_list) bbox_list = ibs.get_annot_bboxes(aid_list) bbox_list_new = geometry.bboxes_from_vert_list(vert_list) assert bbox_list_new == bbox_list, 'Original bbox does not match the returned one' return locals() if __name__ == '__main__': multiprocessing.freeze_support() # For win32 import ibeis main_locals = ibeis.main(defaultdb='testdb0', gui=False, allow_newdir=False, delete_ibsdir=False) ibs = main_locals['ibs'] # IBEIS Control test_locals = utool.run_test(TEST_CONVERT_BBOX_POLY, ibs) #execstr = utool.execstr_dict(test_locals, 'test_locals') #execstr += '\n' + utool.ipython_execstr() #exec(execstr)
#!/usr/bin/env python2.7 # TODO: ADD COPYRIGHT TAG from __future__ import absolute_import, division, print_function import multiprocessing import utool # IBEIST from ibeis.model.preproc import preproc_feat print, print_, printDBG, rrr, profile = utool.inject(__name__, '[TEST_COMPUTE_FEATS]') def TEST_COMPUTE_FEATS(ibs): # Create a HotSpotter API (hs) and GUI backend (back) print('get_valid_ANNOTATIONS') aid_list = ibs.get_valid_aids() cid_list = ibs.add_chips(aid_list) assert len(cid_list) > 0, 'database chips cannot be empty for TEST_COMPUTE_FEATS' print(' * len(cid_list) = %r' % len(cid_list)) feat_list = list(preproc_feat.add_feat_params_gen(ibs, cid_list)) return locals() if __name__ == '__main__': multiprocessing.freeze_support() # For windows import ibeis main_locals = ibeis.main(defaultdb='testdb0', gui=False) ibs = main_locals['ibs'] # IBEIS Control test_locals = utool.run_test(TEST_COMPUTE_FEATS, ibs) execstr = utool.execstr_dict(test_locals, 'test_locals') exec(execstr)
# test that uuids are the same after running localize images ibs.localize_images() gpath_list = ibs.get_image_paths(gid_list) assert gid_list, 'get_valid_gids returned empty' assert gpath_list, 'get_image_paths returned empty' print('[gpath_list = %r' % (gpath_list,)) uuids_new = [utool.get_file_uuid(gpath) for gpath in gpath_list] assert uuids_old, 'get_file_uuid returned empty' assert uuids_new, 'get_image_uuids returned empty' print('uuids_old = %r' % (uuids_old,)) print('uuids_new = %r' % (uuids_new,)) assert uuids_old == uuids_new, 'regenerated uuids are not the same as the originals' return locals() if __name__ == '__main__': multiprocessing.freeze_support() # For windows import ibeis main_locals = ibeis.main(defaultdb='testdb1', gui=False) ibs = main_locals['ibs'] test_locals = utool.run_test(TEST_LOCALIZE_IMAGES, ibs) execstr = utool.execstr_dict(test_locals, 'test_locals') exec(execstr) exec(utool.ipython_execstr())
def benchmark_L2_dist(): setup = utool.unindent( """ hist1 = np.random.rand(100, 128).astype(np.float64) hist2 = np.random.rand(100, 128).astype(np.float64) """ ) func_list = ["vtool.linalg.L2_sqrd", "vtool.linalg.L2_sqrd_cython"] argstr = "(hist1, hist2)" return _run_benchmark(setup, func_list, argstr) if __name__ == "__main__": try: from vtool import linalg_cython # NOQA print("[vtool] cython is on") except ImportError as ex: utool.printex(ex, iswarning=True) print("[vtool] cython is off") # raise # from vtool import linalg test_locals1, error_report1 = utool.run_test(test_L2_sqrd) test_locals2, error_report2 = utool.run_test(test_invVR_sqrd_scale) test_locals3, error_report3 = utool.run_test(test_det_dist) benchmark_L2_dist() benchmark_invVR_sqrd_scale() benchmark_det_dist() # execstr = utool.execstr_dict(test_linalg, 'test_locals') # exec(execstr)
aid_list = ibs.add_annots(gid_list, bbox_list=bbox_list, name_list=name_list) assert len(aid_list) != 0, "No annotations" aid = aid_list[0] gid = ibs.get_annot_gids(aid) assert gid is not None, "gid for aid=%r is None" % (aid, ) gthumbpath = ibs.get_image_thumbpath(gid) annotation_thumbpath = ibs.get_annot_chip_thumbpath(aid) ibs.delete_annot_chips(aid) aid_list = ibs.get_valid_aids() assert aid in aid_list, "Error: Annotation deleted" assert not utool.checkpath(gthumbpath), "Image Thumbnail not deleted" assert not utool.checkpath( annotation_thumbpath), "Roi Thumbnail not deleted" return locals() if __name__ == '__main__': multiprocessing.freeze_support() # For windows import ibeis main_locals = ibeis.main(defaultdb='testdb_empty', gui=False, allow_newdir=True, delete_ibsdir=True) ibs = main_locals['ibs'] # IBEIS Control back = main_locals['back'] # IBEIS GUI backend test_locals = utool.run_test(TEST_DELETE_ANNOTATION_CHIPS, ibs, back) exec(utool.execstr_dict(test_locals, 'test_locals')) exec(utool.ipython_execstr())
gpath_list = grabdata.get_test_gpaths(ndata=None)[0:4] gid_list = ibs.add_images(gpath_list) bbox_list = [(0, 0, 100, 100)] * len(gid_list) name_list = ['a', 'b', 'a', 'd'] aid_list = ibs.add_annots(gid_list, bbox_list=bbox_list, name_list=name_list) cid_list = ibs.add_annot_chips(aid_list) assert len(cid_list) != 0, "No chips added" fid_list = ibs.add_chip_feat(cid_list) assert len(fid_list) != 0, "No features added" fid = fid_list[0] ibs.delete_features(fid) fid_list = ibs.get_valid_fids() assert fid not in fid_list, "FID not deleted" return locals() if __name__ == '__main__': multiprocessing.freeze_support() # For windows import ibeis main_locals = ibeis.main(defaultdb='testdb_empty', gui=False, allow_newdir=True, delete_ibsdir=True) ibs = main_locals['ibs'] # IBEIS Control back = main_locals['back'] # IBEIS GUI backend test_locals = utool.run_test(TEST_DELETE_FEATURE, ibs, back) exec(utool.execstr_dict(test_locals, 'test_locals')) exec(utool.ipython_execstr())
augmented_uuid_T3 = utool.augment_uuid(uuid_, hashable_data2, hashable_data1) augmented_uuid_T4 = utool.augment_uuid(uuid_, hashable_data1, hashable_data2) augmented_uuid_T5 = utool.augment_uuid(uuid_, [1, 2, 3]) augmented_uuid_T5 = utool.augment_uuid(uuid_, (1, 2, 3)) augmented_uuid_T6 = utool.augment_uuid(uuid_, np.array((1, 2, 3))) print('augmented_uuid_T1=%r' % (augmented_uuid_T1, )) print('augmented_uuid_T2=%r' % (augmented_uuid_T2, )) print('augmented_uuid_T3=%r' % (augmented_uuid_T3, )) print('augmented_uuid_T4=%r' % (augmented_uuid_T4, )) print('augmented_uuid_T5=%r' % (augmented_uuid_T5, )) print('augmented_uuid_T6=%r' % (augmented_uuid_T6, )) def test_byteslike(): text = lorium_text[0:11] print('type(text) = %r' % type(text)) data = text.encode('utf-8') print('type(data) = %r' % type(data)) memview = memoryview(data) print('type(memview) = %r, memview=%r' % (type(memview), memview)) if __name__ == '__main__': test_byteslike() utool.run_test(test_augment_uuid) import sys print(sys.executable)
# Sample keypoints kpts = get_test_kpts(ibs, 11) img = dummy.get_kpts_dummy_img(kpts, sf=1.2) # Matching keypoints kpts1 = dummy.perterb_kpts(kpts, ori_std=np.tau / 6, damping=4) kpts2 = dummy.perterb_kpts(kpts, ori_std=np.tau / 6, damping=4) # Keypoint images img1 = dummy.get_kpts_dummy_img(kpts1, sf=1.2) img2 = dummy.get_kpts_dummy_img(kpts2, sf=1.2) # Matching indexes fx1_m = np.arange(len(kpts1)) fx2_m = np.arange(len(kpts1)) fm = np.vstack((fx1_m, fx2_m)).T # WRITE SPATIAL VERIFICATION DATA #sv_reprs = utool.get_reprs('kpts1', 'kpts2', 'fm') #sys.stdout.write(sv_reprs) #sys.stdout.write('\n') return locals() if __name__ == '__main__': multiprocessing.freeze_support() # For windows import ibeis main_locals = ibeis.main(defaultdb='testdb1', gui=False) ibs = main_locals['ibs'] test_locals = utool.run_test(SAMPLE_DATA, ibs) execstr = utool.execstr_dict(test_locals, 'test_locals') exec(execstr)
for bbox in bboxes: gid_list2.append(gid) bbox_list2.append(bbox) # not using confidence nor img_conf here if SPECIAL: from plottool import viz_image2, fig_presenter #from plottool import draw_func2 as df2 for gid in gid_list: isthisgid = [gid == gid2 for gid2 in gid_list2] bbox_list = utool.filter_items(bbox_list2, isthisgid) img = ibs.get_images(gid) fig = viz_image2.show_image(img, bbox_list=bbox_list) fig_presenter.present() #fig_presenter.all_figures_bring_to_front() #ibs.detect_random_forest(gid_list, 'zebra_grevys') return locals() if __name__ == '__main__': multiprocessing.freeze_support() # For windows main_locals = ibeis.main(defaultdb='testdb1', gui=False) ibs = main_locals['ibs'] # IBEIS Control test_locals = utool.run_test(TEST_DETECT, ibs) execstr = utool.execstr_dict(test_locals, 'test_locals') exec(execstr) if SPECIAL: from plottool import df2 df2.present() raw_input()
print('[TEST] read from sql database') tt = utool.tic() db.cur.execute('SELECT temp_hash FROM temp', []) print(' * execute select time=%r sec' % utool.toc(tt)) tt = utool.tic() result_list = _results_gen(db.cur) print(' * iter results time=%r sec' % utool.toc(tt)) print(' * memory(result_list) = %s' % utool.byte_str2(utool.get_object_size(result_list))) del result_list #print('[TEST] result_list=%r' % result_list) print('[TEST] dump sql database') tt = utool.tic() db.dump('temp.dump.txt') print(' * dump time=%r sec' % utool.toc(tt)) #with open('temp.dump.txt') as file_: # print(file_.read()) return locals() if __name__ == '__main__': import multiprocessing multiprocessing.freeze_support() # For win32 test_locals = utool.run_test(TEST_SQL_NUMPY) execstr = utool.execstr_dict(test_locals, 'test_locals') exec(execstr)
augmented_uuid_T1 = utool.augment_uuid(uuid_, hashable_data1) augmented_uuid_T2 = utool.augment_uuid(uuid_, hashable_data2) augmented_uuid_T3 = utool.augment_uuid(uuid_, hashable_data2, hashable_data1) augmented_uuid_T4 = utool.augment_uuid(uuid_, hashable_data1, hashable_data2) augmented_uuid_T5 = utool.augment_uuid(uuid_, [1, 2, 3]) augmented_uuid_T5 = utool.augment_uuid(uuid_, (1, 2, 3)) augmented_uuid_T6 = utool.augment_uuid(uuid_, np.array((1, 2, 3))) print('augmented_uuid_T1=%r' % (augmented_uuid_T1,)) print('augmented_uuid_T2=%r' % (augmented_uuid_T2,)) print('augmented_uuid_T3=%r' % (augmented_uuid_T3,)) print('augmented_uuid_T4=%r' % (augmented_uuid_T4,)) print('augmented_uuid_T5=%r' % (augmented_uuid_T5,)) print('augmented_uuid_T6=%r' % (augmented_uuid_T6,)) def test_byteslike(): text = lorium_text[0:11] print('type(text) = %r' % type(text)) data = text.encode('utf-8') print('type(data) = %r' % type(data)) memview = memoryview(data) print('type(memview) = %r, memview=%r' % (type(memview), memview)) if __name__ == '__main__': test_byteslike() utool.run_test(test_augment_uuid) import sys print(sys.executable)
assert coltype_list_ == coltype_list__, 'Actual values: %r ' % coltype_list_ ##################### # Drop column ##################### drop_column(db) # Verify table's schema colname_list = db.get_column_names('test3') coltype_list = db.get_column_types('test3') assert colname_list == ['test_rowid', 'test_text', 'test_integer'], 'Actual values: %r ' % colname_list assert coltype_list == [u'INTEGER PRIMARY KEY', u'TEXT NOT NULL', u'TEXT'], 'Actual values: %r ' % coltype_list ##################### # Drop table ##################### drop_table(db) tablename_list = db.get_table_names() assert tablename_list == ['metadata', 'test'], 'Actual values: %r ' % tablename_list return locals() if __name__ == '__main__': import multiprocessing multiprocessing.freeze_support() # For windows test_locals = utool.run_test(TEST_SQL_MODIFY) execstr = utool.execstr_dict(test_locals, 'test_locals') exec(execstr)
#img_fname = split(img_fpath)[1] #dst_fpath = join(detect_path, img_fname) #print(' * img_fpath = %r' % img_fpath) #print(' * dst_fpath = %r' % dst_fpath) with utool.Timer('[test_pyrf] detector.detect ix=%r' % (ix,)): results = detector.detect(forest, img_fpath, dst_fpath) results_list1.append(results) print('num results = %r' % len(results)) else: print('...skipped') # with utool.Timer('[test_pyrf] detector.detect_many') as t2: # results_list2 = detector.detect_many(forest, std_gpath_list, # dst_gpath_list, use_openmp=True) print('') print('+ --------------') print('| total time1: %r' % t1.ellapsed) # print('| total time2: %r' % t2.ellapsed) print('|') print('| num results1 = %r' % (list(map(len, results_list1)))) # print('| num results2 = %r' % (list(map(len, results_list2)))) #assert results_list2 == results_list1 return locals() if __name__ == '__main__': test_locals = utool.run_test(test_pyrf) exec(utool.execstr_dict(test_locals, 'test_locals')) exec(utool.ipython_execstr())
#!/usr/bin/env python2.7 # TODO: ADD COPYRIGHT TAG from __future__ import absolute_import, division, print_function import multiprocessing import utool from vtool.tests import grabdata from ibeis.model.preproc import preproc_image from PIL import Image print, print_, printDBG, rrr, profile = utool.inject(__name__, '[TEST_PIL_HASH]') def TEST_PIL_HASH(): print('[TEST] GET_TEST_IMAGE_PATHS') # The test api returns a list of interesting chip indexes gpath_list = grabdata.get_test_gpaths(ndata=None) pil_img_list = [Image.open(gpath, 'r') for gpath in gpath_list] uuid_list = [preproc_image.get_image_uuid(pil_img) for pil_img in pil_img_list] unique_uuid_list = list(set(uuid_list)) assert len(uuid_list) == len(unique_uuid_list), 'Reinstall PIL, watch for libjpeg' return locals() if __name__ == '__main__': multiprocessing.freeze_support() # For win32 test_locals = utool.run_test(TEST_PIL_HASH) execstr = utool.execstr_dict(test_locals, 'test_locals') exec(execstr)
theta_list = ibs.get_annot_thetas(aid_list) aids_list = ibs.get_image_aids(gid) print(' * gid_list=%r' % gid_list) print(' * bbox_list=%r' % bbox_list) print(' * theta_list=%r' % theta_list) print(' * aids_list=%r' % aids_list) assert len(bbox_list) == len(theta_list), "len(bbox_list) != len(theta_list)" assert len(theta_list) == len(aid_list), "len(theta_list) != len(aid_list)" viz.show_image(ibs, gid) return locals() if __name__ == '__main__': import multiprocessing multiprocessing.freeze_support() # For win32 import ibeis # Initialize database try: main_locals = ibeis.main(defaultdb='testdb0', gui=False) ibs = main_locals['ibs'] test_locals = utool.run_test(TEST_IBS, ibs) except RuntimeError as ex: utool.printex(ex) import matplotlib as mpl backend = mpl.get_backend() print('[test] current backend is: %r' % backend) raise execstr = utool.execstr_dict(test_locals, 'test_locals') exec(execstr)
) ''' cur.execute(operation, []) connection.commit() status = [] for trans in [True, False]: status.append(test_query(connection, cur, 'UPDATE', alter_update, isolation_level, transaction=trans)) status.append(test_query(connection, cur, 'UPDATE', alter_update, isolation_level, transaction=trans, commit=True)) status.append(test_query(connection, cur, 'DELETE', alter_delete, isolation_level, transaction=trans)) status.append(test_query(connection, cur, 'DELETE', alter_delete, isolation_level, transaction=trans, commit=True)) status.append(test_query(connection, cur, 'INSERT', alter_insert, isolation_level, transaction=trans)) status.append(test_query(connection, cur, 'INSERT', alter_insert, isolation_level, transaction=trans, commit=True)) if not all(status): raise Exception("Tests failed for %r" % (isolation_level)) # This will never happen unless SQLite 3 freaks out return locals() if __name__ == '__main__': import multiprocessing multiprocessing.freeze_support() # For windows test_locals = utool.run_test(TEST_SQL_REVERT) test_locals = utool.run_test(TEST_SQL_REVERT, isolation_level='DEFERRED') test_locals = utool.run_test(TEST_SQL_REVERT, isolation_level='IMMEDIATE') test_locals = utool.run_test(TEST_SQL_REVERT, isolation_level='EXCLUSIVE') execstr = utool.execstr_dict(test_locals, 'test_locals') exec(execstr)
if num_procs is not None: util_parallel.close_pool() util_parallel.init_pool(num_procs) else: num_procs = util_parallel.get_default_numprocs() msg = 'processing tasks in %s' % ('serial' if num_procs == 1 else str(num_procs) + '-parallel') with utool.Timer(msg): result_list = util_parallel.process(pyhesaff.detect_feats, args_list, hesaff_kwargs) print_test_results(result_list) return result_list run_parallel_task() # Compare to serial if needed @utool.argv_flag_dec def compare_serial(): print('compare_serial') run_parallel_task(1) compare_serial() return locals() if __name__ == '__main__': multiprocessing.freeze_support() # for win32 test_locals = utool.run_test(TEST_PARALLEL) execstr = utool.execstr_dict(test_locals, 'test_locals') exec(execstr)
cid = ibs.get_annot_cids(aid, ensure=True) fid = ibs.get_annot_fids(aid, ensure=True) assert cid is not None, "cid should be computed" assert fid is not None, "fid should be computed" gthumbpath = ibs.get_image_thumbpath(gid) athumbpath = ibs.get_annot_chip_thumbpath(aid) ibs.delete_images(gid) all_gids = ibs.get_valid_gids() all_aids = ibs.get_valid_aids() all_cids = ibs.get_valid_cids() all_fids = ibs.get_valid_fids() assert gid not in all_gids, "gid still exists" assert aid not in all_aids, "rid %r still exists" % aid assert fid not in all_fids, "fid %r still exists" % fid assert cid not in all_cids, "cid %r still exists" % cid assert not utool.checkpath(gthumbpath), "Thumbnail still exists" assert not utool.checkpath(athumbpath), "ANNOTATION Thumbnail still exists" return locals() if __name__ == '__main__': multiprocessing.freeze_support() # For windows import ibeis main_locals = ibeis.main(defaultdb='testdb_empty', gui=False, allow_newdir=True, delete_ibsdir=True) ibs = main_locals['ibs'] # IBEIS Control back = main_locals['back'] # IBEIS GUI backend test_locals = utool.run_test(TEST_DELETE_IMAGE, ibs, back) exec(utool.execstr_dict(test_locals, 'test_locals')) exec(utool.ipython_execstr())
def benchmark_L2_dist(): setup = utool.unindent(''' hist1 = np.random.rand(100, 128).astype(np.float64) hist2 = np.random.rand(100, 128).astype(np.float64) ''') func_list = [ 'vtool.linalg.L2_sqrd', 'vtool.linalg.L2_sqrd_cython', ] argstr = '(hist1, hist2)' return _run_benchmark(setup, func_list, argstr) if __name__ == '__main__': try: from vtool import linalg_cython # NOQA print('[vtool] cython is on') except ImportError as ex: utool.printex(ex, iswarning=True) print('[vtool] cython is off') # raise #from vtool import linalg test_locals1, error_report1 = utool.run_test(test_L2_sqrd) test_locals2, error_report2 = utool.run_test(test_invVR_sqrd_scale) test_locals3, error_report3 = utool.run_test(test_det_dist) benchmark_L2_dist() benchmark_invVR_sqrd_scale() benchmark_det_dist() #execstr = utool.execstr_dict(test_linalg, 'test_locals') #exec(execstr)
#!/usr/bin/env python2.7 # TODO: ADD COPYRIGHT TAG from __future__ import absolute_import, division, print_function import multiprocessing import utool print, print_, printDBG, rrr, profile = utool.inject(__name__, '[TEST_DELETE_ENC]') def TEST_DELETE_ENC(ibs, back): from ibeis.dev import ibsfuncs ibsfuncs.update_all_image_encounter(ibs) eid_list = ibs.get_valid_eids() assert len(eid_list) != 0, "All Image encounter not created" eid = eid_list[0] ibs.delete_encounters(eid) eid_list = ibs.get_valid_eids() assert eid not in eid_list, "eid=%r still exists" % (eid,) return locals() if __name__ == '__main__': multiprocessing.freeze_support() # For windows import ibeis main_locals = ibeis.main(defaultdb='testdb1', gui=False) ibs = main_locals['ibs'] # IBEIS Control back = main_locals['back'] # IBEIS GUI backend test_locals = utool.run_test(TEST_DELETE_ENC, ibs, back) exec(utool.execstr_dict(test_locals, 'test_locals')) exec(utool.ipython_execstr())
aid2 = top_aids[0] fnum = df2.next_fnum() df2.figure(fnum=fnum, doclf=True) qres.ishow_top(ibs, fnum=fnum, top_aids=top_aids, ensure=False, annot_mode=1) df2.set_figtitle('Query Result') df2.adjust_subplots_safe(top=.8) return locals() if __name__ == '__main__': """ CommandLine: python -m ibeis.tests.test_ibs_query python -m ibeis.tests.test_ibs_query --allexamples python -m ibeis.tests.test_ibs_query --allexamples --noface --nosrc """ import multiprocessing multiprocessing.freeze_support() # for win32 import utool as ut # NOQA nPass, nTotal, failed_cmd_list = ut.doctest_funcs() if nTotal == 0: # OLD MAIN multiprocessing.freeze_support() # For windows import ibeis main_locals = ibeis.main(defaultdb='testdb1', gui=False) ibs = main_locals['ibs'] test_locals = utool.run_test(TEST_QUERY, ibs) execstr = utool.execstr_dict(test_locals, 'test_locals') exec(execstr) exec(utool.ipython_execstr())