> 1.)
> I had to give compute() a dummy argument, because it would otherwise
> produce always twice the same number. I suspect that it'll otherwise
> only create one Task and assign it's output to both variables ... Can
> I circumvent this without the fake argument?
This is actually the expected behaviour. Jug assumes that your functions
are deterministic, which is why it can cache the results. Normally, I will
pass in the seed for the random number generator.
This should go into the FAQ because you are not the first to ask it.
> 2.)
> The while loop is not repeated, even if the check() is False. In my
> actual code I do check convergence at this point, and would like to go
> on if it's not converged yet. Is this solvable?
This is a more serious issue.
Here is what your code looks like after unsugaring:
while True:
v1 = Task(compute, 1)
v2 = Task(compute, 1)
Task(output, v1, v2)
if Task(check, v1, v2):
break
This whole thing is first read in and finally, all tasks are executed. But
the number of tasks is fixed in advance. This is a limitation of jug.
Sorry.
Luis
You can fake this with jug by using barrier() and value().
barrier() will stop the script unless all of the previous values have been
calculated.
So your script would look like:
v = intial
while True:
v = compute(v)
barrier()
v = value(v) # loads the value
if good_enough(v):
break
Not great, but it would work.
HTH
Luis
http://packages.python.org/Jug/faq.html#it-doesn-t-work-with-random-input
maybe in the future someone will read it there before they run into problems.
*
If you are comfortable testing the bleeding edge, you can try the git
version which would *not require you to resubmit* with barrier.
https://github.com/luispedro/jug
If you do try it, please let me know whether it works.
Thank you
Luis
I'm really sorry for the delayed answer - I wanted to try the git
version before answering, but didn't have time to do so, and then
totally forgot. Just today I remembered and tried to get it running
... and it works perfect!
I will now let my code run, and go around the institute praising how
marvellous jug is!
Thank you and have a nice day, too!
Sven
2011/11/22 <lu...@luispedro.org>: