ijulia印刷每一行的进度栏
我目前正在学习朱莉娅(Julia),并且一直在Jupyter笔记本电脑环境中练习。但是,ProgressBar软件包(类似于Python中的TQDM)已更新每条新行,而不是在同一行上更新(图片附加)。有什么方法可以解决此问题吗?谢谢。
Update :这是我写的完整功能。
function spike_rate(raw_dat, width)
N = size(raw_dat)[1]
domain = collect(1:N);
spike_rat = zeros(N);
for i in ProgressBar(1:N)
dx = i .- domain;
window = gaussian.(dx, width);
spike_rat[i] = sum(window .* raw_dat) ./ width;
end
return spike_rat;
end
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
有一种方法,据我所知,包装模块是这样做的:
您可以分享一些代码吗?
例如,在哪里定义写在控制台上的内容。
一个猜测是
,而不是
可以帮助您,因为
println()
始终创建一个新行,而print()
应该只覆盖当前行。There is a way, the package module does that as far as I know when you do:
Could you share a little of your code?
For example, where you define what is written to the console.
One guess is that
instead of
could help, because
println()
always creates a new line, whileprint()
should just overwrite you current line.这似乎是已知 esgease 不幸的是。目前尚不清楚如何使这些进度栏不再正常,而是维护者的评论说TQDM使用“自定义iPywidget”来为Python库做这项工作,但尚未为Julia套件实施。
要扩展 @Zitzero提及的
] UP
,该调用pkg.update()
也打印了进度栏 - 因此建议是使用该机制pkg
用于它。pkg
具有一个内部模块,称为miniprogressbars
可以处理此输出。edit :蒂姆·霍尔(Tim Holy's) progressmeter package package 看起来很好,并且是且是良好的,并且是一个比依靠没有文档的内部非代码> pkg 子模块要好得多。因此,我建议下面的进度表。
读书文件提到 Miniprogressbar 。因此,使用
progressmeter
,并将进度输出与其他相关输出分开为不同的单元格,似乎是最佳选择。(不推荐)
这是基于
pkg
使用它的方法src/operations.jl#l988“ rel =“ nofollow noreferrer”>来自此文件。评论的线(使用start_progress
,print_progress_bottom
和end_progress
)在pkg
中的原始用法中,但是目前尚不清楚他们做什么,在这里他们似乎只是弄乱了输出 - 也许我错误地使用了它们,或者jupyter笔记本仅支持miniprogressbars
使用的ANSI代码的子集。This seems to be a known issue with ProgressBars.jl, unfortunately. It's not clear what changed to make these progress bars not work properly anymore, but the maintainer's comment says that tqdm uses "a custom ipywidget" to make this work for the Python library, and that hasn't been implemented for the Julia package yet.
To expand on @Zitzero's mention of
] up
, that callsPkg.update()
which also prints a progress bar - so the suggestion is to use the mechanismPkg
uses for it.Pkg
has an internal module calledMiniProgressBars
which handles this output.Edit: Tim Holy's ProgressMeter package seems well-maintained, and is a much better option than relying on an internal non-exported
Pkg
submodule with no docs. So I'd recommend ProgressMeter over the below.The Readme mentions a caveat regarding printing additional information with the progress bar when in Jupyter, which likely applies to
MiniProgressBar
as well. So, usingProgressMeter
, and separating the progress output vs other relevant output to different cells, seems like the best option.(not recommended)
This is based on how
Pkg
uses it, from this file. The commented out lines (withstart_progress
,print_progress_bottom
, andend_progress
) are in the original usage inPkg
, but it's not clear what they do and here they just seem to mess up the output - maybe I'm using them wrongly, or maybe Jupyter notebooks only support a subset of the ANSI codes thatMiniProgressBars
uses.