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


Python numpy.seterrcall方法代碼示例

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


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

示例1: __enter__

# 需要導入模塊: import numpy [as 別名]
# 或者: from numpy import seterrcall [as 別名]
def __enter__(self):
        self.oldstate = seterr(**self.kwargs)
        if self.call is not _Unspecified:
            self.oldcall = seterrcall(self.call) 
開發者ID:Frank-qlu,項目名稱:recruit,代碼行數:6,代碼來源:numeric.py

示例2: __exit__

# 需要導入模塊: import numpy [as 別名]
# 或者: from numpy import seterrcall [as 別名]
def __exit__(self, *exc_info):
        seterr(**self.oldstate)
        if self.call is not _Unspecified:
            seterrcall(self.oldcall) 
開發者ID:Frank-qlu,項目名稱:recruit,代碼行數:6,代碼來源:numeric.py

示例3: raw_qualities_to_histogram

# 需要導入模塊: import numpy [as 別名]
# 或者: from numpy import seterrcall [as 別名]
def raw_qualities_to_histogram(qualities):
    """Approximate the distribution of base quality at each position in a read
    using a pseudo 2d kernel density estimation

    Generate cumulative distribution functions

    Args:
        qualities (list): raw count of all phred scores

    Returns:
        list: list of cumulative distribution functions. One cdf per base. The
            list has the size of the read length
    """
    logger = logging.getLogger(__name__)

    # moved this in quality_bins_to_histogram to try parallelization
    # quals = util.split_list([i for i in zip(*qualities)], n_parts=cpus)
    cdfs_list = []
    for q in qualities:
        numpy_log_handler = np.seterrcall(util.nplog)
        with np.errstate(under='ignore', divide='call'):
            try:
                kde = stats.gaussian_kde(q, bw_method=0.2 / np.std(q, ddof=1))
            except np.linalg.linalg.LinAlgError as e:
                # if np.std of array is 0, we modify the array slightly to be
                # able to divide by ~ np.std
                # this will print a FloatingPointError in DEBUG mode
                # logger.debug('np.std of quality array is zero: %s' % e)
                q = list(q)
                q[-1] += 1
                kde = stats.gaussian_kde(q, bw_method=0.2 / np.std(q, ddof=1))
            kde = kde.evaluate(range(41))
        cdf = np.cumsum(kde)
        cdf = cdf / cdf[-1]
        cdfs_list.append(cdf)
    return cdfs_list 
開發者ID:HadrienG,項目名稱:InSilicoSeq,代碼行數:38,代碼來源:modeller.py

示例4: get_mirrors

# 需要導入模塊: import numpy [as 別名]
# 或者: from numpy import seterrcall [as 別名]
def get_mirrors(coxeter_diagram):
    """
    Given a Coxter diagram consists of integers/rationals that represent the angles between
    the mirrors (a rational p means the angle is π/p), return a square matrix whose
    rows are the normal vectors of the mirrors. This matrix is not unique, here we use a
    lower triangle one to simplify the computations.
    """
    # error handling function when the input coxeter matrix is invalid.
    def err_handler(err_type, flag):
        print("Invalid input Coxeter diagram. This diagram does not give a finite \
symmetry group of an uniform polytope. See \
https://en.wikipedia.org/wiki/Coxeter_group#Symmetry_groups_of_regular_polytopes \
for a complete list of valid Coxeter diagrams.")
        sys.exit(1)

    np.seterrcall(err_handler)
    np.seterr(all="call")

    coxeter_matrix = np.array(make_symmetry_matrix(coxeter_diagram)).astype(np.float)
    C = -np.cos(np.pi / coxeter_matrix)
    M = np.zeros_like(C)
    n = len(M)
    # the first normal vector is simply (1, 0, ...)
    M[0, 0] = 1
    # in the i-th row, the j-th entry can be computed via the (j, j) entry.
    for i in range(1, n):
        for j in range(i):
            M[i, j] = (C[i, j] - np.dot(M[j, :j], M[i, :j])) / M[j, j]
        # the (i, i) entry is used to normalize this vector
        M[i, i] = np.sqrt(1 - np.dot(M[i, :i], M[i, :i]))

    return M 
開發者ID:neozhaoliang,項目名稱:pywonderland,代碼行數:34,代碼來源:helpers.py

示例5: __call__

# 需要導入模塊: import numpy [as 別名]
# 或者: from numpy import seterrcall [as 別名]
def __call__(self, decorated: Callable) -> Callable:
        """Decorate the function."""
        @functools.wraps(decorated)
        def wrapper(*args: Any, **kwargs: Any) -> Any:
            """Configure NumPy to detect numerical errors."""
            detector = NumericalErrorDetector(self.error)
            with np.errstate(divide='call', over='call', under='ignore', invalid='call'):
                np.seterrcall(detector)
                returned = decorated(*args, **kwargs)
            if detector.detected is not None:
                returned[-1].append(detector.detected)
            return returned

        return wrapper 
開發者ID:jeffgortmaker,項目名稱:pyblp,代碼行數:16,代碼來源:basics.py

示例6: catch_nans

# 需要導入模塊: import numpy [as 別名]
# 或者: from numpy import seterrcall [as 別名]
def catch_nans():
    np.seterr(invalid='call')
    np.seterrcall(examine_nan) 
開發者ID:millerjohnp,項目名稱:traversing_knowledge_graphs,代碼行數:5,代碼來源:util.py


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