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


Python numpy._NoValue方法代碼示例

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


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

示例1: unreduce_array

# 需要導入模塊: import numpy [as 別名]
# 或者: from numpy import _NoValue [as 別名]
def unreduce_array(array, shape, axis, keepdims):
  """Reverse summing over a dimension, NumPy implementation.

  Args:
    array: The array that was reduced.
    shape: The original shape of the array before reduction.
    axis: The axis or axes that were summed.
    keepdims: Whether these axes were kept as singleton axes.

  Returns:
    An array with axes broadcast to match the shape of the original array.
  """
  # NumPy uses a special default value for keepdims, which is equivalent to
  # False.
  if axis is not None and (not keepdims or keepdims is numpy._NoValue):  # pylint: disable=protected-access
    if isinstance(axis, int):
      axis = axis,
    for ax in sorted(axis):
      array = numpy.expand_dims(array, ax)
  return numpy.broadcast_to(array, shape)


# The values are unary functions. 
開發者ID:google,項目名稱:tangent,代碼行數:25,代碼來源:utils.py

示例2: test_numpy_reloading

# 需要導入模塊: import numpy [as 別名]
# 或者: from numpy import _NoValue [as 別名]
def test_numpy_reloading():
    # gh-7844. Also check that relevant globals retain their identity.
    import numpy as np
    import numpy._globals

    _NoValue = np._NoValue
    VisibleDeprecationWarning = np.VisibleDeprecationWarning
    ModuleDeprecationWarning = np.ModuleDeprecationWarning

    reload(np)
    assert_(_NoValue is np._NoValue)
    assert_(ModuleDeprecationWarning is np.ModuleDeprecationWarning)
    assert_(VisibleDeprecationWarning is np.VisibleDeprecationWarning)

    assert_raises(RuntimeError, reload, numpy._globals)
    reload(np)
    assert_(_NoValue is np._NoValue)
    assert_(ModuleDeprecationWarning is np.ModuleDeprecationWarning)
    assert_(VisibleDeprecationWarning is np.VisibleDeprecationWarning) 
開發者ID:Frank-qlu,項目名稱:recruit,代碼行數:21,代碼來源:test_reloading.py

示例3: _nanquantile_unchecked

# 需要導入模塊: import numpy [as 別名]
# 或者: from numpy import _NoValue [as 別名]
def _nanquantile_unchecked(a, q, axis=None, out=None, overwrite_input=False,
                           interpolation='linear', keepdims=np._NoValue):
    """Assumes that q is in [0, 1], and is an ndarray"""
    # apply_along_axis in _nanpercentile doesn't handle empty arrays well,
    # so deal them upfront
    if a.size == 0:
        return np.nanmean(a, axis, out=out, keepdims=keepdims)

    r, k = function_base._ureduce(
        a, func=_nanquantile_ureduce_func, q=q, axis=axis, out=out,
        overwrite_input=overwrite_input, interpolation=interpolation
    )
    if keepdims and keepdims is not np._NoValue:
        return r.reshape(q.shape + k)
    else:
        return r 
開發者ID:Frank-qlu,項目名稱:recruit,代碼行數:18,代碼來源:nanfunctions.py

示例4: _wrapreduction

# 需要導入模塊: import numpy [as 別名]
# 或者: from numpy import _NoValue [as 別名]
def _wrapreduction(obj, ufunc, method, axis, dtype, out, **kwargs):
    passkwargs = {k: v for k, v in kwargs.items()
                  if v is not np._NoValue}

    if type(obj) is not mu.ndarray:
        try:
            reduction = getattr(obj, method)
        except AttributeError:
            pass
        else:
            # This branch is needed for reductions like any which don't
            # support a dtype.
            if dtype is not None:
                return reduction(axis=axis, dtype=dtype, out=out, **passkwargs)
            else:
                return reduction(axis=axis, out=out, **passkwargs)

    return ufunc.reduce(obj, axis, dtype, out, **passkwargs) 
開發者ID:Frank-qlu,項目名稱:recruit,代碼行數:20,代碼來源:fromnumeric.py

示例5: _wrapreduction

# 需要導入模塊: import numpy [as 別名]
# 或者: from numpy import _NoValue [as 別名]
def _wrapreduction(obj, ufunc, method, axis, dtype, out, **kwargs):
    passkwargs = {}
    for k, v in kwargs.items():
        if v is not np._NoValue:
            passkwargs[k] = v

    if type(obj) is not mu.ndarray:
        try:
            reduction = getattr(obj, method)
        except AttributeError:
            pass
        else:
            # This branch is needed for reductions like any which don't
            # support a dtype.
            if dtype is not None:
                return reduction(axis=axis, dtype=dtype, out=out, **passkwargs)
            else:
                return reduction(axis=axis, out=out, **passkwargs)

    return ufunc.reduce(obj, axis, dtype, out, **passkwargs) 
開發者ID:ryfeus,項目名稱:lambda-packs,代碼行數:22,代碼來源:fromnumeric.py

示例6: sometrue

# 需要導入模塊: import numpy [as 別名]
# 或者: from numpy import _NoValue [as 別名]
def sometrue(a, axis=None, out=None, keepdims=np._NoValue):
    """
    Check whether some values are true.

    Refer to `any` for full documentation.

    See Also
    --------
    any : equivalent function

    """
    arr = asanyarray(a)
    kwargs = {}
    if keepdims is not np._NoValue:
        kwargs['keepdims'] = keepdims
    return arr.any(axis=axis, out=out, **kwargs) 
開發者ID:abhisuri97,項目名稱:auto-alt-text-lambda-api,代碼行數:18,代碼來源:fromnumeric.py


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