Ask Your Question

Multithreading of the multi-arg function

asked 2012-02-13 02:24:17 +0200

bk322 gravatar image

updated 2012-02-13 13:48:17 +0200

kcrisman gravatar image

So here's an example from the reference:

sage:  def f(N,M=10): return N*M
sage:  inputs = [(tuple([]), {'N':3,'M':5}), (tuple([]), {'N':4,'M':5})]
sage:  for a, val in sage.parallel.reference.parallel_iter(f, inputs):
    :      print a, val
 ((), {'M': 5, 'N': 4}) 20
 ((), {'M': 5, 'N': 3}) 15

I'd like to call in parallel scipy.misc.derivative - which has lots of args:

for i in range(-2, 2, 0.01):
    scipy.misc.derivative(imagLogPROD00, i, dx = 0.001, args=(opts.myN, 3, DP))

So I'm doing it in the following way:

mesh = arange(-2, 2, 0.01)
inputs = [[(tuple([]), {'func':imagLogPROD00, 'x0':i, 'dx':0.001, 'args':(opts.myN, 3, DP)})] for i in mesh]
for a, val in sage.parallel.reference.parallel_iter(scipy.misc.derivative, inputs):
    print a, val

and I get error at parallel_iter:

ValueError: need more than 1 value to unpack

So ah... what could that be?

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted

answered 2012-02-13 13:48:09 +0200

kcrisman gravatar image

Could this patch or the answer at this question give what you are looking for? Feel free to ignore this if you are asking something different.

edit flag offensive delete link more

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools


Asked: 2012-02-13 02:24:17 +0200

Seen: 539 times

Last updated: Feb 13 '12