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


Python numeric.indices方法代码示例

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


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

示例1: choose

# 需要导入模块: from numpy.core import numeric [as 别名]
# 或者: from numpy.core.numeric import indices [as 别名]
def choose (indices, t, out=None, mode='raise'):
    "Returns array shaped like indices with elements chosen from t"
    def fmask (x):
        if x is masked: return 1
        return filled(x)
    def nmask (x):
        if x is masked: return 1
        m = getmask(x)
        if m is nomask: return 0
        return m
    c = filled(indices, 0)
    masks = [nmask(x) for x in t]
    a = [fmask(x) for x in t]
    d = numeric.choose(c, a)
    m = numeric.choose(c, masks)
    m = make_mask(mask_or(m, getmask(indices)), copy=0, flag=1)
    return masked_array(d, m) 
开发者ID:ktraunmueller,项目名称:Computable,代码行数:19,代码来源:ma.py

示例2: __next__

# 需要导入模块: from numpy.core import numeric [as 别名]
# 或者: from numpy.core.numeric import indices [as 别名]
def __next__(self):
        """
        Standard iterator method, returns the index tuple and array value.

        Returns
        -------
        coords : tuple of ints
            The indices of the current iteration.
        val : scalar
            The array element of the current iteration.

        """
        return self.iter.coords, next(self.iter) 
开发者ID:Frank-qlu,项目名称:recruit,代码行数:15,代码来源:index_tricks.py

示例3: diag_indices_from

# 需要导入模块: from numpy.core import numeric [as 别名]
# 或者: from numpy.core.numeric import indices [as 别名]
def diag_indices_from(arr):
    """
    Return the indices to access the main diagonal of an n-dimensional array.

    See `diag_indices` for full details.

    Parameters
    ----------
    arr : array, at least 2-D

    See Also
    --------
    diag_indices

    Notes
    -----
    .. versionadded:: 1.4.0

    """

    if not arr.ndim >= 2:
        raise ValueError("input array must be at least 2-d")
    # For more than d=2, the strided formula is only valid for arrays with
    # all dimensions equal, so we check first.
    if not alltrue(diff(arr.shape) == 0):
        raise ValueError("All dimensions of input must be of equal length")

    return diag_indices(arr.shape[0], arr.ndim) 
开发者ID:Frank-qlu,项目名称:recruit,代码行数:30,代码来源:index_tricks.py

示例4: __next__

# 需要导入模块: from numpy.core import numeric [as 别名]
# 或者: from numpy.core.numeric import indices [as 别名]
def __next__(self):
        """
        Standard iterator method, updates the index and returns the index
        tuple.

        Returns
        -------
        val : tuple of ints
            Returns a tuple containing the indices of the current
            iteration.

        """
        next(self._it)
        return self._it.multi_index 
开发者ID:ryfeus,项目名称:lambda-packs,代码行数:16,代码来源:index_tricks.py

示例5: nonzero

# 需要导入模块: from numpy.core import numeric [as 别名]
# 或者: from numpy.core.numeric import indices [as 别名]
def nonzero(a):
    """returns the indices of the elements of a which are not zero
    and not masked
    """
    return numeric.asarray(filled(a, 0).nonzero()) 
开发者ID:ktraunmueller,项目名称:Computable,代码行数:7,代码来源:ma.py

示例6: new_take

# 需要导入模块: from numpy.core import numeric [as 别名]
# 或者: from numpy.core.numeric import indices [as 别名]
def new_take (a, indices, axis=None, out=None, mode='raise'):
    "returns selection of items from a."
    m = getmask(a)
    # d = masked_array(a).raw_data()
    d = masked_array(a).data
    if m is nomask:
        return masked_array(numeric.take(d, indices, axis))
    else:
        return masked_array(numeric.take(d, indices, axis),
                     mask = numeric.take(m, indices, axis)) 
开发者ID:ktraunmueller,项目名称:Computable,代码行数:12,代码来源:ma.py

示例7: put

# 需要导入模块: from numpy.core import numeric [as 别名]
# 或者: from numpy.core.numeric import indices [as 别名]
def put(a, indices, values, mode='raise'):
    """sets storage-indexed locations to corresponding values.

    Values and indices are filled if necessary.

    """
    d = a.raw_data()
    ind = filled(indices)
    v = filled(values)
    numeric.put (d, ind, v)
    m = getmask(a)
    if m is not nomask:
        a.unshare_mask()
        numeric.put(a.raw_mask(), ind, 0) 
开发者ID:ktraunmueller,项目名称:Computable,代码行数:16,代码来源:ma.py

示例8: argsort

# 需要导入模块: from numpy.core import numeric [as 别名]
# 或者: from numpy.core.numeric import indices [as 别名]
def argsort (x, axis = -1, out=None, fill_value=None):
    """Treating masked values as if they have the value fill_value,
       return sort indices for sorting along given axis.
       if fill_value is None, use get_fill_value(x)
       Returns a numpy array.
    """
    d = filled(x, fill_value)
    return fromnumeric.argsort(d, axis) 
开发者ID:ktraunmueller,项目名称:Computable,代码行数:10,代码来源:ma.py

示例9: argmin

# 需要导入模块: from numpy.core import numeric [as 别名]
# 或者: from numpy.core.numeric import indices [as 别名]
def argmin (x, axis = -1, out=None, fill_value=None):
    """Treating masked values as if they have the value fill_value,
       return indices for minimum values along given axis.
       if fill_value is None, use get_fill_value(x).
       Returns a numpy array if x has more than one dimension.
       Otherwise, returns a scalar index.
    """
    d = filled(x, fill_value)
    return fromnumeric.argmin(d, axis) 
开发者ID:ktraunmueller,项目名称:Computable,代码行数:11,代码来源:ma.py

示例10: take

# 需要导入模块: from numpy.core import numeric [as 别名]
# 或者: from numpy.core.numeric import indices [as 别名]
def take(a, indices, axis=0):
    return new_take(a, indices, axis) 
开发者ID:ktraunmueller,项目名称:Computable,代码行数:4,代码来源:ma.py


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