當前位置: 首頁>>代碼示例>>Python>>正文


Python builtins.range方法代碼示例

本文整理匯總了Python中builtins.range方法的典型用法代碼示例。如果您正苦於以下問題:Python builtins.range方法的具體用法?Python builtins.range怎麽用?Python builtins.range使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在builtins的用法示例。


在下文中一共展示了builtins.range方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: _coco_results_one_category

# 需要導入模塊: import builtins [as 別名]
# 或者: from builtins import range [as 別名]
def _coco_results_one_category(self, boxes, cat_id):
        results = []
        for im_ind, roi_rec in enumerate(self.roidb):
            index = roi_rec['index']
            dets = boxes[im_ind].astype(np.float)
            if len(dets) == 0:
                continue
            scores = dets[:, -1]
            xs = dets[:, 0]
            ys = dets[:, 1]
            ws = dets[:, 2] - xs + 1
            hs = dets[:, 3] - ys + 1
            result = [{'image_id': index,
                       'category_id': cat_id,
                       'bbox': [xs[k], ys[k], ws[k], hs[k]],
                       'score': scores[k]} for k in range(dets.shape[0])]
            results.extend(result)
        return results 
開發者ID:awslabs,項目名稱:dynamic-training-with-apache-mxnet-on-aws,代碼行數:20,代碼來源:coco.py

示例2: issubset

# 需要導入模塊: import builtins [as 別名]
# 或者: from builtins import range [as 別名]
def issubset(list1, list2):
    """
    Examples:

    >>> issubset([], [65, 66, 67])
    True
    >>> issubset([65], [65, 66, 67])
    True
    >>> issubset([65, 66], [65, 66, 67])
    True
    >>> issubset([65, 67], [65, 66, 67])
    False
    """
    n = len(list1)
    for startpos in range(len(list2) - n + 1):
        if list2[startpos:startpos+n] == list1:
            return True
    return False 
開發者ID:Soft8Soft,項目名稱:verge3d-blender-addon,代碼行數:20,代碼來源:__init__.py

示例3: test_boolean

# 需要導入模塊: import builtins [as 別名]
# 或者: from builtins import range [as 別名]
def test_boolean(self):
        x = Variable((5, 4))
        y = Boolean(5, 4)
        p = Problem(Minimize(sum(1-x) + sum(x)), [x == y])
        result = p.solve(method="NC-ADMM", solver=CVXOPT)
        self.assertAlmostEqual(result[0], 20)
        for i in range(x.shape[0]):
            for j in range(x.shape[1]):
                v = x.value[i, j]
                self.assertAlmostEqual(v*(1-v), 0)

        x = Variable()
        p = Problem(Minimize(sum(1-x) + sum(x)), [x == Boolean(5,4)[0,0]])
        result = p.solve(method="NC-ADMM", solver=CVXOPT)
        self.assertAlmostEqual(result[0], 1)
        self.assertAlmostEqual(x.value*(1-x.value), 0)

    # Test choose variable. 
開發者ID:cvxgrp,項目名稱:ncvx,代碼行數:20,代碼來源:test_vars.py

示例4: test_card

# 需要導入模塊: import builtins [as 別名]
# 或者: from builtins import range [as 別名]
def test_card(self):
        x = Card(5, k=3, M=1)
        p = Problem(Maximize(cp.sum(x)),
            [x <= 1, x >= 0])
        result = p.solve(method="NC-ADMM")
        self.assertAlmostEqual(result[0], 3)
        for v in np.nditer(x.value):
            self.assertAlmostEqual(v*(1-v), 0)
        self.assertAlmostEqual(x.value.sum(), 3)

        #should be equivalent to x == choose
        x = Variable((5, 4))
        c = Choose(5, 4, k=4)
        b = Boolean(5, 4)
        p = Problem(Minimize(sum(1-x) + sum(x)),
                    [x == c, x == b])
        result = p.solve(method="NC-ADMM", solver=CVXOPT)
        self.assertAlmostEqual(result[0], 20)
        for i in range(x.shape[0]):
            for j in range(x.shape[1]):
                v = x.value[i, j]
                self.assertAlmostEqual(v*(1-v), 0)

    # Test permutation variable. 
開發者ID:cvxgrp,項目名稱:ncvx,代碼行數:26,代碼來源:test_vars.py

示例5: drawTextMode

# 需要導入模塊: import builtins [as 別名]
# 或者: from builtins import range [as 別名]
def drawTextMode(self, qp):
        log.debug('OFFSET %s', self.dataModel.getOffset())
        # draw background
        qp.fillRect(0, 0, self.COLUMNS * self.fontWidth, self.ROWS * self.fontHeight, self.backgroundBrush)

        # set text pen&font
        qp.setFont(self.font)
        qp.setPen(self.textPen)

        cemu = ConsoleEmulator(qp, self.ROWS, self.COLUMNS)

        offset = 0
        for i in range(self.ROWS):
            if i < len(self.OPCODES):
                asm = self.OPCODES[i]
                self._drawRow(qp, cemu, i, asm, offset)
                offset += asm.get_length() 
開發者ID:amimo,項目名稱:dcc,代碼行數:19,代碼來源:DisasmViewMode.py

示例6: decorate

# 需要導入模塊: import builtins [as 別名]
# 或者: from builtins import range [as 別名]
def decorate(self, pageOffset=None):
        page = self.decorated.decorate(pageOffset)

        self.PenInterval = self.decorated.PenInterval
        self.brushMap = self.decorated.brushMap
        self.penMap = self.decorated.penMap

        off = self.dataModel.getOffset()

        Match = [(m.start(), m.end()) for m in re.finditer(b'([a-zA-Z0-9\\-\\\\.%*:/? _<>]){4,}', page)]
        for s, e in Match:
            for i in range(e - s):
                idx = off + s + i
                if idx not in self.penMap:
                    self.penMap[off + s + i] = self.redPen

        self.page = page
        return self.page 
開發者ID:amimo,項目名稱:dcc,代碼行數:20,代碼來源:TextDecorators.py

示例7: highliteWithPrefix

# 需要導入模塊: import builtins [as 別名]
# 或者: from builtins import range [as 別名]
def highliteWithPrefix(self, page, text, additionalLength=0, brush=None, pen=None):

        # todo: nu am gasit o metoda mai eleganta pentru a selecta toate aparitiile ale lui text
        # regexp nu merg, "bad re expression"
        lenText = len(text)
        M = []
        idx = 0
        if lenText > 0:
            while idx < len(page):
                idx = page.find(text, idx, len(page))

                if idx == -1:
                    break

                M.append((idx, lenText + additionalLength))
                idx += lenText + additionalLength

        off = self.dataModel.getOffset()
        for start, length in M:

            for i in range(length):
                self.penMap[off + start + i] = pen
                self.brushMap[off + start + i] = brush

        return page 
開發者ID:amimo,項目名稱:dcc,代碼行數:27,代碼來源:TextDecorators.py

示例8: __init__

# 需要導入模塊: import builtins [as 別名]
# 或者: from builtins import range [as 別名]
def __init__(self, graph, params):
        self.g = graph
        self.A = defaultdict(set)
        self.R = defaultdict(set)
        self.DB = defaultdict(set)
        self.defs = defaultdict(lambda: defaultdict(set))
        self.def_to_loc = defaultdict(set)
        # Deal with special entry node
        entry = graph.entry
        self.A[entry] = set(range(-1, -len(params) - 1, -1))
        for loc, param in enumerate(params, 1):
            self.defs[entry][param].add(-loc)
            self.def_to_loc[param].add(-loc)
        # Deal with the other nodes
        for node in graph.rpo:
            for i, ins in node.get_loc_with_ins():
                kill = ins.get_lhs()
                if kill is not None:
                    self.defs[node][kill].add(i)
                    self.def_to_loc[kill].add(i)
            for defs, values in self.defs[node].items():
                self.DB[node].add(max(values)) 
開發者ID:amimo,項目名稱:dcc,代碼行數:24,代碼來源:dataflow.py

示例9: invokeinterface

# 需要導入模塊: import builtins [as 別名]
# 或者: from builtins import range [as 別名]
def invokeinterface(ins, vmap, ret):
    logger.debug('InvokeInterface : %s', ins.get_output())
    method = ins.cm.get_method_ref(ins.BBBB)
    cls_name = util.get_type(method.get_class_name())
    name = method.get_name()
    param_type, ret_type = method.get_proto()
    param_type = util.get_params_type(param_type)
    largs = [ins.D, ins.E, ins.F, ins.G]
    args = get_args(vmap, param_type, largs)
    c = get_variables(vmap, ins.C)
    returned = None if ret_type == 'V' else ret.new()
    exp = InvokeInstruction(cls_name, name, c, ret_type, param_type, args,
                            method.get_triple())
    return AssignExpression(returned, exp)


# invoke-virtual/range {vCCCC..vNNNN} ( 16b each ) 
開發者ID:amimo,項目名稱:dcc,代碼行數:19,代碼來源:opcode_ins.py

示例10: invokevirtualrange

# 需要導入模塊: import builtins [as 別名]
# 或者: from builtins import range [as 別名]
def invokevirtualrange(ins, vmap, ret):
    logger.debug('InvokeVirtualRange : %s', ins.get_output())
    method = ins.cm.get_method_ref(ins.BBBB)
    cls_name = util.get_type(method.get_class_name())
    name = method.get_name()
    param_type, ret_type = method.get_proto()
    param_type = util.get_params_type(param_type)
    largs = list(range(ins.CCCC, ins.NNNN + 1))
    this_arg = get_variables(vmap, largs[0])
    args = get_args(vmap, param_type, largs[1:])
    returned = None if ret_type == 'V' else ret.new()
    exp = InvokeRangeInstruction(cls_name, name, ret_type, param_type,
                                 [this_arg] + args, method.get_triple())
    return AssignExpression(returned, exp)


# invoke-super/range {vCCCC..vNNNN} ( 16b each ) 
開發者ID:amimo,項目名稱:dcc,代碼行數:19,代碼來源:opcode_ins.py

示例11: invokedirectrange

# 需要導入模塊: import builtins [as 別名]
# 或者: from builtins import range [as 別名]
def invokedirectrange(ins, vmap, ret):
    logger.debug('InvokeDirectRange : %s', ins.get_output())
    method = ins.cm.get_method_ref(ins.BBBB)
    cls_name = util.get_type(method.get_class_name())
    name = method.get_name()
    param_type, ret_type = method.get_proto()
    param_type = util.get_params_type(param_type)
    largs = list(range(ins.CCCC, ins.NNNN + 1))
    this_arg = get_variables(vmap, largs[0])
    args = get_args(vmap, param_type, largs[1:])
    base = get_variables(vmap, ins.CCCC)
    if ret_type != 'V':
        returned = ret.new()
    else:
        returned = base
        ret.set_to(base)
    exp = InvokeRangeInstruction(cls_name, name, ret_type, param_type,
                                 [this_arg] + args, method.get_triple())
    return AssignExpression(returned, exp)


# invoke-static/range {vCCCC..vNNNN} ( 16b each ) 
開發者ID:amimo,項目名稱:dcc,代碼行數:24,代碼來源:opcode_ins.py

示例12: invokestaticrange

# 需要導入模塊: import builtins [as 別名]
# 或者: from builtins import range [as 別名]
def invokestaticrange(ins, vmap, ret):
    logger.debug('InvokeStaticRange : %s', ins.get_output())
    method = ins.cm.get_method_ref(ins.BBBB)
    cls_name = util.get_type(method.get_class_name())
    name = method.get_name()
    param_type, ret_type = method.get_proto()
    param_type = util.get_params_type(param_type)
    largs = list(range(ins.CCCC, ins.NNNN + 1))
    args = get_args(vmap, param_type, largs)
    base = BaseClass(cls_name, descriptor=method.get_class_name())
    returned = None if ret_type == 'V' else ret.new()
    exp = InvokeStaticInstruction(cls_name, name, base, ret_type, param_type,
                                  args, method.get_triple())
    return AssignExpression(returned, exp)


# invoke-interface/range {vCCCC..vNNNN} ( 16b each ) 
開發者ID:amimo,項目名稱:dcc,代碼行數:19,代碼來源:opcode_ins.py

示例13: invokeinterfacerange

# 需要導入模塊: import builtins [as 別名]
# 或者: from builtins import range [as 別名]
def invokeinterfacerange(ins, vmap, ret):
    logger.debug('InvokeInterfaceRange : %s', ins.get_output())
    method = ins.cm.get_method_ref(ins.BBBB)
    cls_name = util.get_type(method.get_class_name())
    name = method.get_name()
    param_type, ret_type = method.get_proto()
    param_type = util.get_params_type(param_type)
    largs = list(range(ins.CCCC, ins.NNNN + 1))
    base_arg = get_variables(vmap, largs[0])
    args = get_args(vmap, param_type, largs[1:])
    returned = None if ret_type == 'V' else ret.new()
    exp = InvokeRangeInstruction(cls_name, name, ret_type, param_type,
                                 [base_arg] + args, method.get_triple())
    return AssignExpression(returned, exp)


# neg-int vA, vB ( 4b, 4b ) 
開發者ID:amimo,項目名稱:dcc,代碼行數:19,代碼來源:opcode_ins.py

示例14: visit_fill_array

# 需要導入模塊: import builtins [as 別名]
# 或者: from builtins import range [as 別名]
def visit_fill_array(self, array, value):
        self.write_ind()
        array.visit(self)
        self.write(' = {', data="ARRAY_FILLED")
        data = value.get_data()
        tab = []
        elem_size = value.element_width

        # Set type depending on size of elements
        data_types = {1: 'b', 2: 'h', 4: 'i', 8: 'd'}

        if elem_size in data_types:
            elem_id = data_types[elem_size]
        else:
            # FIXME for other types we just assume bytes...
            logger.warning("Unknown element size {} for array. Assume bytes.".format(elem_size))
            elem_id = 'b'
            elem_size = 1

        for i in range(0, value.size*elem_size, elem_size):
            tab.append('%s' % unpack(elem_id, data[i:i+elem_size])[0])
        self.write(', '.join(tab), data="COMMA")
        self.write('}', data="ARRAY_FILLED_END")
        self.end_ins() 
開發者ID:amimo,項目名稱:dcc,代碼行數:26,代碼來源:writer.py

示例15: _find_class

# 需要導入模塊: import builtins [as 別名]
# 或者: from builtins import range [as 別名]
def _find_class(self, clname, basefolder):
        # check if defpackage
        if "/" not in clname:
            # this is a defpackage class probably...
            # Search first for defpackage, then search for requested string
            res = self._find_class("defpackage/{}".format(clname), basefolder)
            if res:
                return res

        # We try to map inner classes here
        if "$" in clname:
            # sometimes the inner class get's an extra file, sometimes not...
            # So we try all possibilities
            for x in range(clname.count("$")):
                tokens = clname.split("$", x + 1)
                base = "$".join(tokens[:-1])
                res = self._find_class(base, basefolder)
                if res:
                    return res

        # Check the whole supplied name
        fname = os.path.join(basefolder, clname.replace("/", os.sep) + ".java")
        if not os.path.isfile(fname):
            return None
        return fname 
開發者ID:amimo,項目名稱:dcc,代碼行數:27,代碼來源:decompiler.py


注:本文中的builtins.range方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。