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


Python builtins.reversed方法代码示例

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


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

示例1: evaluate_operation

# 需要导入模块: import builtins [as 别名]
# 或者: from builtins import reversed [as 别名]
def evaluate_operation(cls, operation, context, **kwargs):
        """
        Evaluate an operation or constant given a context.
        """
        try:
            if isinstance(operation, Operation):
                return operation.evaluate(context, **kwargs)
            partial = functools.partial(cls.evaluate_operation, context=context, **kwargs)
            if isinstance(operation, tuple):
                return tuple(partial(element) for element in operation)
            if isinstance(operation, list):
                return [partial(element) for element in operation]
            if isinstance(operation, dict):
                return {partial(key): partial(value) for key, value in operation.items()}
            if isinstance(operation, slice):
                return slice(*[partial(getattr(operation, attr))
                               for attr in ['start', 'stop', 'step']])
            return operation
        except Exception as ex:  # pragma: no cover
            stack = []
            interactive = False
            for frame in reversed(operation._stack):  # pylint: disable=protected-access
                # Do not capture any internal stack traces
                if 'pythonflow' in frame.filename:
                    continue
                # Stop tracing at the last interactive cell
                if interactive and not frame.filename.startswith('<'):
                    break  # pragma: no cover
                interactive = frame.filename.startswith('<')
                stack.append(frame)

            stack = "".join(traceback.format_list(reversed(stack)))
            message = "Failed to evaluate operation `%s` defined at:\n\n%s" % (operation, stack)
            raise ex from EvaluationError(message) 
开发者ID:spotify,项目名称:pythonflow,代码行数:36,代码来源:core.py

示例2: __reversed__

# 需要导入模块: import builtins [as 别名]
# 或者: from builtins import reversed [as 别名]
def __reversed__(self):
            return _coconut.reversed(self._xrange) 
开发者ID:evhub,项目名称:pyprover,代码行数:4,代码来源:__coconut__.py

示例3: _coconut_back_compose

# 需要导入模块: import builtins [as 别名]
# 或者: from builtins import reversed [as 别名]
def _coconut_back_compose(*funcs): return _coconut_forward_compose(*_coconut.reversed(funcs)) 
开发者ID:evhub,项目名称:pyprover,代码行数:3,代码来源:__coconut__.py

示例4: _coconut_back_star_compose

# 需要导入模块: import builtins [as 别名]
# 或者: from builtins import reversed [as 别名]
def _coconut_back_star_compose(*funcs): return _coconut_forward_star_compose(*_coconut.reversed(funcs)) 
开发者ID:evhub,项目名称:pyprover,代码行数:3,代码来源:__coconut__.py

示例5: _coconut_back_dubstar_compose

# 需要导入模块: import builtins [as 别名]
# 或者: from builtins import reversed [as 别名]
def _coconut_back_dubstar_compose(*funcs): return _coconut_forward_dubstar_compose(*_coconut.reversed(funcs)) 
开发者ID:evhub,项目名称:pyprover,代码行数:3,代码来源:__coconut__.py

示例6: __new__

# 需要导入模块: import builtins [as 别名]
# 或者: from builtins import reversed [as 别名]
def __new__(cls, iterable):
        if _coconut.isinstance(iterable, _coconut.range):
            return iterable[::-1]
        if not _coconut.hasattr(iterable, "__reversed__") or _coconut.isinstance(iterable, (_coconut.list, _coconut.tuple)):
            return _coconut.object.__new__(cls)
        return _coconut.reversed(iterable) 
开发者ID:evhub,项目名称:pyprover,代码行数:8,代码来源:__coconut__.py

示例7: __repr__

# 需要导入模块: import builtins [as 别名]
# 或者: from builtins import reversed [as 别名]
def __repr__(self):
        return "reversed(%r)" % (self.iter,) 
开发者ID:evhub,项目名称:pyprover,代码行数:4,代码来源:__coconut__.py

示例8: count

# 需要导入模块: import builtins [as 别名]
# 或者: from builtins import reversed [as 别名]
def count(self, elem):
        """Count the number of times elem appears in the reversed iterator."""
        return self.iter.count(elem) 
开发者ID:evhub,项目名称:pyprover,代码行数:5,代码来源:__coconut__.py

示例9: index

# 需要导入模块: import builtins [as 别名]
# 或者: from builtins import reversed [as 别名]
def index(self, elem):
        """Find the index of elem in the reversed iterator."""
        return _coconut.len(self.iter) - self.iter.index(elem) - 1 
开发者ID:evhub,项目名称:pyprover,代码行数:5,代码来源:__coconut__.py

示例10: __iter__

# 需要导入模块: import builtins [as 别名]
# 或者: from builtins import reversed [as 别名]
def __iter__(self):
        return _coconut.iter(_coconut.reversed(self.iter)) 
开发者ID:evhub,项目名称:pyprover,代码行数:4,代码来源:setup.py

示例11: reversed

# 需要导入模块: import builtins [as 别名]
# 或者: from builtins import reversed [as 别名]
def reversed(seq):
    '''Replacement for the built-in
    :func:`reversed() <python:reversed>` function.'''
    return builtins.reversed(seq) 
开发者ID:eth-cscs,项目名称:reframe,代码行数:6,代码来源:sanity.py

示例12: checkDesignMatrix

# 需要导入模块: import builtins [as 别名]
# 或者: from builtins import reversed [as 别名]
def checkDesignMatrix(X):
    """
       Parameters
       ----------
       X: a matrix of shape (T, N), where T denotes the number
           of samples and N labels the number of features.
           If T < N, a warning is issued to the user, and the transpose
           of X is considered instead.

       Returns:
       T: type int

       N: type int

       transpose_flag: type bool
           Specify if the design matrix X should be transposed
           in view of having less rows than columns.       
    """
    
    try:
        assert isinstance(X, (np.ndarray, pd.DataFrame, pd.Series,
                              MutableSequence, Sequence))
    except AssertionError:
        raise
        sys.exit(1)

    X = np.asarray(X, dtype=float)
    X = np.atleast_2d(X)

    if X.shape[0] < X.shape[1]:
        warnings.warn("The Marcenko-Pastur distribution pertains to "
                      "the empirical covariance matrix of a random matrix X "
                      "of shape (T, N). It is assumed that the number of "
                      "samples T is assumed higher than the number of "
                      "features N. The transpose of the matrix X submitted "
                      "at input will be considered in the cleaning schemes "
                      "for the corresponding correlation matrix.", UserWarning)
        
        T, N = reversed(X.shape)
        transpose_flag = True
    else:
        T, N = X.shape
        transpose_flag = False
        
    return T, N, transpose_flag 
开发者ID:GGiecold,项目名称:pyRMT,代码行数:47,代码来源:pyRMT.py


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