Python TQDM软件包销售商不偶尔工作

发布于 2025-02-05 07:08:34 字数 291 浏览 2 评论 0原文

由于我正在循环排列,因此我不想太频繁地更新进度栏,因此我将销售商设置为总长度的十分之一:

total_len = len(list(itertools.permutations(range(N), 2)))
for row_a, row_b in tqdm(itertools.permutations(range(N), 2), total=total_len , miniters=int(total_len/10), disable=disable):

​矿物?

Since I'm looping over permutations I don't want too frequent updates of the progress bar, so I set miniters to be one-tenth of the total length:

total_len = len(list(itertools.permutations(range(N), 2)))
for row_a, row_b in tqdm(itertools.permutations(range(N), 2), total=total_len , miniters=int(total_len/10), disable=disable):

Sometimes it works fine

but it can fail in other cases

Any idea what's causing this unstable performance of miniters?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

述情 2025-02-12 07:08:34

我想我找到了原因,另一个参数maxInterval控制最大更新间隔,该间隔设置为10(秒),因此,当进度条更新太慢时,它将自动修改迷你店参数。因此,我还需要指定更大的MaxInterval。

因此代码应该是

total_len = len(list(itertools.permutations(range(N), 2)))
# or a larger value than 200 (seconds)
for row_a, row_b in tqdm(itertools.permutations(range(N), 2), total=total_len , miniters=int(total_len/10), maxinterval=200, disable=disable):

I think I found the reason, another argument maxinterval controls the maximum update interval which is set to 10 (seconds) by default, so when the progress bar updates too slowly it'll automatically modify the miniters parameter. Therefore I'll need to specify a larger maxinterval as well.

So the code should be

total_len = len(list(itertools.permutations(range(N), 2)))
# or a larger value than 200 (seconds)
for row_a, row_b in tqdm(itertools.permutations(range(N), 2), total=total_len , miniters=int(total_len/10), maxinterval=200, disable=disable):
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文