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


Python numpy.intc方法代碼示例

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


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

示例1: set_jds

# 需要導入模塊: import numpy [as 別名]
# 或者: from numpy import intc [as 別名]
def set_jds(self, val1, val2):
        """Parse the time strings contained in val1 and set jd1, jd2"""
        iterator = np.nditer([val1, None, None, None, None, None, None],
                             op_dtypes=([val1.dtype] + 5 * [np.intc]
                                        + [np.double]))
        try:
            for val, iy, im, id, ihr, imin, dsec in iterator:
                timestr = val.item()
                components = timestr.split()
                iy[...], im[...], id[...], ihr[...], imin[...], sec = (
                    int(component) for component in components[:-1])
                dsec[...] = sec + float(components[-1])
        except Exception:
            raise ValueError('Time {0} does not match {1} format'
                             .format(timestr, self.name))

        self.jd1, self.jd2 = erfa.dtf2d(
            self.scale.upper().encode('utf8'), *iterator.operands[1:]) 
開發者ID:mhvk,項目名稱:baseband,代碼行數:20,代碼來源:header.py

示例2: nested_to_ring

# 需要導入模塊: import numpy [as 別名]
# 或者: from numpy import intc [as 別名]
def nested_to_ring(nested_index, nside):
    """
    Convert a HEALPix 'nested' index to a HEALPix 'ring' index

    Parameters
    ----------
    nested_index : int or `~numpy.ndarray`
        Healpix index using the 'nested' ordering
    nside : int or `~numpy.ndarray`
        Number of pixels along the side of each of the 12 top-level HEALPix tiles

    Returns
    -------
    ring_index : int or `~numpy.ndarray`
        Healpix index using the 'ring' ordering
    """

    nside = np.asarray(nside, dtype=np.intc)

    return _core.nested_to_ring(nested_index, nside) 
開發者ID:astropy,項目名稱:astropy-healpix,代碼行數:22,代碼來源:core.py

示例3: _unsigned_subtract

# 需要導入模塊: import numpy [as 別名]
# 或者: from numpy import intc [as 別名]
def _unsigned_subtract(a, b):
    """
    Subtract two values where a >= b, and produce an unsigned result

    This is needed when finding the difference between the upper and lower
    bound of an int16 histogram
    """
    # coerce to a single type
    signed_to_unsigned = {
        np.byte: np.ubyte,
        np.short: np.ushort,
        np.intc: np.uintc,
        np.int_: np.uint,
        np.longlong: np.ulonglong
    }
    dt = np.result_type(a, b)
    try:
        dt = signed_to_unsigned[dt.type]
    except KeyError:
        return np.subtract(a, b, dtype=dt)
    else:
        # we know the inputs are integers, and we are deliberately casting
        # signed to unsigned
        return np.subtract(a, b, casting='unsafe', dtype=dt) 
開發者ID:Frank-qlu,項目名稱:recruit,代碼行數:26,代碼來源:histograms.py

示例4: lists_to_matrix

# 需要導入模塊: import numpy [as 別名]
# 或者: from numpy import intc [as 別名]
def lists_to_matrix(self, WS, DS):
        """Convert array of word (or topic) and document indices to doc-term array

        Parameters
        -----------
        (WS, DS) : tuple of two arrays
            WS[k] contains the kth word in the corpus
            DS[k] contains the document index for the kth word

        Returns
        -------
        doc_word : array (D, V)
            document-term array of counts

        """
        D = max(DS) + 1
        V = max(WS) + 1
        doc_word = np.empty((D, V), dtype=np.intc)
        for d in range(D):
            for v in range(V):
                doc_word[d, v] = np.count_nonzero(WS[DS == d] == v)
        return doc_word 
開發者ID:armor-ai,項目名稱:IDEA,代碼行數:24,代碼來源:onlineLDA.py

示例5: _unsigned_subtract

# 需要導入模塊: import numpy [as 別名]
# 或者: from numpy import intc [as 別名]
def _unsigned_subtract(a, b):
    """
    Subtract two values where a >= b, and produce an unsigned result

    This is needed when finding the difference between the upper and lower
    bound of an int16 histogram
    """
    # coerce to a single type
    signed_to_unsigned = {
        np.byte: np.ubyte,
        np.short: np.ushort,
        np.intc: np.uintc,
        np.int_: np.uint,
        np.longlong: np.ulonglong
    }
    dt = np.result_type(a, b)
    try:
        dt = signed_to_unsigned[dt.type]
    except KeyError:  # pragma: no cover
        return np.subtract(a, b, dtype=dt)
    else:
        # we know the inputs are integers, and we are deliberately casting
        # signed to unsigned
        return np.subtract(a, b, casting='unsafe', dtype=dt) 
開發者ID:mars-project,項目名稱:mars,代碼行數:26,代碼來源:histogram.py

示例6: transpose

# 需要導入模塊: import numpy [as 別名]
# 或者: from numpy import intc [as 別名]
def transpose(self, axes=None, copy=False):
        if axes is not None:
            raise ValueError(("Sparse matrices do not support "
                              "an 'axes' parameter because swapping "
                              "dimensions is the only logical permutation."))

        num_rows, num_cols = self.shape
        max_dim = max(self.shape)

        # flip diagonal offsets
        offsets = -self.offsets

        # re-align the data matrix
        r = np.arange(len(offsets), dtype=np.intc)[:, None]
        c = np.arange(num_rows, dtype=np.intc) - (offsets % max_dim)[:, None]
        pad_amount = max(0, max_dim-self.data.shape[1])
        data = np.hstack((self.data, np.zeros((self.data.shape[0], pad_amount),
                                              dtype=self.data.dtype)))
        data = data[r, c]
        return dia_matrix((data, offsets), shape=(
            num_cols, num_rows), copy=copy) 
開發者ID:ryfeus,項目名稱:lambda-packs,代碼行數:23,代碼來源:dia.py

示例7: perform

# 需要導入模塊: import numpy [as 別名]
# 或者: from numpy import intc [as 別名]
def perform(self, node, inputs, out):
        # TODO support broadcast!
        # TODO assert all input have the same shape
        z, = out
        if (z[0] is None or
                z[0].shape != inputs[0].shape or
                not z[0].is_c_contiguous()):
            z[0] = theano.sandbox.cuda.CudaNdarray.zeros(inputs[0].shape)
        if inputs[0].shape != inputs[1].shape:
            raise TypeError("PycudaElemwiseSourceModuleOp:"
                            " inputs don't have the same shape!")

        if inputs[0].size > 512:
            grid = (int(numpy.ceil(inputs[0].size / 512.)), 1)
            block = (512, 1, 1)
        else:
            grid = (1, 1)
            block = (inputs[0].shape[0], inputs[0].shape[1], 1)
        self.pycuda_fct(inputs[0], inputs[1], z[0],
                        numpy.intc(inputs[1].size), block=block, grid=grid) 
開發者ID:muhanzhang,項目名稱:D-VAE,代碼行數:22,代碼來源:pycuda_example.py

示例8: make_thunk

# 需要導入模塊: import numpy [as 別名]
# 或者: from numpy import intc [as 別名]
def make_thunk(self, node, storage_map, _, _2):
        mod = SourceModule("""
    __global__ void my_fct(float * i0, float * o0, int size) {
    int i = blockIdx.x*blockDim.x + threadIdx.x;
    if(i<size){
        o0[i] = i0[i]*2;
    }
  }""")
        pycuda_fct = mod.get_function("my_fct")
        inputs = [ storage_map[v] for v in node.inputs]
        outputs = [ storage_map[v] for v in node.outputs]
        def thunk():
            z = outputs[0]
            if z[0] is None or z[0].shape!=inputs[0][0].shape:
                z[0] = cuda.CudaNdarray.zeros(inputs[0][0].shape)
            grid = (int(numpy.ceil(inputs[0][0].size / 512.)),1)
            pycuda_fct(inputs[0][0], z[0], numpy.intc(inputs[0][0].size),
                       block=(512,1,1), grid=grid)

        return thunk 
開發者ID:muhanzhang,項目名稱:D-VAE,代碼行數:22,代碼來源:pycuda_double_op.py

示例9: attributes_encoder

# 需要導入模塊: import numpy [as 別名]
# 或者: from numpy import intc [as 別名]
def attributes_encoder(attr):
    """Custom encoder for copying file attributes in Python 3"""
    if isinstance(attr, (bytes, bytearray)):
        return attr.decode('utf-8')
    if isinstance(attr, (np.int_, np.intc, np.intp, np.int8, np.int16, np.int32,
        np.int64, np.uint8, np.uint16, np.uint32, np.uint64)):
        return int(attr)
    elif isinstance(attr, (np.float_, np.float16, np.float32, np.float64)):
        return float(attr)
    elif isinstance(attr, (np.ndarray)):
        if not isinstance(attr[0], (object)):
            return attr.tolist()
    elif isinstance(attr, (np.bool_)):
        return bool(attr)
    elif isinstance(attr, (np.void)):
        return None
    else:
        return attr

#-- PURPOSE: help module to describe the optional input parameters 
開發者ID:tsutterley,項目名稱:read-ICESat-2,代碼行數:22,代碼來源:convert_ICESat2_zarr.py

示例10: _mul_sparse_matrix

# 需要導入模塊: import numpy [as 別名]
# 或者: from numpy import intc [as 別名]
def _mul_sparse_matrix(self, other):
        M, K1 = self.shape
        K2, N = other.shape

        major_axis = self._swap((M,N))[0]
        indptr = np.empty(major_axis + 1, dtype=np.intc)

        other = self.__class__(other)  # convert to this format
        fn = getattr(sparsetools, self.format + '_matmat_pass1')
        fn(M, N, self.indptr, self.indices,
                  other.indptr, other.indices,
                  indptr)

        nnz = indptr[-1]
        indices = np.empty(nnz, dtype=np.intc)
        data = np.empty(nnz, dtype=upcast(self.dtype,other.dtype))

        fn = getattr(sparsetools, self.format + '_matmat_pass2')
        fn(M, N, self.indptr, self.indices, self.data,
                  other.indptr, other.indices, other.data,
                  indptr, indices, data)

        return self.__class__((data,indices,indptr),shape=(M,N)) 
開發者ID:ktraunmueller,項目名稱:Computable,代碼行數:25,代碼來源:compressed.py

示例11: tocoo

# 需要導入模塊: import numpy [as 別名]
# 或者: from numpy import intc [as 別名]
def tocoo(self,copy=True):
        """Return a COOrdinate representation of this matrix

        When copy=False the index and data arrays are not copied.
        """
        major_dim,minor_dim = self._swap(self.shape)

        data = self.data
        minor_indices = self.indices

        if copy:
            data = data.copy()
            minor_indices = minor_indices.copy()

        major_indices = np.empty(len(minor_indices), dtype=np.intc)

        sparsetools.expandptr(major_dim,self.indptr,major_indices)

        row,col = self._swap((major_indices,minor_indices))

        from .coo import coo_matrix
        return coo_matrix((data,(row,col)), self.shape) 
開發者ID:ktraunmueller,項目名稱:Computable,代碼行數:24,代碼來源:compressed.py

示例12: tocsr

# 需要導入模塊: import numpy [as 別名]
# 或者: from numpy import intc [as 別名]
def tocsr(self):
        """ Return Compressed Sparse Row format arrays for this matrix.
        """

        indptr = np.asarray([len(x) for x in self.rows], dtype=np.intc)
        indptr = np.concatenate((np.array([0], dtype=np.intc), np.cumsum(indptr)))

        nnz = indptr[-1]

        indices = []
        for x in self.rows:
            indices.extend(x)
        indices = np.asarray(indices, dtype=np.intc)

        data = []
        for x in self.data:
            data.extend(x)
        data = np.asarray(data, dtype=self.dtype)

        from .csr import csr_matrix
        return csr_matrix((data, indices, indptr), shape=self.shape) 
開發者ID:ktraunmueller,項目名稱:Computable,代碼行數:23,代碼來源:lil.py

示例13: _validate_X_predict

# 需要導入模塊: import numpy [as 別名]
# 或者: from numpy import intc [as 別名]
def _validate_X_predict(self, X, check_input):
        """Validate X whenever one tries to predict, apply, predict_proba"""
        if check_input:
            X = check_array(X, dtype=DTYPE, accept_sparse="csr")
            if issparse(X) and (X.indices.dtype != np.intc or
                                X.indptr.dtype != np.intc):
                raise ValueError("No support for np.int64 index based "
                                 "sparse matrices")

        n_features = X.shape[1]
        if self.n_features_ != n_features:
            raise ValueError("Number of features of the model must "
                             "match the input. Model n_features is %s and "
                             "input n_features is %s "
                             % (self.n_features_, n_features))

        return X 
開發者ID:PacktPublishing,項目名稱:Mastering-Elasticsearch-7.0,代碼行數:19,代碼來源:tree.py

示例14: _default

# 需要導入模塊: import numpy [as 別名]
# 或者: from numpy import intc [as 別名]
def _default(obj):
        """
        Convert dates and numpy objects in a json serializable format.
        """
        if isinstance(obj, datetime):
            return obj.strftime('%Y-%m-%dT%H:%M:%SZ')
        elif isinstance(obj, date):
            return obj.strftime('%Y-%m-%d')
        elif isinstance(obj, (np.int_, np.intc, np.intp, np.int8, np.int16,
                              np.int32, np.int64, np.uint8, np.uint16,
                              np.uint32, np.uint64)):
            return int(obj)
        elif isinstance(obj, np.bool_):
            return bool(obj)
        elif isinstance(obj, (np.float_, np.float16, np.float32, np.float64,
                              np.complex_, np.complex64, np.complex128)):
            return float(obj)

        raise TypeError(f"Object of type '{obj.__class__.__name__}' is not JSON serializable") 
開發者ID:apache,項目名稱:airflow,代碼行數:21,代碼來源:json.py

示例15: lists_to_matrix

# 需要導入模塊: import numpy [as 別名]
# 或者: from numpy import intc [as 別名]
def lists_to_matrix(WS, DS):
    """Convert array of word (or topic) and document indices to doc-term array

    Parameters
    -----------
    (WS, DS) : tuple of two arrays
        WS[k] contains the kth word in the corpus
        DS[k] contains the document index for the kth word

    Returns
    -------
    doc_word : array (D, V)
        document-term array of counts

    """
    D = max(DS) + 1
    V = max(WS) + 1
    doc_word = np.empty((D, V), dtype=np.intc)
    for d in range(D):
        for v in range(V):
            doc_word[d, v] = np.count_nonzero(WS[DS == d] == v)
    return doc_word 
開發者ID:vi3k6i5,項目名稱:GuidedLDA,代碼行數:24,代碼來源:utils.py


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