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


Python numba.int64方法代碼示例

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


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

示例1: map_neighbors

# 需要導入模塊: import numba [as 別名]
# 或者: from numba import int64 [as 別名]
def map_neighbors(indices, similarity, labels, top_k, pad_ind, pad_val):
    m = indices.shape[0]
    point_labels = np.full(
        (m, top_k), pad_ind, dtype=np.int64)
    point_label_sims = np.full(
        (m, top_k), pad_val, dtype=np.float32)
    for i in nb.prange(m):
        unique_point_labels, point_label_sim = map_one(
            labels[indices[i]], similarity[i], pad_ind)
        if top_k < len(unique_point_labels):
            top_indices = np.argsort(
                point_label_sim)[-1 * top_k:][::-1]
            point_labels[i] = unique_point_labels[top_indices]
            point_label_sims[i] = point_label_sim[top_indices]
        else:
            point_labels[i, :len(unique_point_labels)] = unique_point_labels
            point_label_sims[i, :len(unique_point_labels)] = point_label_sim
    return point_labels, point_label_sims 
開發者ID:kunaldahiya,項目名稱:pyxclib,代碼行數:20,代碼來源:shortlist.py

示例2: ij_bbox

# 需要導入模塊: import numba [as 別名]
# 或者: from numba import int64 [as 別名]
def ij_bbox(self,
                xy_bbox: Tuple[float, float, float, float],
                xy_border: float = 0.0,
                ij_border: int = 0,
                gu: bool = False) -> Tuple[int, int, int, int]:
        """
        Compute bounding box in i,j pixel coordinates given a bounding box *xy_bbox* in x,y coordinates.

        :param xy_bbox: Bounding box (x_min, y_min, x_max, y_max) given in the same CS as x and y.
        :param xy_border: If non-zero, grows the bounding box *xy_bbox* before using it for comparisons. Defaults to 0.
        :param ij_border: If non-zero, grows the returned i,j bounding box and clips it to size. Defaults to 0.
        :param gu: Use generic ufunc for the computation (may be faster). Defaults to False.
        :return: Bounding box in (i_min, j_min, i_max, j_max) in pixel coordinates.
            Returns ``(-1, -1, -1, -1)`` if *xy_bbox* isn't intersecting any of the x,y coordinates.
        """
        xy_bboxes = np.array([xy_bbox], dtype=np.float64)
        ij_bboxes = np.full_like(xy_bboxes, -1, dtype=np.int64)
        self.ij_bboxes(xy_bboxes, xy_border=xy_border, ij_border=ij_border, ij_bboxes=ij_bboxes, gu=gu)
        # noinspection PyTypeChecker
        return tuple(map(int, ij_bboxes[0])) 
開發者ID:dcs4cop,項目名稱:xcube,代碼行數:22,代碼來源:geocoding.py

示例3: __init__

# 需要導入模塊: import numba [as 別名]
# 或者: from numba import int64 [as 別名]
def __init__(
        self, n_fish_max, pos_std, angle_std, n_segments, pred_coef, persist_fish_for
    ):
        self.n_fish = n_fish_max
        self.coords = np.full((n_fish_max, 6 + n_segments), np.nan)
        self.uncertainties = np.array((pos_std, angle_std, angle_std))
        self.def_P = np.zeros((3, 2, 2))
        for i, uc in enumerate(self.uncertainties):
            self.def_P[i, 0, 0] = uc
            self.def_P[i, 1, 1] = uc
        self.i_not_updated = np.zeros(n_fish_max, dtype=np.int64)
        self.Ps = np.zeros((n_fish_max, 3, 2, 2))
        self.F = np.array([[1.0, 1.0], [0.0, 1.0]])
        dt = 0.02
        self.Q = (
            np.array([[0.25 * dt ** 4, 0.5 * dt ** 3], [0.5 * dt ** 3, dt ** 2]])
            * pred_coef
        )
        self.persist_fish_for = persist_fish_for 
開發者ID:portugueslab,項目名稱:stytra,代碼行數:21,代碼來源:fish.py

示例4: gaps_between_hits

# 需要導入模塊: import numba [as 別名]
# 或者: from numba import int64 [as 別名]
def gaps_between_hits(hits):
    """Return array of gaps between hits: a hit's 'gap' is the # of samples before that hit free of other hits.
    The gap of the first hit is 0 by definition.
    Hits should already be sorted by index of maximum; we'll check this and throw an error if not.
    """
    n_hits = len(hits)
    gaps = np.zeros(n_hits, dtype=np.int64)
    if n_hits == 0:
        return gaps
    # Keep a running right boundary
    boundary = hits[0].index_of_maximum
    for i, hit in enumerate(hits[1:]):
        gaps[i + 1] = max(0, hit.index_of_maximum - boundary - 1)
        if hit.index_of_maximum < boundary:
            raise ValueError("Hits should be sorted by index_of_maximum")
        boundary = max(hit.index_of_maximum, boundary)
    return gaps 
開發者ID:XENON1T,項目名稱:pax,代碼行數:19,代碼來源:dsputils.py

示例5: __init__

# 需要導入模塊: import numba [as 別名]
# 或者: from numba import int64 [as 別名]
def __init__(self, x_qbin, n_bin, m_bin):
        self.x_qbin = x_qbin
        self.n_bin = n_bin
        self.m_bin = m_bin
        self.print_log = False
        if nb_flag:
            logger.debug("SubBinning: NUMBA")
            self.p_per_subbins = nb.jit(nb.double[:](nb.double[:], nb.double[:], nb.int64))(self.p_per_subbins_py)
        else:
            logger.debug("SubBinning: Python")
            self.p_per_subbins = self.p_per_subbins_py 
開發者ID:ocelot-collab,項目名稱:ocelot,代碼行數:13,代碼來源:csr.py

示例6: map_centroids

# 需要導入模塊: import numba [as 別名]
# 或者: from numba import int64 [as 別名]
def map_centroids(indices, sims, mapping, pad_ind, pad_val):
    mapped_indices = np.full(
        indices.shape, fill_value=pad_ind, dtype=np.int64)
    mapped_sims = np.full(
        indices.shape, fill_value=pad_val, dtype=np.float32)

    for i in nb.prange(indices.shape[0]):
        _ind, _sim = _remap_centroid_one(indices[i], sims[i], mapping)
        mapped_indices[i, :len(_ind)] = _ind
        mapped_sims[i, :len(_sim)] = _sim
    return mapped_indices, mapped_sims 
開發者ID:kunaldahiya,項目名稱:pyxclib,代碼行數:13,代碼來源:shortlist.py

示例7: _as_array

# 需要導入模塊: import numba [as 別名]
# 或者: from numba import int64 [as 別名]
def _as_array(self, labels):
        n_pos_labels = list(map(len, labels))
        _labels = np.full(
            (len(labels), max(n_pos_labels)),
            self.pad_ind, np.int64)
        for ind, _lab in enumerate(labels):
            _labels[ind, :n_pos_labels[ind]] = labels[ind]
        return _labels 
開發者ID:kunaldahiya,項目名稱:pyxclib,代碼行數:10,代碼來源:shortlist.py

示例8: int2key

# 需要導入模塊: import numba [as 別名]
# 或者: from numba import int64 [as 別名]
def int2key(int_key, dim, key_maxs, key_mins):
    key = np.empty((dim + 1,), dtype=np.int64)
    scales = key_maxs - key_mins + 1
    for idx in range(dim, 0, -1):
        key[idx] = int_key % scales[idx]
        int_key -= key[idx]
        int_key //= scales[idx]
    key[0] = int_key

    key += key_mins
    return key 
開發者ID:laoreja,項目名稱:HPLFlowNet,代碼行數:13,代碼來源:transforms.py

示例9: ij_bboxes

# 需要導入模塊: import numba [as 別名]
# 或者: from numba import int64 [as 別名]
def ij_bboxes(self,
                  xy_bboxes: np.ndarray,
                  xy_border: float = 0.0,
                  ij_bboxes: np.ndarray = None,
                  ij_border: int = 0,
                  gu: bool = False) -> np.ndarray:
        """
        Compute bounding boxes in i,j pixel coordinates given bounding boxes *xy_bboxes* in x,y coordinates.

        :param xy_bboxes: Numpy array of x,y bounding boxes [[x_min, y_min, x_max, y_max], ...]
            given in the same CS as x and y.
        :param xy_border: If non-zero, grows the bounding box *xy_bbox* before using it for comparisons. Defaults to 0.
        :param ij_bboxes: Numpy array of pixel i,j bounding boxes [[x_min, y_min, x_max, y_max], ...].
            If given, must have same shape as *xy_bboxes*.
        :param ij_border: If non-zero, grows the returned i,j bounding box and clips it to size. Defaults to 0.
        :param gu: Use generic ufunc for the computation (may be faster). Defaults to False.
        :return: Bounding box in (i_min, j_min, i_max, j_max) in pixel coordinates.
            Returns None if *xy_bbox* isn't intersecting any of the x,y coordinates.
        """
        if self.is_lon_normalized:
            xy_bboxes = xy_bboxes.copy()
            c0 = xy_bboxes[:, 0]
            c2 = xy_bboxes[:, 2]
            c0 = np.where(c0 < 0.0, c0 + 360.0, c0)
            c2 = np.where(c2 < 0.0, c2 + 360.0, c2)
            xy_bboxes[:, 0] = c0
            xy_bboxes[:, 2] = c2

        c0 = xy_bboxes[:, 0]
        c2 = xy_bboxes[:, 2]
        cond = c0 > c2
        if np.any(cond):
            xy_bboxes = xy_bboxes.copy()
            xy_bboxes[:, 2] += 360.0

        if ij_bboxes is None:
            ij_bboxes = np.full_like(xy_bboxes, -1, dtype=np.int64)
        else:
            ij_bboxes[:, :] = -1
        if gu:
            gu_compute_ij_bboxes(self.x.values,
                                 self.y.values,
                                 xy_bboxes,
                                 xy_border,
                                 ij_border,
                                 ij_bboxes)
        else:
            compute_ij_bboxes(self.x.values,
                              self.y.values,
                              xy_bboxes,
                              xy_border,
                              ij_border,
                              ij_bboxes)
        return ij_bboxes 
開發者ID:dcs4cop,項目名稱:xcube,代碼行數:56,代碼來源:geocoding.py

示例10: _round

# 需要導入模塊: import numba [as 別名]
# 或者: from numba import int64 [as 別名]
def _round(mz: np.ndarray, intensity: np.ndarray, decimals: int, combine: str)\
        -> Tuple[np.ndarray, np.ndarray, np.ndarray]:
    """
    JIT helper function for `MsmsSpectrum.round`.

    Parameters
    ----------
    mz : np.ndarray
        The mass-to-charge ratios of the spectrum fragment peaks.
    intensity : np.ndarray
        The intensities of the corresponding spectrum fragment peaks.
    decimals : int
        Number of decimal places to round the mass-to-charge ratios.
    combine : {'sum', 'max'}
        Method used to combine intensities from merged fragment peaks.

    Returns
    -------
    Tuple[np.ndarray, np.ndarray, np.ndarray]
        A tuple consisting of the rounded mass-to-charge ratios and the
        corresponding intensities and peak annotation indexes.
    """
    mz_round = np.round_(mz, decimals, np.empty_like(mz, np.float32))
    mz_unique = np.unique(mz_round)
    # If peaks got merged by rounding the mass-to-charge ratios we need to
    # combine their intensities and annotations as well.
    if len(mz_unique) < len(mz_round):
        intensity_unique = np.zeros_like(mz_unique, np.float32)
        annotations_unique_idx = np.zeros_like(mz_unique, np.int64)
        combine_is_sum = combine == 'sum'
        i_orig = 0
        offset = 0
        for i_unique in range(len(mz_unique)):
            # Check whether subsequent mz values got merged.
            while (abs(mz_unique[i_unique] - mz_round[i_orig + offset])
                   <= 1e-06):
                offset += 1
            # Select the annotation of the most intense peak.
            annotations_unique_idx[i_unique] = i_orig + np.argmax(
                intensity[i_orig: i_orig + offset])
            # Combine the corresponding intensities.
            intensity_unique[i_unique] = (
                intensity[i_orig: i_orig + offset].sum() if combine_is_sum else
                intensity[annotations_unique_idx[i_unique]])

            i_orig += offset
            offset = 0

        return mz_unique, intensity_unique, annotations_unique_idx
    else:
        return mz_unique, intensity, np.arange(len(mz)) 
開發者ID:bittremieux,項目名稱:spectrum_utils,代碼行數:53,代碼來源:spectrum.py


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