Beispiel #1
0
def present(*args, **kwargs):
    """
    execing present should cause IPython magic

    basically calls show if not embeded.
    """
    if VERBOSE:
        print('[pt] present')
    if '--noshow' not in sys.argv:
        #print('[fig_presenter] Presenting figures...')
        #with warnings.catch_warnings():
        #    warnings.simplefilter("ignore")
        all_figures_tile(*args, **kwargs)
        all_figures_show()
        all_figures_bring_to_front()
        # Return an exec string
    execstr = ut.ipython_execstr()
    execstr += textwrap.dedent('''
    if not embedded:
        if '--quiet' not in sys.argv:
            print('[fig_presenter] Presenting in normal shell.')
            print('[fig_presenter] ... plt.show()')
        import matplotlib.pyplot as plt
        if '--noshow' not in sys.argv:
            print('WARNING USING plt.show')
            plt.show()
    ''')
    return execstr
Beispiel #2
0
def present(*args, **kwargs):
    """
    execing present should cause IPython magic

    basically calls show if not embeded.
    """
    if VERBOSE:
        print('[pt] present')
    if '--noshow' not in sys.argv:
        #print('[fig_presenter] Presenting figures...')
        #with warnings.catch_warnings():
        #    warnings.simplefilter("ignore")
        all_figures_tile(*args, **kwargs)
        all_figures_show()
        all_figures_bring_to_front()
        # Return an exec string
    execstr = ut.ipython_execstr()
    execstr += textwrap.dedent('''
    if not embedded:
        if '--quiet' not in sys.argv:
            print('[fig_presenter] Presenting in normal shell.')
            print('[fig_presenter] ... plt.show()')
        import matplotlib.pyplot as plt
        if '--noshow' not in sys.argv:
            print('WARNING USING plt.show')
            plt.show()
    ''')
    return execstr
Beispiel #3
0
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
Beispiel #4
0
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
    """
    logger.info('[main] wbia.entry_points.main_loop()')
    params.parse_args()
    import utool as ut

    # logger.info('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
Beispiel #5
0
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
Beispiel #6
0
#!/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())
Beispiel #7
0
    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())
    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)