本文整理汇总了Python中utool.dict_str函数的典型用法代码示例。如果您正苦于以下问题:Python dict_str函数的具体用法?Python dict_str怎么用?Python dict_str使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了dict_str函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。
示例1: hack
def hack(ibs):
#ibs.get_imageset_text(imgsetid_list)
#imgsetid = ibs.get_imageset_imgsetids_from_text("NNP GZC Car '1PURPLE'")
def get_name_linked_imagesets_by_imgsetid(ibs, imgsetid):
import utool as ut
#gid_list = ibs.get_imageset_gids(imgsetid)
aid_list_ = ibs.get_imageset_aids(imgsetid)
aid_list = ut.filterfalse_items(aid_list_, ibs.is_aid_unknown(aid_list_))
#all(ibs.db.check_rowid_exists(const.ANNOTATION_TABLE, aid_list))
#aids_list2 = ibs.get_image_aids(gid_list)
#assert ut.flatten(aids_list2) == aids_list1
nid_list = list(set(ibs.get_annot_nids(aid_list, distinguish_unknowns=False)))
# remove unknown annots
name_imgsetids = ibs.get_name_imgsetids(nid_list)
name_imagesettexts = ibs.get_imageset_text(name_imgsetids)
return name_imagesettexts
imgsetid_list = ibs.get_valid_imgsetids()
linked_imagesettexts = [get_name_linked_imagesets_by_imgsetid(ibs, imgsetid) for imgsetid in imgsetid_list]
imagesettext_list = ibs.get_imageset_text(imgsetid_list)
print(ut.dict_str(dict(zip(imgsetid_list, linked_imagesettexts))))
print(ut.align(ut.dict_str(dict(zip(imagesettext_list, linked_imagesettexts))), ':'))
print(ut.align(ut.dict_str(dict(zip(imagesettext_list, imgsetid_list)), sorted_=True), ':'))
开发者ID:Erotemic,项目名称:ibeis,代码行数:25,代码来源:_grave_dev.py
示例2: api_remote_ibeis
def api_remote_ibeis(remote_ibeis_url, remote_api_func, remote_ibeis_port=5001,
**kwargs):
import requests
if GLOBAL_APP_ENABLED and GLOBAL_APP is None:
raise ValueError('Flask has not been initialized')
api_name = remote_api_func.__name__
route_list = list(GLOBAL_APP.url_map.iter_rules(api_name))
assert len(route_list) == 1, 'More than one route resolved'
route = route_list[0]
api_route = route.rule
assert api_route.startswith('/api/'), 'Must be an API route'
method_list = sorted(list(route.methods - set(['HEAD', 'OPTIONS'])))
remote_api_method = method_list[0].upper()
assert api_route is not None, 'Route could not be found'
args = (remote_ibeis_url, remote_ibeis_port, api_route)
remote_api_url = 'http://%s:%s%s' % args
headers = {
'Authorization': get_url_authorization(remote_api_url)
}
for key in kwargs.keys():
value = kwargs[key]
if isinstance(value, (tuple, list, set)):
value = str(list(value))
kwargs[key] = value
print('[REMOTE] %s' % ('-' * 80, ))
print('[REMOTE] Calling remote IBEIS API: %r' % (remote_api_url, ))
print('[REMOTE] \tMethod: %r' % (remote_api_method, ))
print('[REMOTE] \tHeaders: %s' % (ut.dict_str(headers), ))
print('[REMOTE] \tKWArgs: %s' % (ut.dict_str(kwargs), ))
# Make request to server
try:
if remote_api_method == 'GET':
req = requests.get(remote_api_url, headers=headers, data=kwargs,
verify=False)
elif remote_api_method == 'POST':
req = requests.post(remote_api_url, headers=headers, data=kwargs,
verify=False)
elif remote_api_method == 'PUT':
req = requests.put(remote_api_url, headers=headers, data=kwargs,
verify=False)
elif remote_api_method == 'DELETE':
req = requests.delete(remote_api_url, headers=headers, data=kwargs,
verify=False)
else:
message = '_api_result got unsupported method=%r' % (remote_api_method, )
raise KeyError(message)
except requests.exceptions.ConnectionError as ex:
message = '_api_result could not connect to server %s' % (ex, )
raise IOError(message)
response = req.text
converted = ut.from_json(value)
response = converted.get('response', None)
print('response = %s' % (response,))
return response
开发者ID:heroinlin,项目名称:ibeis,代码行数:59,代码来源:controller_inject.py
示例3: dictinfo
def dictinfo(dict_):
if not isinstance(dict_, dict):
return 'expected dict got %r' % type(dict_)
keys = list(dict_.keys())
vals = list(dict_.values())
num_keys = len(keys)
key_types = list(set(map(type, keys)))
val_types = list(set(map(type, vals)))
fmtstr_ = '\n' + ut.unindent('''
* num_keys = {num_keys}
* key_types = {key_types}
* val_types = {val_types}
'''.strip('\n'))
if len(val_types) == 1:
if val_types[0] == np.ndarray:
# each key holds an ndarray
val_shape_stats = ut.get_stats(set(map(np.shape, vals)), axis=0)
val_shape_stats_str = ut.dict_str(val_shape_stats, strvals=True, newlines=False)
val_dtypes = list(set([val.dtype for val in vals]))
fmtstr_ += ut.unindent('''
* val_shape_stats = {val_shape_stats_str}
* val_dtypes = {val_dtypes}
'''.strip('\n'))
elif val_types[0] == list:
# each key holds a list
val_len_stats = ut.get_stats(set(map(len, vals)))
val_len_stats_str = ut.dict_str(val_len_stats, strvals=True, newlines=False)
depth = ut.list_depth(vals)
deep_val_types = list(set(ut.list_deep_types(vals)))
fmtstr_ += ut.unindent('''
* list_depth = {depth}
* val_len_stats = {val_len_stats_str}
* deep_types = {deep_val_types}
'''.strip('\n'))
if len(deep_val_types) == 1:
if deep_val_types[0] == np.ndarray:
deep_val_dtypes = list(set([val.dtype for val in vals]))
fmtstr_ += ut.unindent('''
* deep_val_dtypes = {deep_val_dtypes}
''').strip('\n')
elif val_types[0] in [np.uint8, np.int8, np.int32, np.int64, np.float16, np.float32, np.float64]:
# each key holds a scalar
val_stats = ut.get_stats(vals)
fmtstr_ += ut.unindent('''
* val_stats = {val_stats}
''').strip('\n')
fmtstr = fmtstr_.format(**locals())
return ut.indent(fmtstr)
开发者ID:Erotemic,项目名称:ibeis,代码行数:52,代码来源:smk_debug.py
示例4: get_inspect_str
def get_inspect_str(qres):
assert_qres(qres)
nFeatMatch_list = get_num_feats_in_matches(qres)
nFeatMatch_stats = utool.mystats(nFeatMatch_list)
top_lbl = utool.unindent('''
top aids
scores
ranks''').strip()
top_aids = qres.get_top_aids(num=5)
top_scores = qres.get_aid_scores(top_aids)
top_ranks = qres.get_aid_ranks(top_aids)
top_stack = np.vstack((top_aids, top_scores, top_ranks))
top_stack = np.array(top_stack, dtype=np.int32)
top_str = str(top_stack)
inspect_str = '\n'.join([
'QueryResult',
'qaid=%r ' % qres.qaid,
utool.horiz_string(top_lbl, ' ', top_str),
'num Feat Matches stats:',
utool.indent(utool.dict_str(nFeatMatch_stats)),
])
inspect_str = utool.indent(inspect_str, '[INSPECT] ')
return inspect_str
开发者ID:byteyoo,项目名称:ibeis,代码行数:27,代码来源:hots_query_result.py
示例5: testdata_ibeis
def testdata_ibeis(**kwargs):
"""
DEPRICATE
Step 1
builds ibs for testing
Example:
>>> from ibeis.algo.hots.smk.smk_debug import * # NOQA
>>> kwargs = {}
"""
print(' === Test Data IBEIS ===')
print('kwargs = ' + ut.dict_str(kwargs))
print('[smk_debug] testdata_ibeis')
db = kwargs.get('db', ut.get_argval('--db', str, 'PZ_MTEST'))
#with ut.Indenter('ENSURE'):
if db == 'PZ_MTEST':
ibeis.ensure_pz_mtest()
ibs = ibeis.opendb(db=db)
ibs._default_config()
aggregate = kwargs.get('aggregate', ut.get_argflag(('--agg', '--aggregate')))
nWords = kwargs.get( 'nWords', ut.get_argval(('--nWords', '--nCentroids'), int, default=8E3))
nAssign = kwargs.get( 'nAssign', ut.get_argval(('--nAssign', '--K'), int, default=10))
# Configs
ibs.cfg.query_cfg.pipeline_root = 'smk'
ibs.cfg.query_cfg.smk_cfg.aggregate = aggregate
ibs.cfg.query_cfg.smk_cfg.smk_alpha = 3
ibs.cfg.query_cfg.smk_cfg.smk_thresh = 0
ibs.cfg.query_cfg.smk_cfg.vocabtrain_cfg.nWords = nWords
ibs.cfg.query_cfg.smk_cfg.vocabassign_cfg.nAssign = nAssign
if ut.VERYVERBOSE:
ibs.cfg.query_cfg.smk_cfg.printme3()
return ibs
开发者ID:Erotemic,项目名称:ibeis,代码行数:33,代码来源:smk_debug.py
示例6: vector_normal_stats
def vector_normal_stats(vectors):
import numpy.linalg as npl
norm_list = npl.norm(vectors, axis=1)
#norm_list2 = np.sqrt((vectors ** 2).sum(axis=1))
#assert np.all(norm_list == norm_list2)
norm_stats = ut.get_stats(norm_list)
print('normal_stats:' + ut.dict_str(norm_stats, newlines=False))
开发者ID:Erotemic,项目名称:ibeis,代码行数:7,代码来源:smk_debug.py
示例7: figure_clicked
def figure_clicked(self, event=None):
from ibeis.viz import viz_helpers as vh
ax = event.inaxes
if ih.clicked_inside_axis(event):
viztype = vh.get_ibsdat(ax, 'viztype')
if viztype == 'chip':
aid = vh.get_ibsdat(ax, 'aid')
print('... aid=%r' % aid)
if event.button == 3: # right-click
from ibeis.viz.interact import interact_chip
import guitool
height = self.fig.canvas.geometry().height()
qpoint = guitool.newQPoint(event.x, height - event.y)
if self.qreq_ is None:
config2_ = None
else:
if aid in self.qreq_.qaids:
config2_ = self.qreq_.query_config2_
else:
config2_ = self.qreq_.data_config2_
callback_list = interact_chip.build_annot_context_options(
self.ibs, aid, refresh_func=self.show_page, config2_=config2_)
guitool.popup_menu(self.fig.canvas, qpoint, callback_list)
#interact_chip.show_annot_context_menu(
# self.ibs, aid, self.fig.canvas, qpoint, refresh_func=self.show_page)
#self.show_page()
#ibs.print_annotation_table()
print(ut.dict_str(event.__dict__))
开发者ID:Erotemic,项目名称:ibeis,代码行数:28,代码来源:interact_query_decision.py
示例8: general_annot_coverage_mask_generator
def general_annot_coverage_mask_generator(make_mask_func, qreq_, cm, config, cov_cfg):
"""
Yeilds:
daid, weight_mask_m, weight_mask
CommandLine:
python -m ibeis.algo.hots.scoring --test-general_annot_coverage_mask_generator --show
python -m ibeis.algo.hots.scoring --test-general_annot_coverage_mask_generator --show --qaid 18
Note:
Evaluate output one at a time or it will get clobbered
Example0:
>>> # SLOW_DOCTEST
>>> # (IMPORTANT)
>>> from ibeis.algo.hots.scoring import * # NOQA
>>> qreq_, cm = plh.testdata_scoring('PZ_MTEST', qaid_list=[18])
>>> config = qreq_.qparams
>>> make_mask_func, cov_cfg = get_mask_func(config)
>>> masks_iter = general_annot_coverage_mask_generator(make_mask_func, qreq_, cm, config, cov_cfg)
>>> daid_list, score_list, masks_list = evaluate_masks_iter(masks_iter)
>>> #assert daid_list[idx] ==
>>> ut.quit_if_noshow()
>>> idx = score_list.argmax()
>>> daids = [daid_list[idx]]
>>> daid, weight_mask_m, weight_mask = masks_list[idx]
>>> show_single_coverage_mask(qreq_, cm, weight_mask_m, weight_mask, daids)
>>> ut.show_if_requested()
"""
if ut.VERYVERBOSE:
print('[acov] make_mask_func = %r' % (make_mask_func,))
print('[acov] cov_cfg = %s' % (ut.dict_str(cov_cfg),))
return general_coverage_mask_generator(make_mask_func, qreq_, cm.qaid, cm.daid_list, cm.fm_list, cm.fs_list, config, cov_cfg)
开发者ID:Erotemic,项目名称:ibeis,代码行数:33,代码来源:scoring.py
示例9: preload_commands
def preload_commands(dbdir, **kwargs):
""" Preload commands work with command line arguments and global caches """
#print('[main_cmd] preload_commands')
if params.args.dump_argv:
print(utool.dict_str(vars(params.args)))
if params.args.dump_global_cache:
utool.global_cache_dump() # debug command, dumps to stdout
if params.args.workdir is not None:
sysres.set_workdir(params.args.workdir)
if params.args.logdir is not None:
sysres.set_logdir(params.args.logdir)
if utool.get_flag('--vwd'):
vwd()
if utool.get_flag('--vdq'):
print('got arg --vdq')
vdq(dbdir)
if kwargs.get('delete_ibsdir', False):
ibsfuncs.delete_ibeis_database(dbdir)
if params.args.convert:
preload_convert_hsdb(dbdir)
if params.args.merge_species is not None:
ibsfuncs.merge_species_databases(params.args.merge_species)
if params.args.preload_exit:
print('[main_cmd] preload exit')
sys.exit(1)
开发者ID:byteyoo,项目名称:ibeis,代码行数:25,代码来源:main_commands.py
示例10: _image_view
def _image_view(sel_aids=sel_aids, **_kwargs):
try:
viz.show_image(ibs, gid, sel_aids=sel_aids, fnum=self.fnum, **_kwargs)
df2.set_figtitle('Image View')
except TypeError as ex:
ut.printex(ex, ut.dict_str(_kwargs))
raise
开发者ID:Erotemic,项目名称:ibeis,代码行数:7,代码来源:interact_image.py
示例11: update_query_cfg
def update_query_cfg(query_cfg, **cfgdict):
# Each config paramater should be unique
# So updating them all should not cause conflicts
# FIXME: Should be able to infer all the children that need updates
#
# apply codename before updating subconfigs
query_cfg.apply_codename(cfgdict.get('codename', None))
# update subconfigs
query_cfg.nn_cfg.update(**cfgdict)
query_cfg.nnweight_cfg.update(**cfgdict)
query_cfg.sv_cfg.update(**cfgdict)
query_cfg.agg_cfg.update(**cfgdict)
query_cfg.flann_cfg.update(**cfgdict)
query_cfg.smk_cfg.update(**cfgdict)
query_cfg.smk_cfg.vocabassign_cfg.update(**cfgdict)
query_cfg.smk_cfg.vocabtrain_cfg.update(**cfgdict)
query_cfg.rrvsone_cfg.update(**cfgdict)
query_cfg._featweight_cfg.update(**cfgdict)
query_cfg._featweight_cfg._feat_cfg.update(**cfgdict)
query_cfg._featweight_cfg._feat_cfg._chip_cfg.update(**cfgdict)
query_cfg.update(**cfgdict)
# Ensure feasibility of the configuration
try:
query_cfg.make_feasible()
except AssertionError as ex:
print(ut.dict_str(cfgdict, sorted_=True))
ut.printex(ex)
raise
开发者ID:Erotemic,项目名称:ibeis,代码行数:28,代码来源:Config.py
示例12: load_gztest
def load_gztest(ibs):
r"""
CommandLine:
python -m ibeis.algo.hots.special_query --test-load_gztest
Example:
>>> # DISABLE_DOCTEST
>>> from ibeis.algo.hots.devcases import * # NOQA
>>> import ibeis
>>> ibs = ibeis.opendb('GZ_ALL')
"""
from os.path import join
from ibeis.algo.hots import match_chips4 as mc4
dir_ = ut.get_module_dir(mc4)
eval_text = ut.read_from(join(dir_, 'GZ_TESTTUP.txt'))
testcases = eval(eval_text)
count_dict = ut.count_dict_vals(testcases)
print(ut.dict_str(count_dict))
testtup_list = ut.flatten(ut.dict_take_list(testcases, ['vsone_wins',
'vsmany_outperformed',
'vsmany_dominates',
'vsmany_wins']))
qaid_list = [testtup.qaid_t for testtup in testtup_list]
visual_uuids = ibs.get_annot_visual_uuids(qaid_list)
visual_uuids
开发者ID:Erotemic,项目名称:ibeis,代码行数:26,代码来源:devcases.py
示例13: checkinfo_wrapper
def checkinfo_wrapper(*args, **kwargs):
suggested_fix = ''
funcname = get_funcname(func)
packagename = funcname.replace('_version', '')
pipname_ = pipname if pipname is not None else packagename
try:
infodict = func(*args, **kwargs)
except ImportError as ex:
infodict = module_stdinfo_dict(None, name=pipname_)
suggested_fix = 'pip install ' + pipname_
if not sys.platform.startswith('win32'):
suggested_fix = 'sudo ' + suggested_fix
return False, 'None', target, infodict, ut.formatex(ex), suggested_fix
except Exception as ex:
infodict = module_stdinfo_dict(None, name=pipname_)
return False, 'None', target, infodict, ut.formatex(ex), 'Some unknown error in ' + packagename
current_version = infodict['__version__']
# Build status text
msg = ut.dict_str(infodict, strvals=True)
msg += '\n' + '%s: %r >= (target=%r)?' % (funcname, current_version, target)
statustext = ut.msgblock(infodict['__name__'], msg)
# Check if passed
passed = version_ge_target(current_version, target)
# Suggest possible fix
if not passed:
suggested_fix = 'pip install ' + infodict['__name__'] + ' --upgrade'
if not sys.platform.startswith('win32'):
suggested_fix = 'sudo ' + suggested_fix
return passed, current_version, target, infodict, statustext, suggested_fix
开发者ID:Erotemic,项目名称:ibeis,代码行数:29,代码来源:assert_modules.py
示例14: preload_commands
def preload_commands(dbdir, **kwargs):
""" Preload commands work with command line arguments and global caches """
#print('[main_cmd] preload_commands')
if params.args.dump_argv:
print(ut.dict_str(vars(params.args), sorted_=False))
if params.args.dump_global_cache:
ut.global_cache_dump() # debug command, dumps to stdout
if params.args.set_workdir is not None:
sysres.set_workdir(params.args.set_workdir)
if params.args.get_workdir:
print(' Current work dir = %s' % sysres.get_workdir())
if params.args.logdir is not None:
sysres.set_logdir(params.args.logdir)
if params.args.get_logdir:
print(' Current log dir = %s' % (sysres.get_logdir(),))
if params.args.view_logdir:
ut.view_directory(sysres.get_logdir())
if ut.get_argflag('--vwd'):
vwd()
if ut.get_argflag('--vdq'):
print('got arg --vdq')
vdq(dbdir)
if kwargs.get('delete_ibsdir', False):
ibsfuncs.delete_ibeis_database(dbdir)
if params.args.convert:
preload_convert_hsdb(dbdir)
if params.args.preload_exit:
print('[main_cmd] preload exit')
sys.exit(1)
开发者ID:heroinlin,项目名称:ibeis,代码行数:29,代码来源:main_commands.py
示例15: cached_wraper
def cached_wraper(*args, **kwargs):
try:
if True:
print('[utool] computing cached function fname_=%s' % (fname_,))
# Implicitly adds use_cache to kwargs
cfgstr = get_cfgstr_from_args(func, args, kwargs, key_argx,
key_kwds, kwdefaults, argnames)
assert cfgstr is not None, 'cfgstr=%r cannot be None' % (cfgstr,)
if kwargs.get('use_cache', use_cache_):
# Make cfgstr from specified input
data = cacher.tryload(cfgstr)
if data is not None:
return data
# Cached missed compute function
data = func(*args, **kwargs)
# Cache save
cacher.save(data, cfgstr)
return data
except Exception as ex:
import utool
_dbgdict2 = dict(key_argx=key_argx, lenargs=len(args), lenkw=len(kwargs),)
msg = '\n'.join([
'+--- UTOOL --- ERROR IN CACHED FUNCTION',
#'dbgdict = ' + utool.dict_str(_dbgdict),
'dbgdict2 = ' + utool.dict_str(_dbgdict2),
])
utool.printex(ex, msg)
raise
开发者ID:animalus,项目名称:utool,代码行数:28,代码来源:util_cache.py
示例16: get_timestats_str
def get_timestats_str(unixtime_list, newlines=False, full=True):
r"""
Args:
unixtime_list (list):
newlines (bool):
Returns:
str: timestat_str
CommandLine:
python -m utool.util_time --test-get_timestats_str
Example:
>>> # ENABLE_DOCTEST
>>> from utool.util_time import * # NOQA
>>> import utool as ut
>>> unixtime_list = [0, 0 + 60*60*5 , 10+ 60*60*5, 100+ 60*60*5, 1000+ 60*60*5]
>>> newlines = True
>>> full = False
>>> timestat_str = get_timestats_str(unixtime_list, newlines, full=full)
>>> result = ut.align(str(timestat_str), ':')
>>> print(result)
{
'max' : '1970/01/01 05:16:40',
'mean' : '1970/01/01 04:03:42',
'min' : '1970/01/01 00:00:00',
'range': '5:16:40',
'std' : '2:02:01',
}
Example2:
>>> # ENABLE_DOCTEST
>>> from utool.util_time import * # NOQA
>>> import utool as ut
>>> unixtime_list = [0, 0 + 60*60*5 , 10+ 60*60*5, 100+ 60*60*5, 1000+ 60*60*5, float('nan'), 0]
>>> newlines = True
>>> timestat_str = get_timestats_str(unixtime_list, newlines)
>>> result = ut.align(str(timestat_str), ':')
>>> print(result)
{
'max' : '1970/01/01 05:16:40',
'mean' : '1970/01/01 03:23:05',
'min' : '1970/01/01 00:00:00',
'nMax' : 1,
'nMin' : 2,
'num_nan': 1,
'range' : '5:16:40',
'shape' : (7,),
'std' : '2:23:43',
}
"""
import utool as ut
datetime_stats = get_timestats_dict(unixtime_list, full=full)
timestat_str = ut.dict_str(datetime_stats, newlines=newlines)
return timestat_str
开发者ID:animalus,项目名称:utool,代码行数:56,代码来源:util_time.py
示例17: chipmatch_view
def chipmatch_view(self, fnum=None, pnum=(1, 1, 1), verbose=None, **kwargs_):
"""
just visualizes the matches using some type of lines
"""
import plottool as pt
from plottool import plot_helpers as ph
if fnum is None:
fnum = self.fnum
if verbose is None:
verbose = ut.VERBOSE
if verbose:
print("-- CHIPMATCH VIEW --")
print("[ichipmatch_view] self.mode = %r" % (self.mode,))
mode = kwargs_.get("mode", self.mode)
draw_ell = mode >= 1
draw_lines = mode == 2
if verbose:
print("[ichipmatch_view] draw_lines = %r" % (draw_lines,))
print("[ichipmatch_view] draw_ell = %r" % (draw_ell,))
# pt.figure(fnum=fnum, docla=True, doclf=True)
# NOTE: i remove the clf here. might cause issues
pt.figure(fnum=fnum, docla=True, doclf=False)
# show_matches_kw = self.__dict__.copy()
show_matches_kw = dict(
# fnum=fnum, pnum=pnum,
draw_lines=draw_lines,
draw_ell=draw_ell,
colorbar_=True,
vert=self.vert,
)
show_matches_kw.update(kwargs_)
if verbose:
print("self.warp_homog = %r" % (self.warp_homog,))
if self.warp_homog:
show_matches_kw["H1"] = self.H1
show_matches_kw["H2"] = self.H2
if verbose:
print("show_matches_kw = %s" % (ut.dict_str(show_matches_kw, truncate=True)))
# tup = show_matches(fm, fs, **show_matches_kw)
ax, xywh1, xywh2 = pt.show_chipmatch2(
self.rchip1, self.rchip2, self.kpts1, self.kpts2, fm=self.fm, fs=self.fs, pnum=pnum, **show_matches_kw
)
self.xywh2 = xywh2
ph.set_plotdat(ax, "viztype", "matches")
if self.truth is not None and self.truth:
truth_color = pt.TRUE_BLUE # if else pt.FALSE_RED
pt.draw_border(ax, color=truth_color, lw=4)
if self.title is not None:
pt.set_title(self.title, ax=ax)
开发者ID:Erotemic,项目名称:plottool,代码行数:55,代码来源:interact_matches.py
示例18: wrp_cache_invalidator
def wrp_cache_invalidator(self, *args, **kwargs):
# the class must have a table_cache property
colscache_ = self.table_cache[tblname]
colnames_ = list(six.iterkeys(colscache_)) if colnames is None else colnames
if DEBUG_API_CACHE:
indenter = ut.Indenter("[%s]" % (tblname,))
indenter.start()
print("+------")
print("INVALIDATING tblname=%r, colnames=%r, rowidx=%r, force=%r" % (tblname, colnames, rowidx, force))
print("self = %r" % (self,))
print("args = %r" % (args,))
print("kwargs = %r" % (kwargs,))
print("colscache_ = " + ut.dict_str(colscache_, truncate=1))
# Clear the cache of any specified colname
# when the invalidator is called
if rowidx is None:
for colname in colnames_:
kwargs_cache_ = colscache_[colname]
# We dont know the rowsids so clear everything
for cache_ in six.itervalues(kwargs_cache_):
cache_.clear()
else:
rowid_list = args[rowidx]
for colname in colnames_:
kwargs_cache_ = colscache_[colname]
# We know the rowids to delete
# iterate over all getter kwargs values
for cache_ in six.itervalues(kwargs_cache_):
ut.delete_dict_keys(cache_, rowid_list)
# Preform set/delete action
if DEBUG_API_CACHE:
print("After:")
print("colscache_ = " + ut.dict_str(colscache_, truncate=1))
print("L__________")
writer_result = writer_func(self, *args, **kwargs)
if DEBUG_API_CACHE:
indenter.stop()
return writer_result
开发者ID:Erotemic,项目名称:ibeis,代码行数:42,代码来源:accessor_decors.py
示例19: get_cfgstr
def get_cfgstr(nnindexer, noquery=False):
r""" returns string which uniquely identified configuration and support data
Args:
noquery (bool): if True cfgstr is only relevant to building the
index. No search params are returned (default = False)
Returns:
str: flann_cfgstr
CommandLine:
python -m ibeis.algo.hots.neighbor_index --test-get_cfgstr
Example:
>>> # DISABLE_DOCTEST
>>> from ibeis.algo.hots.neighbor_index import * # NOQA
>>> import ibeis
>>> cfgdict = dict(fg_on=False)
>>> qreq_ = ibeis.testdata_qreq_(defaultdb='testdb1', p='default:fg_on=False')
>>> qreq_.load_indexer()
>>> nnindexer = qreq_.indexer
>>> noquery = True
>>> flann_cfgstr = nnindexer.get_cfgstr(noquery)
>>> result = ('flann_cfgstr = %s' % (str(flann_cfgstr),))
>>> print(result)
flann_cfgstr = _FLANN((algo=kdtree,seed=42,t=8,))_VECS((11260,128)[email protected]%f3aja)
"""
flann_cfgstr_list = []
use_params_hash = True
use_data_hash = True
if use_params_hash:
flann_defaults = vt.get_flann_params(nnindexer.flann_params['algorithm'])
#flann_params_clean = flann_defaults.copy()
flann_params_clean = ut.sort_dict(flann_defaults)
ut.updateif_haskey(flann_params_clean, nnindexer.flann_params)
if noquery:
ut.delete_dict_keys(flann_params_clean, ['checks'])
shortnames = dict(algorithm='algo', checks='chks', random_seed='seed', trees='t')
short_params = ut.odict([(shortnames.get(key, key), str(val)[0:7])
for key, val in six.iteritems(flann_params_clean)])
flann_valsig_ = ut.dict_str(
short_params, nl=False, explicit=True, strvals=True)
flann_valsig_ = flann_valsig_.lstrip('dict').replace(' ', '')
#flann_valsig_ = str(list(flann_params.values()))
#flann_valsig = ut.remove_chars(flann_valsig_, ', \'[]')
flann_cfgstr_list.append('_FLANN(' + flann_valsig_ + ')')
if use_data_hash:
vecs_hashstr = ut.hashstr_arr(nnindexer.idx2_vec, '_VECS')
flann_cfgstr_list.append(vecs_hashstr)
flann_cfgstr = ''.join(flann_cfgstr_list)
return flann_cfgstr
开发者ID:Erotemic,项目名称:ibeis,代码行数:51,代码来源:neighbor_index.py
示例20: figure_clicked
def figure_clicked(self, event=None):
from ibeis.viz import viz_helpers as vh
ax = event.inaxes
if ih.clicked_inside_axis(event):
viztype = vh.get_ibsdat(ax, 'viztype')
if viztype == 'chip':
aid = vh.get_ibsdat(ax, 'aid')
print('... aid=%r' % aid)
if event.button == 3: # right-click
from ibeis.viz.interact import interact_chip
height = self.fig.canvas.geometry().height()
qpoint = guitool.newQPoint(event.x, height - event.y)
interact_chip.show_annot_context_menu(
self.ibs, aid, self.fig.canvas, qpoint, refresh_func=self.show_page)
#self.show_page()
#ibs.print_annotation_table()
print(ut.dict_str(event.__dict__))
开发者ID:heroinlin,项目名称:ibeis,代码行数:17,代码来源:interact_query_decision.py
注:本文中的utool.dict_str函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论