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


Python __builtin__.all方法代碼示例

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


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

示例1: load

# 需要導入模塊: import __builtin__ [as 別名]
# 或者: from __builtin__ import all [as 別名]
def load(file):
    """
    Wrapper around cPickle.load which accepts either a file-like object or
    a filename.

    Note that the NumPy binary format is not based on pickle/cPickle anymore.
    For details on the preferred way of loading and saving files, see `load`
    and `save`.

    See Also
    --------
    load, save

    """
    if isinstance(file, type("")):
        file = open(file, "rb")
    return pickle.load(file)

# These are all essentially abbreviations
# These might wind up in a special abbreviations module 
開發者ID:abhisuri97,項目名稱:auto-alt-text-lambda-api,代碼行數:22,代碼來源:numeric.py

示例2: __init__

# 需要導入模塊: import __builtin__ [as 別名]
# 或者: from __builtin__ import all [as 別名]
def __init__(self):
        # The tree, which should be built.
        self._tree = []

        # List of all open constructs
        self._open_blocks = []

        # Nodes to which the open blocks have to be appended when closed
        self._path = []

        # Nr. of open blocks when file was opened. Used for checking whether all
        # blocks have been closed, when file processing finishes.
        self._nr_prev_blocks = []

        # Current node, to which content should be added
        self._curnode = self._tree

        # Current file
        self._curfile = None 
開發者ID:aradi,項目名稱:fypp,代碼行數:21,代碼來源:fypp.py

示例3: _validate_axis

# 需要導入模塊: import __builtin__ [as 別名]
# 或者: from __builtin__ import all [as 別名]
def _validate_axis(axis, ndim, argname):
    try:
        axis = [operator.index(axis)]
    except TypeError:
        axis = list(axis)
    axis = [a + ndim if a < 0 else a for a in axis]
    if not builtins.all(0 <= a < ndim for a in axis):
        raise ValueError('invalid axis for this array in `%s` argument' %
                         argname)
    if len(set(axis)) != len(axis):
        raise ValueError('repeated axis in `%s` argument' % argname)
    return axis 
開發者ID:abhisuri97,項目名稱:auto-alt-text-lambda-api,代碼行數:14,代碼來源:numeric.py

示例4: _maketup

# 需要導入模塊: import __builtin__ [as 別名]
# 或者: from __builtin__ import all [as 別名]
def _maketup(descr, val):
    dt = dtype(descr)
    # Place val in all scalar tuples:
    fields = dt.fields
    if fields is None:
        return val
    else:
        res = [_maketup(fields[name][0], val) for name in dt.names]
        return tuple(res) 
開發者ID:abhisuri97,項目名稱:auto-alt-text-lambda-api,代碼行數:11,代碼來源:numeric.py

示例5: identity

# 需要導入模塊: import __builtin__ [as 別名]
# 或者: from __builtin__ import all [as 別名]
def identity(n, dtype=None):
    """
    Return the identity array.

    The identity array is a square array with ones on
    the main diagonal.

    Parameters
    ----------
    n : int
        Number of rows (and columns) in `n` x `n` output.
    dtype : data-type, optional
        Data-type of the output.  Defaults to ``float``.

    Returns
    -------
    out : ndarray
        `n` x `n` array with its main diagonal set to one,
        and all other elements 0.

    Examples
    --------
    >>> np.identity(3)
    array([[ 1.,  0.,  0.],
           [ 0.,  1.,  0.],
           [ 0.,  0.,  1.]])

    """
    from numpy import eye
    return eye(n, dtype=dtype) 
開發者ID:abhisuri97,項目名稱:auto-alt-text-lambda-api,代碼行數:32,代碼來源:numeric.py

示例6: array_equal

# 需要導入模塊: import __builtin__ [as 別名]
# 或者: from __builtin__ import all [as 別名]
def array_equal(a1, a2):
    """
    True if two arrays have the same shape and elements, False otherwise.

    Parameters
    ----------
    a1, a2 : array_like
        Input arrays.

    Returns
    -------
    b : bool
        Returns True if the arrays are equal.

    See Also
    --------
    allclose: Returns True if two arrays are element-wise equal within a
              tolerance.
    array_equiv: Returns True if input arrays are shape consistent and all
                 elements equal.

    Examples
    --------
    >>> np.array_equal([1, 2], [1, 2])
    True
    >>> np.array_equal(np.array([1, 2]), np.array([1, 2]))
    True
    >>> np.array_equal([1, 2], [1, 2, 3])
    False
    >>> np.array_equal([1, 2], [1, 4])
    False

    """
    try:
        a1, a2 = asarray(a1), asarray(a2)
    except:
        return False
    if a1.shape != a2.shape:
        return False
    return bool(asarray(a1 == a2).all()) 
開發者ID:abhisuri97,項目名稱:auto-alt-text-lambda-api,代碼行數:42,代碼來源:numeric.py

示例7: any

# 需要導入模塊: import __builtin__ [as 別名]
# 或者: from __builtin__ import all [as 別名]
def any(items):
        for item in items:
            if item:
                return True
        return False

# ---all() from Python 2.5 --- 
開發者ID:Yukinoshita47,項目名稱:Yuki-Chan-The-Auto-Pentest,代碼行數:9,代碼來源:compatibility.py

示例8: all

# 需要導入模塊: import __builtin__ [as 別名]
# 或者: from __builtin__ import all [as 別名]
def all(items):
        return reduce(operator.__and__, items)

# --- test if interpreter supports yield keyword --- 
開發者ID:Yukinoshita47,項目名稱:Yuki-Chan-The-Auto-Pentest,代碼行數:6,代碼來源:compatibility.py

示例9: all

# 需要導入模塊: import __builtin__ [as 別名]
# 或者: from __builtin__ import all [as 別名]
def all(items):
        return reduce(operator.__and__, items) 
開發者ID:tuwid,項目名稱:darkc0de-old-stuff,代碼行數:4,代碼來源:compatibility.py

示例10: geterr

# 需要導入模塊: import __builtin__ [as 別名]
# 或者: from __builtin__ import all [as 別名]
def geterr():
    """
    Get the current way of handling floating-point errors.

    Returns
    -------
    res : dict
        A dictionary with keys "divide", "over", "under", and "invalid",
        whose values are from the strings "ignore", "print", "log", "warn",
        "raise", and "call". The keys represent possible floating-point
        exceptions, and the values define how these exceptions are handled.

    See Also
    --------
    geterrcall, seterr, seterrcall

    Notes
    -----
    For complete documentation of the types of floating-point exceptions and
    treatment options, see `seterr`.

    Examples
    --------
    >>> np.geterr()
    {'over': 'warn', 'divide': 'warn', 'invalid': 'warn',
    'under': 'ignore'}
    >>> np.arange(3.) / np.arange(3.)
    array([ NaN,   1.,   1.])

    >>> oldsettings = np.seterr(all='warn', over='raise')
    >>> np.geterr()
    {'over': 'raise', 'divide': 'warn', 'invalid': 'warn', 'under': 'warn'}
    >>> np.arange(3.) / np.arange(3.)
    __main__:1: RuntimeWarning: invalid value encountered in divide
    array([ NaN,   1.,   1.])

    """
    maskvalue = umath.geterrobj()[1]
    mask = 7
    res = {}
    val = (maskvalue >> SHIFT_DIVIDEBYZERO) & mask
    res['divide'] = _errdict_rev[val]
    val = (maskvalue >> SHIFT_OVERFLOW) & mask
    res['over'] = _errdict_rev[val]
    val = (maskvalue >> SHIFT_UNDERFLOW) & mask
    res['under'] = _errdict_rev[val]
    val = (maskvalue >> SHIFT_INVALID) & mask
    res['invalid'] = _errdict_rev[val]
    return res 
開發者ID:abhisuri97,項目名稱:auto-alt-text-lambda-api,代碼行數:51,代碼來源:numeric.py

示例11: geterrcall

# 需要導入模塊: import __builtin__ [as 別名]
# 或者: from __builtin__ import all [as 別名]
def geterrcall():
    """
    Return the current callback function used on floating-point errors.

    When the error handling for a floating-point error (one of "divide",
    "over", "under", or "invalid") is set to 'call' or 'log', the function
    that is called or the log instance that is written to is returned by
    `geterrcall`. This function or log instance has been set with
    `seterrcall`.

    Returns
    -------
    errobj : callable, log instance or None
        The current error handler. If no handler was set through `seterrcall`,
        ``None`` is returned.

    See Also
    --------
    seterrcall, seterr, geterr

    Notes
    -----
    For complete documentation of the types of floating-point exceptions and
    treatment options, see `seterr`.

    Examples
    --------
    >>> np.geterrcall()  # we did not yet set a handler, returns None

    >>> oldsettings = np.seterr(all='call')
    >>> def err_handler(type, flag):
    ...     print("Floating point error (%s), with flag %s" % (type, flag))
    >>> oldhandler = np.seterrcall(err_handler)
    >>> np.array([1, 2, 3]) / 0.0
    Floating point error (divide by zero), with flag 1
    array([ Inf,  Inf,  Inf])

    >>> cur_handler = np.geterrcall()
    >>> cur_handler is err_handler
    True

    """
    return umath.geterrobj()[2] 
開發者ID:abhisuri97,項目名稱:auto-alt-text-lambda-api,代碼行數:45,代碼來源:numeric.py


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