本文整理汇总了Python中utool.flatten函数的典型用法代码示例。如果您正苦于以下问题:Python flatten函数的具体用法?Python flatten怎么用?Python flatten使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了flatten函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。
示例1: get_column_keys
def get_column_keys(metadata):
unflat_colname_list = [
[cols.keys() for cols in qaid2_cols.values()]
for qaid2_cols in six.itervalues(metadata.dictstore)
]
colname_list = ut.unique_keep_order(ut.flatten(ut.flatten(unflat_colname_list)))
return colname_list
开发者ID:heroinlin,项目名称:ibeis,代码行数:7,代码来源:old_storage.py
示例2: delete_contributors
def delete_contributors(ibs, contrib_rowid_list):
r"""
deletes contributors from the database and all information associated
RESTful:
Method: DELETE
URL: /api/contributor/
"""
# TODO: FIXME TESTME
if not ut.QUIET:
print('[ibs] deleting %d contributors' % len(contrib_rowid_list))
config_rowid_list = ut.flatten(ibs.get_contributor_config_rowids(contrib_rowid_list))
# Delete configs (UNSURE IF THIS IS CORRECT)
ibs.delete_configs(config_rowid_list)
# CONTRIBUTORS SHOULD NOT DELETE IMAGES
# Delete encounters
#eid_list = ibs.get_valid_eids()
#eid_config_list = ibs.get_encounter_configid(eid_list)
#valid_list = [config in config_rowid_list for config in eid_config_list ]
#eid_list = ut.compress(eid_list, valid_list)
#ibs.delete_encounters(eid_list)
# Remote image contributors ~~~Delete images~~~~
gid_list = ut.flatten(ibs.get_contributor_gids(contrib_rowid_list))
ibs.set_image_contributor_rowid(gid_list, [None] * len(gid_list))
#ibs.delete_images(gid_list)
# Delete contributors
ibs.db.delete_rowids(const.CONTRIBUTOR_TABLE, contrib_rowid_list)
开发者ID:heroinlin,项目名称:ibeis,代码行数:28,代码来源:manual_meta_funcs.py
示例3: get_varied_acfg_labels
def get_varied_acfg_labels(acfg_list, mainkey='_cfgname', checkname=False):
"""
>>> from ibeis.expt.annotation_configs import * # NOQA
"""
#print(ut.list_str(varied_acfg_list, nl=2))
for acfg in acfg_list:
assert acfg['qcfg'][mainkey] == acfg['dcfg'][mainkey], (
'should be the same for now')
cfgname_list = [acfg['qcfg'][mainkey] for acfg in acfg_list]
if checkname and ut.allsame(cfgname_list):
cfgname_list = [None] * len(cfgname_list)
# Hack to make common params between q and d appear the same
_acfg_list = [compress_aidcfg(acfg) for acfg in acfg_list]
flat_acfg_list = flatten_acfg_list(_acfg_list)
nonvaried_dict, varied_acfg_list = ut.partition_varied_cfg_list(
flat_acfg_list)
SUPER_HACK = True
if SUPER_HACK:
# SUPER HACK, recompress remake the varied list after knowing what is varied
_varied_keys = list(set(ut.flatten(
[list(ut.flatten(
[list(x.keys())
for x in unflatten_acfgdict(cfg).values()]
)) for cfg in varied_acfg_list]
)))
_acfg_list = [
compress_aidcfg(acfg, force_noncommon=_varied_keys)
for acfg in acfg_list]
flat_acfg_list = flatten_acfg_list(_acfg_list)
nonvaried_dict, varied_acfg_list = ut.partition_varied_cfg_list(
flat_acfg_list)
shortened_cfg_list = [
#{shorten_to_alias_labels(key): val for key, val in _dict.items()}
ut.map_dict_keys(shorten_to_alias_labels, _dict)
for _dict in varied_acfg_list]
nonlbl_keys = ut.INTERNAL_CFGKEYS
nonlbl_keys = [prefix + key for key in nonlbl_keys
for prefix in ['', 'q', 'd']]
# hack for sorting by q/d stuff first
def get_key_order(cfg):
keys = [k for k in cfg.keys() if k not in nonlbl_keys]
sortorder = [2 * k.startswith('q') + 1 * k.startswith('d')
for k in keys]
return ut.sortedby(keys, sortorder)[::-1]
cfglbl_list = [
ut.get_cfg_lbl(cfg, name, nonlbl_keys, key_order=get_key_order(cfg))
for cfg, name in zip(shortened_cfg_list, cfgname_list)]
if checkname:
cfglbl_list = [x.lstrip(':') for x in cfglbl_list]
return cfglbl_list
开发者ID:Erotemic,项目名称:ibeis,代码行数:58,代码来源:annotation_configs.py
示例4: _build_inverted_descriptor_index
def _build_inverted_descriptor_index(aid_list, desc_list):
"""
Stacks descriptors into a flat structure and returns inverse mapping from
flat database descriptor indexes (dx) to annotation ids (aid) and feature
indexes (fx). Feature indexes are w.r.t. annotation indexes.
Output:
dx2_desc - flat descriptor stack
dx2_aid - inverted index into annotations
dx2_fx - inverted index into features
# Example with 2D Descriptors
>>> from ibeis.model.hots.hots_nn_index import * # NOQA
>>> from ibeis.model.hots.hots_nn_index import _build_inverted_descriptor_index
>>> DESC_TYPE = np.uint8
>>> aid_list = [1, 2, 3, 4, 5]
>>> desc_list = [
... np.array([[0, 0], [0, 1]], dtype=DESC_TYPE),
... np.array([[5, 3], [2, 30], [1, 1]], dtype=DESC_TYPE),
... np.empty((0, 2), dtype=DESC_TYPE),
... np.array([[5, 3], [2, 30], [1, 1]], dtype=DESC_TYPE),
... np.array([[3, 3], [42, 42], [2, 6]], dtype=DESC_TYPE),
... ]
>>> dx2_desc, dx2_aid, dx2_fx = _build_inverted_descriptor_index(aid_list, desc_list)
>>> print(repr(dx2_desc.T))
array([[ 0, 0, 5, 2, 1, 5, 2, 1, 3, 42, 2],
[ 0, 1, 3, 30, 1, 3, 30, 1, 3, 42, 6]], dtype=uint8)
>>> print(repr(dx2_aid))
array([1, 1, 2, 2, 2, 4, 4, 4, 5, 5, 5])
>>> print(repr(dx2_fx))
array([0, 1, 0, 1, 2, 0, 1, 2, 0, 1, 2])
cdef:
list aid_list, desc_list
long nFeat, aid
iter aid_nFeat_iter, nFeat_iter, _ax2_aid, _ax2_fx
np.ndarray dx2_aid, dx2_fx, dx2_desc
"""
# Build inverted index of (aid, fx) pairs
aid_nFeat_iter = zip(aid_list, map(len, desc_list))
nFeat_iter = map(len, desc_list)
# generate aid inverted index for each feature in each annotation
_ax2_aid = ([aid] * nFeat for (aid, nFeat) in aid_nFeat_iter)
# Avi: please test the timing of the lines neighboring this statement.
#_ax2_aid = ([aid] * nFeat for (aid, nFeat) in aid_nFeat_iter)
# generate featx inverted index for each feature in each annotation
_ax2_fx = (range(nFeat) for nFeat in nFeat_iter)
# Flatten generators into the inverted index
#dx2_aid = np.array(list(chain.from_iterable(_ax2_aid)))
#dx2_fx = np.array(list(chain.from_iterable(_ax2_fx)))
dx2_aid = np.array(utool.flatten(_ax2_aid))
dx2_fx = np.array(utool.flatten(_ax2_fx))
# Stack descriptors into numpy array corresponding to inverted inexed
# This might throw a MemoryError
dx2_desc = np.vstack(desc_list)
return dx2_desc, dx2_aid, dx2_fx
开发者ID:heroinlin,项目名称:ibeis,代码行数:57,代码来源:hots_nn_index.py
示例5: get_varied_params_list
def get_varied_params_list(test_cfg_name_list):
vary_dicts = get_vary_dicts(test_cfg_name_list)
dict_comb_list = [utool.all_dict_combinations(dict_) for dict_ in vary_dicts]
dict_comb_lbls = [utool.all_dict_combinations_lbls(dict_) for dict_ in vary_dicts]
# Append testname
dict_comb_lbls = [[name_lbl + lbl for lbl in comb_lbls] for name_lbl, comb_lbls in izip(test_cfg_name_list, dict_comb_lbls)]
varied_params_list = utool.flatten(dict_comb_list) # [comb for dict_comb in dict_comb_list for comb in dict_comb]
varied_param_lbls = utool.flatten(dict_comb_lbls)
return varied_params_list, varied_param_lbls
开发者ID:byteyoo,项目名称:ibeis,代码行数:9,代码来源:experiment_helpers.py
示例6: test_incremental_add
def test_incremental_add(ibs):
r"""
Args:
ibs (IBEISController):
CommandLine:
python -m ibeis.algo.hots._neighbor_experiment --test-test_incremental_add
Example:
>>> # DISABLE_DOCTEST
>>> from ibeis.algo.hots.neighbor_index_cache import * # NOQA
>>> import ibeis
>>> ibs = ibeis.opendb('PZ_MTEST')
>>> result = test_incremental_add(ibs)
>>> print(result)
"""
import ibeis
sample_aids = ibeis.testdata_aids(a='default:pername=1,mingt=2')
aids1 = sample_aids[::2]
aids2 = sample_aids[0:5]
aids3 = sample_aids[:-1] # NOQA
daid_list = aids1 # NOQA
qreq_ = ibs.new_query_request(aids1, aids1)
nnindexer1 = neighbor_index_cache.request_ibeis_nnindexer(ibs.new_query_request(aids1, aids1)) # NOQA
nnindexer2 = neighbor_index_cache.request_ibeis_nnindexer(ibs.new_query_request(aids2, aids2)) # NOQA
# TODO: SYSTEM use visual uuids
#daids_hashid = qreq_.ibs.get_annot_hashid_visual_uuid(daid_list) # get_internal_data_hashid()
items = ibs.get_annot_visual_uuids(aids3)
uuid_map_fpath = neighbor_index_cache.get_nnindexer_uuid_map_fpath(qreq_)
candidate_uuids = neighbor_index_cache.read_uuid_map(uuid_map_fpath, 0)
candidate_sets = candidate_uuids
covertup = ut.greedy_max_inden_setcover(candidate_sets, items)
uncovered_items, covered_items_list, accepted_keys = covertup
covered_items = ut.flatten(covered_items_list)
covered_aids = sorted(ibs.get_annot_aids_from_visual_uuid(covered_items))
uncovered_aids = sorted(ibs.get_annot_aids_from_visual_uuid(uncovered_items))
nnindexer3 = neighbor_index_cache.request_ibeis_nnindexer(ibs.new_query_request(uncovered_aids, uncovered_aids)) # NOQA
# TODO: SYSTEM use visual uuids
#daids_hashid = qreq_.ibs.get_annot_hashid_visual_uuid(daid_list) # get_internal_data_hashid()
items = ibs.get_annot_visual_uuids(sample_aids)
uuid_map_fpath = neighbor_index_cache.get_nnindexer_uuid_map_fpath(qreq_)
#contextlib.closing(shelve.open(uuid_map_fpath)) as uuid_map:
candidate_uuids = neighbor_index_cache.read_uuid_map(uuid_map_fpath, 0)
candidate_sets = candidate_uuids
covertup = ut.greedy_max_inden_setcover(candidate_sets, items)
uncovered_items, covered_items_list, accepted_keys = covertup
covered_items = ut.flatten(covered_items_list)
covered_aids = sorted(ibs.get_annot_aids_from_visual_uuid(covered_items)) # NOQA
uncovered_aids = sorted(ibs.get_annot_aids_from_visual_uuid(uncovered_items))
开发者ID:Erotemic,项目名称:ibeis,代码行数:54,代码来源:_neighbor_experiment.py
示例7: __init__
def __init__(fstack, ibs, aid_list, config=None):
ax2_vecs = ibs.depc_annot.d.get_feat_vecs(aid_list, config=config)
fstack.config = config
fstack.ibs = ibs
fstack.ax2_aid = aid_list
fstack.ax2_nFeat = [len(vecs) for vecs in ax2_vecs]
fstack.idx2_fxs = ut.flatten([list(range(num)) for num in fstack.ax2_nFeat])
fstack.idx2_axs = ut.flatten([[ax] * num for ax, num in enumerate(fstack.ax2_nFeat)])
fstack.idx2_vec = np.vstack(ax2_vecs)
#fstack.idx2_fxs = vt.atleast_nd(fstack.idx2_fxs, 2)
#fstack.idx2_axs = vt.atleast_nd(fstack.idx2_axs, 2)
fstack.num_feat = sum(fstack.ax2_nFeat)
开发者ID:Erotemic,项目名称:ibeis,代码行数:12,代码来源:new_annots.py
示例8: intersect_hack
def intersect_hack():
failed = testres.rank_mat > 0
colx2_failed = [np.nonzero(failed_col)[0] for failed_col in failed.T]
#failed_col2_only = np.setdiff1d(colx2_failed[1], colx2_failed[0])
#failed_col2_only_aids = ut.take(testres.qaids, failed_col2_only)
failed_col1_only = np.setdiff1d(colx2_failed[0], colx2_failed[1])
failed_col1_only_aids = ut.take(testres.qaids, failed_col1_only)
gt_aids1 = ibs.get_annot_groundtruth(failed_col1_only_aids, daid_list=testres.cfgx2_qreq_[0].daids)
gt_aids2 = ibs.get_annot_groundtruth(failed_col1_only_aids, daid_list=testres.cfgx2_qreq_[1].daids)
qaids_expt = failed_col1_only_aids
gt_avl_aids1 = ut.flatten(gt_aids1)
gt_avl_aids2 = list(set(ut.flatten(gt_aids2)).difference(gt_avl_aids1))
ibs.print_annotconfig_stats(qaids_expt, gt_avl_aids1)
ibs.print_annotconfig_stats(qaids_expt, gt_avl_aids2)
#jsontext = ut.to_json({
# 'qaids': list(qaids_expt),
# 'dinclude_aids1': list(gt_aids_expt1),
# 'dinclude_aids2': list(gt_aids_expt2),
#})
#annotation_configs.varysize_pzm
#from ibeis.expt import annotation_configs
acfg = testres.acfg_list[0]
import copy
acfg1 = copy.deepcopy(acfg)
acfg2 = copy.deepcopy(acfg)
acfg1['qcfg']['min_pername'] = None
acfg2['qcfg']['min_pername'] = None
acfg1['dcfg']['min_pername'] = None
acfg2['dcfg']['min_gt_per_name'] = None
acfg1['qcfg']['default_aids'] = qaids_expt
acfg1['dcfg']['gt_avl_aids'] = gt_avl_aids1
acfg2['qcfg']['default_aids'] = qaids_expt
acfg2['dcfg']['gt_avl_aids'] = gt_avl_aids2
from ibeis.init import filter_annots
from ibeis.expt import experiment_helpers
annots1 = filter_annots.expand_acfgs(ibs, acfg1, verbose=True)
annots2 = filter_annots.expand_acfgs(ibs, acfg2, verbose=True)
acfg_name_list = dict( # NOQA
acfg_list=[acfg1, acfg2],
expanded_aids_list=[annots1, annots2],
)
test_cfg_name_list = ['candidacy_k']
cfgdict_list, pipecfg_list = experiment_helpers.get_pipecfg_list(test_cfg_name_list, ibs=ibs)
t1, t2 = testres_list # NOQA
开发者ID:Erotemic,项目名称:ibeis,代码行数:52,代码来源:experiment_printres.py
示例9: parse_all_fname_tags
def parse_all_fname_tags(fname):
_tags = [splitext(fname)[0]]
_tags = ut.flatten([t.split('_') for t in _tags])
_tags = ut.flatten([t.split('.') for t in _tags])
_tags = [t.lower() for t in _tags]
_tags = [tag_alias_map.get(t, t) for t in _tags]
for key, vals in regex_alias_map.items():
pat = ut.regex_or(vals)
_tags = [key if re.match(pat, t) else t for t in _tags]
pat = ut.regex_or(invalid_tag_patterns)
_tags = [t for t in _tags if not re.match(pat, t)]
_tags = ut.unique_ordered(_tags)
return _tags
开发者ID:Erotemic,项目名称:ibeis,代码行数:13,代码来源:getshark.py
示例10: make_ibeis_matching_graph
def make_ibeis_matching_graph(ibs, qaid_list, daids_list, scores_list):
print('make_ibeis_matching_graph')
aid1_list = ut.flatten([[qaid] * len(daids) for qaid, daids in zip(qaid_list, daids_list)])
aid2_list = ut.flatten(daids_list)
unique_aids = list(set(aid2_list + qaid_list))
score_list = ut.flatten(scores_list)
# Make a graph between the chips
nodes = list(zip(unique_aids))
edges = list(zip(aid1_list, aid2_list, score_list))
node_lbls = [('aid', 'int')]
edge_lbls = [('weight', 'float')]
netx_graph = make_netx_graph(nodes, edges, node_lbls, edge_lbls)
return netx_graph
开发者ID:heroinlin,项目名称:ibeis,代码行数:14,代码来源:viz_graph.py
示例11: get_name_imgsetids
def get_name_imgsetids(ibs, nid_list):
r"""
RESTful:
Method: GET
URL: /api/name/imgsetids/
"""
import utool as ut
name_aids_list = ibs.get_name_aids(nid_list)
name_aid_list = ut.flatten(name_aids_list)
name_gid_list = ibs.get_annot_gids(name_aid_list)
name_imgsetids_list = ibs.get_image_imgsetids(name_gid_list)
name_imgsetid_list = ut.flatten(name_imgsetids_list)
name_imgsetids = list(set(name_imgsetid_list))
return name_imgsetids
开发者ID:Erotemic,项目名称:ibeis,代码行数:15,代码来源:manual_name_funcs.py
示例12: unnest_data
def unnest_data(data):
unnested_cols = list(zip(ut.take(data, idxs2)))
nested_cols = ut.take(data, idxs1)
grouped_items = [nested_cols, unnested_cols]
groupxs = [idxs1, idxs2]
unflat = ut.ungroup(grouped_items, groupxs, nested_nCols - 1)
return tuple(ut.flatten(unflat))
开发者ID:Erotemic,项目名称:ibeis,代码行数:7,代码来源:depends_cache.py
示例13: get_set_groundfalse
def get_set_groundfalse(ibs, qaids):
# get groundfalse annots relative to the entire set
valid_nids = ibs.get_valid_nids()
qnids = ibs.get_annot_nids(qaids)
nid_list = list(set(valid_nids) - set(qnids))
aids_list = ibs.get_name_aids(nid_list)
return ut.flatten(aids_list)
开发者ID:Erotemic,项目名称:ibeis,代码行数:7,代码来源:optimize_k.py
示例14: test_vsone_verified
def test_vsone_verified(ibs):
"""
hack in vsone-reranking
Example:
>>> # DISABLE_DOCTEST
>>> from ibeis.all_imports import * # NOQA
>>> #reload_all()
>>> from ibeis.algo.hots.automated_matcher import * # NOQA
>>> import ibeis
>>> ibs = ibeis.opendb('PZ_MTEST')
>>> test_vsone_verified(ibs)
"""
import plottool as pt
#qaids = ibs.get_easy_annot_rowids()
nids = ibs.get_valid_nids(filter_empty=True)
grouped_aids_ = ibs.get_name_aids(nids)
grouped_aids = list(filter(lambda x: len(x) > 1, grouped_aids_))
items_list = grouped_aids
sample_aids = ut.flatten(ut.sample_lists(items_list, num=2, seed=0))
qaid2_qres, qreq_ = query_vsone_verified(ibs, sample_aids, sample_aids)
for cm in ut.InteractiveIter(list(six.itervalues(qaid2_qres))):
pt.close_all_figures()
fig = cm.ishow_top(ibs)
fig.show()
开发者ID:Erotemic,项目名称:ibeis,代码行数:26,代码来源:special_query.py
示例15: group_review
def group_review():
prefill = request.args.get('prefill', '')
if len(prefill) > 0:
ibs = current_app.ibs
aid_list = ibs.get_valid_aids()
bad_species_list, bad_viewpoint_list = ibs.validate_annot_species_viewpoint_cnn(aid_list)
GROUP_BY_PREDICTION = True
if GROUP_BY_PREDICTION:
grouped_dict = ut.group_items(bad_viewpoint_list, ut.get_list_column(bad_viewpoint_list, 3))
grouped_list = grouped_dict.values()
regrouped_items = ut.flatten(ut.sortedby(grouped_list, map(len, grouped_list)))
candidate_aid_list = ut.get_list_column(regrouped_items, 0)
else:
candidate_aid_list = [ bad_viewpoint[0] for bad_viewpoint in bad_viewpoint_list]
elif request.args.get('aid_list', None) is not None:
aid_list = request.args.get('aid_list', '')
if len(aid_list) > 0:
aid_list = aid_list.replace('[', '')
aid_list = aid_list.replace(']', '')
aid_list = aid_list.strip().split(',')
candidate_aid_list = [ int(aid_.strip()) for aid_ in aid_list ]
else:
candidate_aid_list = ''
else:
candidate_aid_list = ''
return appf.template(None, 'group_review', candidate_aid_list=candidate_aid_list, mode_list=appf.VALID_TURK_MODES)
开发者ID:Erotemic,项目名称:ibeis,代码行数:28,代码来源:routes.py
示例16: make_ibeis_cell_list
def make_ibeis_cell_list(ibs):
cell_template_list = get_default_cell_template_list(ibs)
autogen_str = make_autogen_str()
dbname = ibs.get_dbname()
#if ut.get_argflag('--hacktestscore'):
# annotconfig_list_body = ut.codeblock(
# '''
# 'timectrl',
# '''
# )
#else:
default_acfgstr = ut.get_argval('-a', type_=str, default='default:is_known=True')
annotconfig_list_body = ut.codeblock(
ut.repr2(default_acfgstr) + '\n' +
ut.codeblock('''
# See ibeis/expt/annotation_configs.py for names of annot configuration options
#'default:has_any=(query,),dpername=1,exclude_reference=True',
#'default:is_known=True',
#'default:qsame_encounter=True,been_adjusted=True,excluderef=True'
#'default:qsame_encounter=True,been_adjusted=True,excluderef=True,qsize=10,dsize=20',
#'default:require_timestamp=True,min_timedelta=3600',
#'default:species=primary',
#'timectrl:',
#'timectrl:been_adjusted=True,dpername=3',
#'timectrl:qsize=10,dsize=20',
#'unctrl:been_adjusted=True',
''')
)
#if ut.get_argflag('--hacktestscore'):
# pipeline_list_body = ut.codeblock(
# '''
# # See ibeis/algo/Config.py for names of pipeline config options
# 'default:lnbnn_on=True,bar_l2_on=False,normonly_on=False,fg_on=True',
# 'default:lnbnn_on=False,bar_l2_on=True,normonly_on=False,fg_on=True',
# 'default:lnbnn_on=False,bar_l2_on=False,normonly_on=True,fg_on=True',
# 'default:lnbnn_on=True,bar_l2_on=False,normonly_on=False,fg_on=False',
# 'default:lnbnn_on=False,bar_l2_on=True,normonly_on=False,fg_on=False',
# 'default:lnbnn_on=False,bar_l2_on=False,normonly_on=True,fg_on=False',
# '''
# )
#elif True:
default_pcfgstr_list = ut.get_argval(('-t', '-p'), type_=list, default='default')
default_pcfgstr = ut.repr3(default_pcfgstr_list, nobr=True)
pipeline_list_body = ut.codeblock(
default_pcfgstr + '\n' +
ut.codeblock('''
#'default',
#'default:K=1',
#'default:K=1,AI=False',
#'default:K=1,AI=False,QRH=True',
#'default:K=1,RI=True,AI=False',
#'default:K=1,adapteq=True',
#'default:fg_on=[True,False]',
''')
)
locals_ = locals()
_format = partial(format_cells, locals_=locals_)
cell_list = ut.flatten(map(_format, cell_template_list))
return cell_list
开发者ID:heroinlin,项目名称:ibeis,代码行数:60,代码来源:generate_notebook.py
示例17: 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
示例18: get_param_info_list
def get_param_info_list(nnweight_cfg):
# new way to try and specify config options.
# not sure if i like it yet
param_info_list = ut.flatten([
[
ut.ParamInfo('ratio_thresh', None, type_=float, hideif=None),
ut.ParamInfoBool('lnbnn_on', True, hideif=False),
ut.ParamInfoBool('const_on', False, hideif=False),
ut.ParamInfoBool('borda_on', False, hideif=False),
ut.ParamInfoBool('lograt_on', False, hideif=False),
#ut.ParamInfoBool('loglnbnn_on', False, hideif=False),
#ut.ParamInfoBool('logdist_on', False, hideif=False),
#ut.ParamInfoBool('dist_on', False, hideif=False),
ut.ParamInfoBool('normonly_on', False, hideif=False),
ut.ParamInfoBool('bar_l2_on', False, hideif=False),
ut.ParamInfoBool('cos_on', False, hideif=False),
ut.ParamInfoBool('fg_on', True, hideif=False),
ut.ParamInfo('normalizer_rule', 'last', '', valid_values=['last', 'name']),
ut.ParamInfo('lnbnn_normer', None, hideif=None,
help_='config string for lnbnn score normalizer'),
ut.ParamInfo('lnbnn_norm_thresh', .5, type_=float,
hideif=lambda cfg: not cfg['lnbnn_normer'] ,
help_='config string for lnbnn score normalizer'),
#
ut.ParamInfoBool('can_match_sameimg', False, 'sameimg',
hideif=False),
ut.ParamInfoBool('can_match_samename', True, 'samename',
hideif=True),
# Hacked in
#ut.ParamInfoBool('root_sift_on', False, hideif=False),
ut.ParamInfoBool('sqrd_dist_on', False, hideif=True),
#ut.ParamInfoBool('sqrd_dist_on', True, hideif=True),
],
])
return param_info_list
开发者ID:Erotemic,项目名称:ibeis,代码行数:35,代码来源:Config.py
示例19: ensure_mana_list
def ensure_mana_list(manas=None, source=None):
from mtgmonte import mtgobjs
#if sources is None:
# source = None
#else:
# source = None
if manas is None:
manas = []
elif hasattr(manas, '_manas'): # isinstance(manas, ManaSet):
manas = manas._manas
#elif isinstance(manas, mtgobjs.Mana): # isinstance(manas, ManaSet):
elif hasattr(manas, 'color'):
manas = [manas]
elif isinstance(manas, dict): # isinstance(manas, ManaSet):
manas = [mtgobjs.Mana(color, source, num) for color, num in manas.items()]
elif isinstance(manas, six.string_types):
tokens = tokenize_manacost(manas)
manas = [mtgobjs.Mana(color, source, type_=type_) for color, type_ in tokens]
# colors = manas.strip('{}')
# manas = [mtgobjs.Mana(color, source) for color in colors]
elif isinstance(manas, (list, tuple)):
manas = ut.flatten([ensure_mana_list(m) for m in manas])
else:
raise ValueError('Cannot ensure unknown type=%r, manas=%r' % (type(manas), manas,))
return manas
开发者ID:Erotemic,项目名称:mtgmonte,代码行数:25,代码来源:mtgobjs.py
示例20: get_annot_annotmatch_tags
def get_annot_annotmatch_tags(ibs, aid_list):
r"""
Args:
ibs (IBEISController): ibeis controller object
aid_list (list): list of annotation rowids
Returns:
list: annotmatch_tags_list
CommandLine:
python -m ibeis.tag_funcs --exec-get_annot_annotmatch_tags --db GZ_Master1
Example:
>>> # ENABLE_DOCTEST
>>> from ibeis.tag_funcs import * # NOQA
>>> import ibeis
>>> ibs = ibeis.opendb(defaultdb='testdb1')
>>> aid_list = ibs.get_valid_aids()
>>> all_tags = ut.flatten(get_annot_annotmatch_tags(ibs, aid_list))
>>> tag_hist = ut.dict_hist(all_tags)
>>> ut.print_dict(tag_hist)
"""
annotmatch_rowids = ibs.get_annotmatch_rowids_from_aid(aid_list)
unflat_tags_list = ibs.unflat_map(ibs.get_annotmatch_case_tags, annotmatch_rowids)
annotmatch_tags_list = [list(set(ut.flatten(_unflat_tags))) for
_unflat_tags in unflat_tags_list]
return annotmatch_tags_list
开发者ID:Erotemic,项目名称:ibeis,代码行数:27,代码来源:tag_funcs.py
注:本文中的utool.flatten函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论