本文整理汇总了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
示例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)