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