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


Python warnings.warning方法代碼示例

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


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

示例1: _limit_inlines

# 需要導入模塊: import warnings [as 別名]
# 或者: from warnings import warning [as 別名]
def _limit_inlines(max_inlines, images_iter):
    if max_inlines is not None:
        images_list = list(images_iter)
        if max_inlines > len(images_list):
            warn_msg = (
                f"The number of max inlines {max_inlines} is greater"
                f"than the number of inlines found {len(images_list)}."
                f"Setting max inlines to {len(images_list)}"
            )
            warnings.warning(warn_msg)
            max_inlines = len(images_list)
            images_iter = images_list
        else:
            shuffled_list = random.shuffle(images_list)
            images_iter = take(max_inlines, shuffled_list)
    return images_iter, max_inlines 
開發者ID:microsoft,項目名稱:seismic-deeplearning,代碼行數:18,代碼來源:data.py

示例2: transfer

# 需要導入模塊: import warnings [as 別名]
# 或者: from warnings import warning [as 別名]
def transfer(self):
        """
        Mark an object for ownership transfer.  This object, when pickled, will
        unpickle into an owning model that frees resources when closed. Used to
        transfer ownership of shared memory resources from child processes to
        parent processes.  Such an object should only be unpickled once.

        The default implementation sets the ``is_owner`` attribute to ``'transfer'``.

        Returns:
            ``self`` (for convenience)
        """
        if not self.is_owner:
            warnings.warning('non-owning objects should not be transferred', stacklevel=1)
        else:
            self.is_owner = 'transfer'
        return self 
開發者ID:lenskit,項目名稱:lkpy,代碼行數:19,代碼來源:__init__.py

示例3: __init__

# 需要導入模塊: import warnings [as 別名]
# 或者: from warnings import warning [as 別名]
def __init__(
        self, optimizer, t_max: int, eta_min: float = 0., last_epoch: int = -1, factor: float = 1.
    ) -> None:
        assert t_max > 0
        assert eta_min >= 0
        if t_max == 1 and factor == 1:
            warnings.warning(
                "Cosine annealing scheduler will have no effect on the learning "
                "rate since T_max = 1 and factor = 1."
            )
        self.t_max = t_max
        self.eta_min = eta_min
        self.factor = factor
        self._last_restart: int = 0
        self._cycle_counter: int = 0
        self._cycle_factor: float = 1.
        self._updated_cycle_len: int = t_max
        self._initialized: bool = False
        super(CosineWithRestarts, self).__init__(optimizer, last_epoch) 
開發者ID:arthurdouillard,項目名稱:incremental_learning.pytorch,代碼行數:21,代碼來源:schedulers.py

示例4: stop

# 需要導入模塊: import warnings [as 別名]
# 或者: from warnings import warning [as 別名]
def stop(self, timeout=5):
        """Terminate all worker threads.

        Args:
            timeout (int): time to wait for threads to stop gracefully
        """
        # for compatability, negative timeouts are treated like None
        # TODO: treat negative timeouts like already expired timeouts
        if timeout is not None and timeout < 0:
            timeout = None
            warnings.warning(
                'In the future, negative timeouts to Server.stop() '
                'will be equivalent to a timeout of zero.',
                stacklevel=2,
            )

        if timeout is not None:
            endtime = time.time() + timeout

        # Must shut down threads here so the code that calls
        # this method can know when all threads are stopped.
        for worker in self._threads:
            self._queue.put(_SHUTDOWNREQUEST)

        ignored_errors = (
            # TODO: explain this exception.
            AssertionError,
            # Ignore repeated Ctrl-C. See cherrypy#691.
            KeyboardInterrupt,
        )

        for worker in self._clear_threads():
            remaining_time = timeout and endtime - time.time()
            try:
                worker.join(remaining_time)
                if worker.is_alive():
                    # Timeout exhausted; forcibly shut down the socket.
                    self._force_close(worker.conn)
                    worker.join()
            except ignored_errors:
                pass 
開發者ID:cherrypy,項目名稱:cheroot,代碼行數:43,代碼來源:threadpool.py

示例5: memory

# 需要導入模塊: import warnings [as 別名]
# 或者: from warnings import warning [as 別名]
def memory(self):
        """Return function's memory attribute"""
        try:
            return self.function.memory
        except:
            warnings.warning(f'Function of {self.name} (self.function.name) has no memory attribute') 
開發者ID:PrincetonUniversity,項目名稱:PsyNeuLink,代碼行數:8,代碼來源:episodicmemorymechanism.py


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