Beispiel #1
0
    def __init__(invindex, words, wordflann, idx2_vec, idx2_aid, idx2_fx,
                 daids, daid2_label):
        invindex.words = words
        invindex.wordflann = wordflann
        invindex.idx2_dvec = idx2_vec
        invindex.idx2_daid = idx2_aid
        invindex.idx2_dfx = idx2_fx
        invindex.daids = daids
        invindex.daid2_label = daid2_label
        invindex.wx2_idxs = None
        invindex.wx2_aids = None
        invindex.wx2_fxs = None
        invindex.wx2_maws = None
        invindex.wx2_drvecs = None
        invindex.wx2_dflags = None
        invindex.wx2_idf = None
        invindex.daid2_sccw = None
        invindex.idx2_fweight = None
        invindex.idx2_wxs = None  # stacked index -> word indexes

        # Inject debug function
        from ibeis.algo.hots.smk import smk_debug
        ut.make_class_method_decorator(INVERTED_INDEX_INJECT_KEY)(
            smk_debug.invindex_dbgstr)
        ut.inject_instance(invindex, classkey=INVERTED_INDEX_INJECT_KEY)
Beispiel #2
0
    def __init__(invindex, words, wordflann, idx2_vec, idx2_aid, idx2_fx,
                 daids, daid2_label):
        invindex.words        = words
        invindex.wordflann    = wordflann
        invindex.idx2_dvec    = idx2_vec
        invindex.idx2_daid    = idx2_aid
        invindex.idx2_dfx     = idx2_fx
        invindex.daids        = daids
        invindex.daid2_label  = daid2_label
        invindex.wx2_idxs     = None
        invindex.wx2_aids     = None
        invindex.wx2_fxs      = None
        invindex.wx2_maws     = None
        invindex.wx2_drvecs   = None
        invindex.wx2_dflags   = None
        invindex.wx2_idf      = None
        invindex.daid2_sccw   = None
        invindex.idx2_fweight = None
        invindex.idx2_wxs     = None   # stacked index -> word indexes

        # Inject debug function
        from ibeis.algo.hots.smk import smk_debug
        ut.make_class_method_decorator(INVERTED_INDEX_INJECT_KEY)(smk_debug.invindex_dbgstr)
        ut.inject_instance(invindex, classkey=INVERTED_INDEX_INJECT_KEY)
Beispiel #3
0
def make_ibs_register_decorator(modname):
    """builds variables and functions that controller injectable modules need."""
    if __name__ == '__main__':
        print('WARNING: cannot register controller functions as main')
    CLASS_INJECT_KEY = (CONTROLLER_CLASSNAME, modname)
    # Create dectorator to inject these functions into the IBEISController
    register_ibs_unaliased_method = ut.make_class_method_decorator(
        CLASS_INJECT_KEY, modname)

    # TODO Replace IBEISContoller INEJECTED MODULES with this one
    #INJECTED_MODULES.append(sys.modules[modname])

    def register_ibs_method(func):
        """ registers autogenerated functions with the utool class method injector """
        #func  = profile(func)
        register_ibs_unaliased_method(func)
        #aliastup = (func, '_injected_' + ut.get_funcname(func))
        #register_ibs_aliased_method(aliastup)
        return func
    return CLASS_INJECT_KEY, register_ibs_method
Beispiel #4
0
def make_ibs_register_decorator(modname):
    """
    builds variables and functions that controller injectable modules need
    """
    if __name__ == '__main__':
        print('WARNING: cannot register controller functions as main')
    CLASS_INJECT_KEY = (CONTROLLER_CLASSNAME, modname)
    # Create dectorator to inject these functions into the IBEISController
    register_ibs_unaliased_method = ut.make_class_method_decorator(
        CLASS_INJECT_KEY, modname)

    # TODO Replace IBEISContoller INEJECTED MODULES with this one
    #INJECTED_MODULES.append(sys.modules[modname])

    def register_ibs_method(func):
        """ registers autogenerated functions with the utool class method injector """
        #func  = profile(func)
        register_ibs_unaliased_method(func)
        #aliastup = (func, '_injected_' + ut.get_funcname(func))
        #register_ibs_aliased_method(aliastup)
        return func
    return CLASS_INJECT_KEY, register_ibs_method
Beispiel #5
0
def report_memory(obj, objname='obj'):
    """
    obj = invindex
    objname = 'invindex'

    """
    print('Object Memory Usage for %s' % objname)
    maxlen = max(map(len, six.iterkeys(obj.__dict__)))
    for key, val in six.iteritems(obj.__dict__):
        fmtstr = 'memusage({0}.{1}){2} = '
        lbl = fmtstr.format(objname, key, ' ' * (maxlen - len(key)))
        sizestr = ut.get_object_size_str(val, lbl=lbl, unit='MB')
        print(sizestr)


report_memsize = ut.make_class_method_decorator(INVERTED_INDEX_INJECT_KEY)(ut.report_memsize)


QueryIndex = namedtuple(
    'QueryIndex', (
        'wx2_qrvecs',
        'wx2_qflags',
        'wx2_maws',
        'wx2_qaids',
        'wx2_qfxs',
        'query_sccw',
    ))


class LazyGetter(object):
    """
Beispiel #6
0
# Valid API Models
from wbia.guitool.stripe_proxy_model import StripeProxyModel
from wbia.guitool.filter_proxy_model import FilterProxyModel
from wbia.guitool.api_item_model import APIItemModel

(print, rrr, profile) = utool.inject2(__name__, '[APIItemView]')
logger = logging.getLogger('wbia')

VERBOSE_QT = ut.get_argflag(('--verbose-qt', '--verbqt'))
VERBOSE_ITEM_VIEW = ut.get_argflag(('--verbose-item-view'))
VERBOSE = utool.VERBOSE or VERBOSE_QT or VERBOSE_ITEM_VIEW

API_VIEW_BASE = QtWidgets.QAbstractItemView
ABSTRACT_VIEW_INJECT_KEY = ('QtWidgets.QAbstractItemView', 'guitool')
register_view_method = utool.make_class_method_decorator(
    ABSTRACT_VIEW_INJECT_KEY, __name__)

injectviewinstance = functools.partial(utool.inject_instance,
                                       classkey=ABSTRACT_VIEW_INJECT_KEY)

VALID_API_MODELS = (FilterProxyModel, StripeProxyModel, APIItemModel)


class APIItemView(API_VIEW_BASE):
    """
    Trees and Tables implicitly inherit from this class.
    Abstractish class.

    other function in this file will be injected into the concrete
    implementations of either a table or tree view. The code is only written
    once but duplicated in each of the psuedo-children. It is done this way to
Beispiel #7
0
import utool as ut
import operator
# Valid API Models
from guitool.stripe_proxy_model import StripeProxyModel
from guitool.filter_proxy_model import FilterProxyModel
from guitool.api_item_model import APIItemModel

(print, rrr, profile) = utool.inject2(__name__, '[APIItemView]')

VERBOSE_QT = ut.get_argflag(('--verbose-qt', '--verbqt'))
VERBOSE_ITEM_VIEW = ut.get_argflag(('--verbose-item-view'))
VERBOSE = utool.VERBOSE or VERBOSE_QT or VERBOSE_ITEM_VIEW

API_VIEW_BASE = QtGui.QAbstractItemView
ABSTRACT_VIEW_INJECT_KEY = ('QtGui.QAbstractItemView', 'guitool')
register_view_method = utool.make_class_method_decorator(ABSTRACT_VIEW_INJECT_KEY, __name__)

injectviewinstance = functools.partial(utool.inject_instance, classkey=ABSTRACT_VIEW_INJECT_KEY)


VALID_API_MODELS = (FilterProxyModel, StripeProxyModel, APIItemModel)


class APIItemView(API_VIEW_BASE):
    """
    Trees and Tables implicitly inherit from this class.
    Abstractish class.

    other function in this file will be injected into the concrete
    implementations of either a table or tree view. The code is only written
    once but duplicated in each of the psuedo-children. It is done this way to
Beispiel #8
0
def report_memory(obj, objname='obj'):
    """
    obj = invindex
    objname = 'invindex'

    """
    print('Object Memory Usage for %s' % objname)
    maxlen = max(map(len, six.iterkeys(obj.__dict__)))
    for key, val in six.iteritems(obj.__dict__):
        fmtstr = 'memusage({0}.{1}){2} = '
        lbl = fmtstr.format(objname, key, ' ' * (maxlen - len(key)))
        sizestr = ut.get_object_size_str(val, lbl=lbl, unit='MB')
        print(sizestr)


report_memsize = ut.make_class_method_decorator(INVERTED_INDEX_INJECT_KEY)(
    ut.report_memsize)

QueryIndex = namedtuple('QueryIndex', (
    'wx2_qrvecs',
    'wx2_qflags',
    'wx2_maws',
    'wx2_qaids',
    'wx2_qfxs',
    'query_sccw',
))


class LazyGetter(object):
    """
    DEPRICATE
    """