当前位置: 首页>>代码示例>>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;未经允许,请勿转载。