当前位置: 首页>>代码示例>>Python>>正文


Python tqdm.autonotebook方法代码示例

本文整理汇总了Python中tqdm.autonotebook.tqdm.autonotebook方法的典型用法代码示例。如果您正苦于以下问题:Python tqdm.autonotebook方法的具体用法?Python tqdm.autonotebook怎么用?Python tqdm.autonotebook使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在tqdm.autonotebook.tqdm的用法示例。


在下文中一共展示了tqdm.autonotebook方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: __init__

# 需要导入模块: from tqdm.autonotebook import tqdm [as 别名]
# 或者: from tqdm.autonotebook.tqdm import autonotebook [as 别名]
def __init__(
        self,
        persist=False,
        bar_format="{desc}[{n_fmt}/{total_fmt}] {percentage:3.0f}%|{bar}{postfix} [{elapsed}<{remaining}]",
        **tqdm_kwargs
    ):

        try:
            from tqdm.autonotebook import tqdm
        except ImportError:
            raise RuntimeError(
                "This contrib module requires tqdm to be installed. "
                "Please install it with command: \n pip install tqdm"
            )

        self.pbar_cls = tqdm
        self.pbar = None
        self.persist = persist
        self.bar_format = bar_format
        self.tqdm_kwargs = tqdm_kwargs 
开发者ID:pytorch,项目名称:ignite,代码行数:22,代码来源:tqdm_logger.py

示例2: _download

# 需要导入模块: from tqdm.autonotebook import tqdm [as 别名]
# 或者: from tqdm.autonotebook.tqdm import autonotebook [as 别名]
def _download(file_in, file_out, blocksize, output=False):
    """Read from input and write to output file in blocks"""
    with warnings.catch_warnings():
        warnings.filterwarnings('ignore')
        if output:
            try:
                from tqdm.autonotebook import tqdm
            except ImportError:
                logger.warn("Cache progress bar requires tqdm to be installed:"
                            " conda/pip install tqdm")
                output = False
        try:
            file_size = file_in.fs.size(file_in.path)
            pbar_disabled = not file_size
        except ValueError as err:
            logger.debug("File system error requesting size: {}".format(err))
            file_size = 0
            pbar_disabled = True
        if output:
            if not pbar_disabled:
                for i in range(100):
                    if i not in display:
                        display.add(i)
                        out = i
                        break
                pbar = tqdm(total=file_size // 2 ** 20, leave=False,
                            disable=pbar_disabled,
                            position=out, desc=os.path.basename(file_out.path),
                            mininterval=0.1,
                            bar_format=r'{n}/|/{l_bar}')
            else:
                output = False

        logger.debug("Caching {}".format(file_in.path))
        with file_in as f1:
            with file_out as f2:
                data = True
                while data:
                    data = f1.read(blocksize if file_size else -1)
                    f2.write(data)
                    if output:
                        pbar.update(len(data) // 2**20)
        if output:
            try:
                pbar.update(pbar.total - pbar.n)  # force to full
                pbar.close()
            except Exception as e:
                logger.debug('tqdm exception: %s' % e)
            finally:
                display.remove(out) 
开发者ID:intake,项目名称:intake,代码行数:52,代码来源:cache.py


注:本文中的tqdm.autonotebook.tqdm.autonotebook方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。