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


Python builtins.zip方法代码示例

本文整理汇总了Python中future.builtins.zip方法的典型用法代码示例。如果您正苦于以下问题:Python builtins.zip方法的具体用法?Python builtins.zip怎么用?Python builtins.zip使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在future.builtins的用法示例。


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

示例1: _ascii_split

# 需要导入模块: from future import builtins [as 别名]
# 或者: from future.builtins import zip [as 别名]
def _ascii_split(self, fws, string, splitchars):
        # The RFC 2822 header folding algorithm is simple in principle but
        # complex in practice.  Lines may be folded any place where "folding
        # white space" appears by inserting a linesep character in front of the
        # FWS.  The complication is that not all spaces or tabs qualify as FWS,
        # and we are also supposed to prefer to break at "higher level
        # syntactic breaks".  We can't do either of these without intimate
        # knowledge of the structure of structured headers, which we don't have
        # here.  So the best we can do here is prefer to break at the specified
        # splitchars, and hope that we don't choose any spaces or tabs that
        # aren't legal FWS.  (This is at least better than the old algorithm,
        # where we would sometimes *introduce* FWS after a splitchar, or the
        # algorithm before that, where we would turn all white space runs into
        # single spaces or tabs.)
        parts = re.split("(["+FWS+"]+)", fws+string)
        if parts[0]:
            parts[:0] = ['']
        else:
            parts.pop(0)
        for fws, part in zip(*[iter(parts)]*2):
            self._append_chunk(fws, part) 
开发者ID:Soft8Soft,项目名称:verge3d-blender-addon,代码行数:23,代码来源:header.py

示例2: replace_header

# 需要导入模块: from future import builtins [as 别名]
# 或者: from future.builtins import zip [as 别名]
def replace_header(self, _name, _value):
        """Replace a header.

        Replace the first matching header found in the message, retaining
        header order and case.  If no matching header was found, a KeyError is
        raised.
        """
        _name = _name.lower()
        for i, (k, v) in zip(range(len(self._headers)), self._headers):
            if k.lower() == _name:
                self._headers[i] = self.policy.header_store_parse(k, _value)
                break
        else:
            raise KeyError(_name)

    #
    # Use these three methods instead of the three above.
    # 
开发者ID:Soft8Soft,项目名称:verge3d-blender-addon,代码行数:20,代码来源:message.py

示例3: test_handled

# 需要导入模块: from future import builtins [as 别名]
# 或者: from future.builtins import zip [as 别名]
def test_handled(self):
        # handler returning non-None means no more handlers will be called
        o = OpenerDirector()
        meth_spec = [
            ["http_open", "ftp_open", "http_error_302"],
            ["ftp_open"],
            [("http_open", "return self")],
            [("http_open", "return self")],
            ]
        handlers = add_ordered_mock_handlers(o, meth_spec)

        req = Request("http://example.com/")
        r = o.open(req)
        # Second .http_open() gets called, third doesn't, since second returned
        # non-None.  Handlers without .http_open() never get any methods called
        # on them.
        # In fact, second mock handler defining .http_open() returns self
        # (instead of response), which becomes the OpenerDirector's return
        # value.
        self.assertEqual(r, handlers[2])
        calls = [(handlers[0], "http_open"), (handlers[2], "http_open")]
        for expected, got in zip(calls, o.calls):
            handler, name, args, kwds = got
            self.assertEqual((handler, name), expected)
            self.assertEqual(args, (req,)) 
开发者ID:hughperkins,项目名称:kgsgo-dataset-preprocessor,代码行数:27,代码来源:test_urllib2.py

示例4: state_to_rectangle

# 需要导入模块: from future import builtins [as 别名]
# 或者: from future.builtins import zip [as 别名]
def state_to_rectangle(self, states):
        """Convert physical states to its closest rectangle index.

        Parameters
        ----------
        states : ndarray
            Physical states on the discretization.

        Returns
        -------
        rectangles : ndarray (int)
            The indices that correspond to rectangles of the physical states.

        """
        ind = []
        for i, (discrete, num_points) in enumerate(zip(self.discrete_points,
                                                       self.num_points)):
            idx = np.digitize(states[:, i], discrete)
            idx -= 1
            np.clip(idx, 0, num_points - 2, out=idx)

            ind.append(idx)
        return np.ravel_multi_index(ind, self.num_points - 1) 
开发者ID:befelix,项目名称:safe_learning,代码行数:25,代码来源:functions.py

示例5: add_weight_constraint

# 需要导入模块: from future import builtins [as 别名]
# 或者: from future.builtins import zip [as 别名]
def add_weight_constraint(optimization, var_list, bound_list):
    """Add weight constraints to an optimization step.

    Parameters
    ----------
    optimization : tf.Tensor
        The optimization routine that updates the parameters.
    var_list : list
        A list of variables that should be bounded.
    bound_list : list
        A list of bounds (lower, upper) for each variable in var_list.

    Returns
    -------
    assign_operations : list
        A list of assign operations that correspond to one step of the
        constrained optimization.
    """
    with tf.control_dependencies([optimization]):
        new_list = []
        for var, bound in zip(var_list, bound_list):
            clipped_var = tf.clip_by_value(var, bound[0], bound[1])
            assign = tf.assign(var, clipped_var)
            new_list.append(assign)
    return new_list 
开发者ID:befelix,项目名称:safe_learning,代码行数:27,代码来源:utilities.py

示例6: eval_logic_groups_to_bool

# 需要导入模块: from future import builtins [as 别名]
# 或者: from future.builtins import zip [as 别名]
def eval_logic_groups_to_bool(logic_groups, eval_conds):
    first_cond = logic_groups[0]

    if isinstance(first_cond, list):
        result = eval_logic_groups_to_bool(first_cond, eval_conds)
    else:
        result = eval_conds[first_cond]

    for op, cond in zip(logic_groups[1::2], logic_groups[2::2]):
        if isinstance(cond, list):
            eval_cond = eval_logic_groups_to_bool(cond, eval_conds)
        else:
            eval_cond = eval_conds[cond]

        if op == 'and':
            result = result and eval_cond
        elif op == 'or':
            result = result or eval_cond

    return result 
开发者ID:Tautulli,项目名称:Tautulli,代码行数:22,代码来源:helpers.py


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