当前位置: 首页>>代码示例>>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;未经允许,请勿转载。