ProgressMeter.jl icon indicating copy to clipboard operation
ProgressMeter.jl copied to clipboard

[FR] Facilitate monitoring of variables

Open BeastyBlacksmith opened this issue 6 years ago • 4 comments

Ideally i would like to specify monitored variables in the constructor like

p = ProgressUnknown( "description", monitor = ( x, y, z ) )

And then everytime I call ProgressMeter.next! or ProgressMeter.update!, they are populated with the showvalues = (( :x, x ), (:y, y ), (:z, z )) automatically.

BeastyBlacksmith avatar Apr 15 '19 09:04 BeastyBlacksmith

How would you propose the implementation would look like? What would be stored in the progress struct when it is constructed for this to be possible?

KristofferC avatar Apr 15 '19 10:04 KristofferC

I would think it should be possible to save e.g. x as Symbol and the tricky part would be to get the value of x when one of the updating methods gets called. Maybe via observables ?

BeastyBlacksmith avatar Apr 15 '19 11:04 BeastyBlacksmith

tricky part would be to get the value of x when one of the updating methods gets called.

Indeed. You would need to capture a reference to the already existing variable and then u

So for example:

x = Ref(0)
p = ProgressUnknown( "description", monitor = (:x => x)
for i in 1:100
    x[] = 1
    showprogress(p)
end

There doesn't seem to be a large, if any at all, advantage over this vs just using the showvalues functionality.

KristofferC avatar Apr 15 '19 12:04 KristofferC

The advantage is less code duplication if you have something like conditional progress updates like scan_m here. Not a very important feature. More likely a "nice to have".

BeastyBlacksmith avatar Apr 15 '19 12:04 BeastyBlacksmith