當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。