當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。