当前位置: 首页>>代码示例>>Python>>正文


Python utool.execstr_dict函数代码示例

本文整理汇总了Python中utool.execstr_dict函数的典型用法代码示例。如果您正苦于以下问题:Python execstr_dict函数的具体用法?Python execstr_dict怎么用?Python execstr_dict使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了execstr_dict函数的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: run_dev

def run_dev(main_locals):
    print('[dev] run_dev')
    # Get references to controller
    ibs  = main_locals['ibs']
    if ibs is not None:
        # Get aids marked as test cases
        qaid_list = main_helpers.get_test_qaids(ibs)
        print('test_qaids = %r' % qaid_list)
        print('len(test_qaids) = %d' % len(qaid_list))
        # Warn on no test cases
        try:
            assert len(qaid_list) > 0, 'assert!'
        except AssertionError as ex:
            utool.printex(ex, 'len(qaid_list) = 0', iswarning=True)
            #qaid_list = ibs.get_valid_aids()[0]

        if len(qaid_list) > 0:
            # Prepare the IBEIS controller for querys
            ibs.prep_qreq_db(qaid_list)
            # Run the dev experiments
            expt_locals = run_experiments(ibs, qaid_list)
            # Add experiment locals to local namespace
            exec(utool.execstr_dict(expt_locals, 'expt_locals'))
            if '--devmode' in sys.argv:
                # Execute the dev-func and add to local namespace
                devfunc_locals = devfunc(ibs, qaid_list)
                exec(utool.execstr_dict(devfunc_locals, 'devfunc_locals'))

    return locals()
开发者ID:byteyoo,项目名称:ibeis,代码行数:29,代码来源:dev.py

示例2: main_loop

def main_loop(main_locals, rungui=True, ipy=False, persist=True):
    """
    Runs the qt loop if the GUI was initialized and returns an executable string
    for embedding an IPython terminal if requested.

    If rungui is False the gui will not loop even if back has been created
    """
    print('[main] ibeis.main_module.main_loop()')
    from ibeis.dev import params
    import utool
    #print('current process = %r' % (multiprocessing.current_process().name,))
    #== 'MainProcess':
    if rungui and not params.args.nogui:
        try:
            _guitool_loop(main_locals, ipy=ipy)
        except Exception as ex:
            print('[main_loop] IBEIS Caught: %s %s' % (type(ex), ex))
            raise
    #if not persist or params.args.cmd:
    #    main_close()
    # Put locals in the exec namespace
    ipycmd_execstr = utool.ipython_execstr()
    locals_execstr = utool.execstr_dict(main_locals, 'main_locals')
    execstr = locals_execstr + '\n' + ipycmd_execstr
    return execstr
开发者ID:byteyoo,项目名称:ibeis,代码行数:25,代码来源:main_module.py

示例3: run_dev

def run_dev(ibs):
    """
    main developer command

    CommandLine:
        python dev.py --db PZ_Master0 --controlled --print-rankhist
    """
    print('[dev] --- RUN DEV ---')
    # Get reference to controller
    if ibs is not None:
        # Get aids marked as test cases
        ibs, qaid_list, daid_list = main_helpers.testdata_expanded_aids(ibs=ibs)
        #qaid_list = main_helpers.get_test_qaids(ibs, default_qaids=[1])
        #daid_list = main_helpers.get_test_daids(ibs, default_daids='all', qaid_list=qaid_list)
        print('[run_def] Test Annotations:')
        #print('[run_dev] * qaid_list = %s' % ut.packstr(qaid_list, 80, nlprefix='[run_dev]     '))
        try:
            assert len(qaid_list) > 0, 'assert!'
            assert len(daid_list) > 0, 'daid_list!'
        except AssertionError as ex:
            utool.printex(ex, 'len(qaid_list) = 0', iswarning=True)
            utool.printex(ex, 'or len(daid_list) = 0', iswarning=True)
            #qaid_list = ibs.get_valid_aids()[0]

        if len(qaid_list) > 0 or True:
            # Run the dev experiments
            expt_locals = run_devcmds(ibs, qaid_list, daid_list)
            # Add experiment locals to local namespace
            execstr_locals = utool.execstr_dict(expt_locals, 'expt_locals')
            exec(execstr_locals)
        if ut.get_argflag('--devmode'):
            # Execute the dev-func and add to local namespace
            devfunc_locals = devfunc(ibs, qaid_list)
            exec(utool.execstr_dict(devfunc_locals, 'devfunc_locals'))

    return locals()
开发者ID:Erotemic,项目名称:ibeis,代码行数:36,代码来源:dev.py

示例4: __exit__

 def __exit__(self, type_, value, trace):
     if trace is not None:
         print('!!!!!!!!!!!!!!!!!!!')
         print('[util_dbg] %r in context manager!: %s ' % (type_, str(value)))
         import utool
         import traceback
         #traceback.print_stack(type_, value, trace)
         traceback.print_exception(type_, value, trace)
         #parent_locals = utool.get_parent_locals()
         #execstr_parent = utool.execstr_dict(parent_locals, 'parent_locals')
         #exec(execstr_parent)
         trace_locals = trace.tb_frame.f_locals
         execstr_trace = utool.execstr_dict(trace_locals, 'trace_locals')
         exec(execstr_trace)
         utool.embed()
开发者ID:animalus,项目名称:utool,代码行数:15,代码来源:util_dbg.py

示例5: main_loop

def main_loop(main_locals, rungui=True, ipy=False, persist=True):
    """
    Runs the qt loop if the GUI was initialized and returns an executable string
    for embedding an IPython terminal if requested.

    If rungui is False the gui will not loop even if back has been created

    the main locals dict must be callsed main_locals in the scope you call this
    function in.

    Args:
        main_locals (dict_):
        rungui      (bool):
        ipy         (bool):
        persist     (bool):

    Returns:
        str: execstr
    """
    print('[main] ibeis.main_module.main_loop()')
    from ibeis import params
    import utool as ut
    #print('current process = %r' % (multiprocessing.current_process().name,))
    #== 'MainProcess':
    if rungui and not params.args.nogui:
        try:
            _guitool_loop(main_locals, ipy=ipy)
        except Exception as ex:
            ut.printex(ex, 'error in main_loop')
            raise
    #if not persist or params.args.cmd:
    #    main_close()
    # Put locals in the exec namespace
    ipycmd_execstr = ut.ipython_execstr()
    locals_execstr = ut.execstr_dict(main_locals, 'main_locals')
    execstr = locals_execstr + '\n' + ipycmd_execstr
    return execstr
开发者ID:Erotemic,项目名称:ibeis,代码行数:37,代码来源:main_module.py

示例6: TEST_DELETE_ENC

#!/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())
开发者ID:byteyoo,项目名称:ibeis,代码行数:29,代码来源:test_delete_enc.py

示例7: print

    #list(extract_hesaff_sift_feats(cfpath_list, chunksize=16, **genkw))
    #[parallel] executing 1049 gen_feat_worker tasks using 7 processes with chunksize=16
    # * timed: 124.47361485097099 seconds
    #----------
    #list(extract_hesaff_sift_feats(cfpath_list, chunksize=32, **genkw))
    #[parallel] executing 1049 gen_feat_worker tasks using 7 processes with chunksize=32
    # * timed: 126.47238857719219 seconds
    #----------
    #list(extract_hesaff_sift_feats(cfpath_list, chunksize=64, **genkw))
    #[parallel] executing 1049 gen_feat_worker tasks using 7 processes with chunksize=64
    # * timed: 137.3404114996564 seconds

    print('[/TIME_GEN_PREPROC_FEAT]')
    return locals()


if __name__ == '__main__':
    multiprocessing.freeze_support()  # For windows
    import ibeis
    main_locals = ibeis.main(defaultdb='GZ_ALL', gui=False)
    ibs = main_locals['ibs']
    time_locals = {}

    # Varying chunksize seems not to do much on windows :(

    #time_locals.update(TIME_GEN_PREPROC_IMG(ibs))
    time_locals.update(TIME_GEN_PREPROC_FEAT(ibs))
    execstr = utool.execstr_dict(time_locals, 'time_locals')
    exec(execstr)
    exec(utool.ipython_execstr())
开发者ID:Erotemic,项目名称:ibeis,代码行数:30,代码来源:time_generate_preproc_image.py

示例8: print

    aids_in_gids  = ibs.get_image_aids(gid_list)   # Rois in images
    aids_in_nids  = ibs.get_name_aids(nid_list)    # Rois in images
    img_uuid_list = ibs.get_image_uuids(gid_list)  # Image uuids
    annotation_uuid_list = ibs.get_annot_uuids(aid_list)    # Roi uuids
    #
    #
    # IBEIS Getter methods can take scalars as input too,
    # in this case the output is also a scalar
    #
    gid = gid_list[0]
    gpath = ibs.get_image_paths(gid)  # Get an image path

    # Print locals to the screen
    print('locals() = ' + utool.dict_str(locals()))
    return locals()


if __name__ == '__main__':
    multiprocessing.freeze_support()  # for win32
    main_locals = ibeis.main(defaultdb='testdb1', gui=False)
    ibs = main_locals['ibs']  # IBEIS Controller

    # Run the example
    example_locals = run_example(ibs)
    # Add local variables to main namespace
    exec(utool.execstr_dict(example_locals, 'example_locals'))

    execstr = ibeis.main_loop(main_locals)
    # Pass the --cmd flag to the program to run in IPython mode
    exec(execstr)
开发者ID:Erotemic,项目名称:ibeis,代码行数:30,代码来源:example_getters.py

示例9: devmain

def devmain():
    """
    The Developer Script
        A command line interface to almost everything

        -w     # wait / show the gui / figures are visible
        --cmd  # ipython shell to play with variables
        -t     # run list of tests

        Examples:
    """

    helpstr = ut.codeblock(
        '''
        Dev is meant to be run as an interactive script.

        The dev.py script runs any test you regiter with @devcmd in any combination
        of configurations specified by a Config object.

        Dev caches information in order to get quicker results.  # FIXME: Provide quicker results  # FIXME: len(line)
        ''')

    INTRO_TITLE = 'The dev.py Script'
    #INTRO_TEXT = ''.join((ut.bubbletext(INTRO_TITLE, font='cybermedium'), helpstr))
    INTRO_TEXT = ut.bubbletext(INTRO_TITLE, font='cybermedium')

    INTRO_STR = ut.msgblock('dev.py Intro',  INTRO_TEXT)

    EXAMPLE_STR = ut.msgblock('dev.py Examples', ut.codeblock(EXAMPLE_TEXT))

    if ut.NOT_QUIET:
        print(INTRO_STR)
    if ut.get_argflag(('--help', '--verbose')):
        print(EXAMPLE_STR)

    CMD   = ut.get_argflag('--cmd')
    NOGUI = not ut.get_argflag('--gui')

    if len(sys.argv) == 1:
        print('Run dev.py with arguments!')
        sys.exit(1)

    # Run Precommands
    run_devprecmds()

    #
    #
    # Run IBEIS Main, create controller, and possibly gui
    print('++dev')
    main_locals = ibeis.main(gui=ut.get_argflag('--gui'))
    #utool.set_process_title('IBEIS_dev')

    #
    #
    # Load snippet variables
    SNIPPITS = True and CMD
    if SNIPPITS:
        snippet_locals = dev_snippets(main_locals)
        snippet_execstr = utool.execstr_dict(snippet_locals, 'snippet_locals')
        exec(snippet_execstr)

    #
    #
    # Development code
    RUN_DEV = True  # RUN_DEV = '__IPYTHON__' in vars()
    if RUN_DEV:
        dev_locals = run_dev(main_locals['ibs'])
        dev_execstr = utool.execstr_dict(dev_locals, 'dev_locals')
        exec(dev_execstr)

    command = ut.get_argval('--eval', type_=str, default=None)
    if command is not None:
        result = eval(command, globals(), locals())
        print('result = %r' % (result,))
        #ibs.search_annot_notes('360')

    #
    #
    # Main Loop (IPython interaction, or some exec loop)
    #if '--nopresent' not in sys.argv or '--noshow' in sys.argv:
    ut.show_if_requested()
    if ut.get_argflag(('--show', '--wshow')):
        pt.present()
    main_execstr = ibeis.main_loop(main_locals, ipy=(NOGUI or CMD))
    exec(main_execstr)

    #
    #
    # Memory profile
    if ut.get_argflag('--memprof'):
        utool.print_resource_usage()
        utool.memory_profile()

    print('exiting dev')
开发者ID:Erotemic,项目名称:ibeis,代码行数:94,代码来源:dev.py

示例10: NNSplitIndex

    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)
开发者ID:byteyoo,项目名称:ibeis,代码行数:30,代码来源:test_hots_split_trees.py

示例11: print

    from ibeis.dev import dbinfo
    print(ibs.get_infostr())
    dbinfo.get_dbinfo(ibs, verbose=True)
    ################
    print('Inverted Index Stats: vectors per word')
    print(utool.stats_str(map(len, invindex.wx2_idxs.values())))
    ################
    #qfx2_vec     = annots_df['vecs'][1]
    centroids    = invindex.words
    num_pca_dims = 3  # 3
    whiten       = False
    kwd = dict(num_pca_dims=num_pca_dims,
               whiten=whiten,)
    #clustertool.rrr()
    def makeplot_(fnum, prefix, data, labels='centroids', centroids=centroids):
        return clustertool.plot_centroids(data, centroids, labels=labels,
                                          fnum=fnum, prefix=prefix + '\n', **kwd)
    makeplot_(1, 'centroid vecs', centroids)
    #makeplot_(2, 'database vecs', invindex.idx2_dvec)
    #makeplot_(3, 'query vecs', qfx2_vec)
    #makeplot_(4, 'database vecs', invindex.idx2_dvec)
    #makeplot_(5, 'query vecs', qfx2_vec)
    #################


if __name__ == '__main__':
    main_locals = main()
    main_execstr = utool.execstr_dict(main_locals, 'main_locals')
    exec(main_execstr)
    exec(df2.present())
开发者ID:Erotemic,项目名称:ibeis,代码行数:30,代码来源:smk1.py

示例12: print

    """
    multiprocessing.freeze_support()  # for win32

    #
    #
    # Run IBEIS Main, create controller, and possibly gui
    print('++dev')
    main_locals = ibeis.main(gui='--gui' in sys.argv)

    #
    #
    # Load snippet variables
    SNIPPITS = True
    if SNIPPITS:
        snippet_locals = dev_snippets(main_locals)
        snippet_execstr = utool.execstr_dict(snippet_locals, 'snippet_locals')
        exec(snippet_execstr)

    #
    #
    # Development code
    RUN_DEV = True  # RUN_DEV = '__IPYTHON__' in vars()
    if RUN_DEV:
        dev_locals = run_dev(main_locals)
        dev_execstr = utool.execstr_dict(dev_locals, 'dev_locals')
        exec(dev_execstr)

    #
    #
    # Main Loop (IPython interaction, or some exec loop)
    if '--nopresent' not in sys.argv:
开发者ID:byteyoo,项目名称:ibeis,代码行数:31,代码来源:dev.py


注:本文中的utool.execstr_dict函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。