Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

Multithreading of the multi-arg function

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
    :      
 ans:  ((), {'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?

Multithreading of the multi-arg function

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
    :      
 ans:  ((), {'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?

click to hide/show revision 3
retagged

updated 2012-02-13 06:48:17 -0500

kcrisman gravatar image

Multithreading of the multi-arg function

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?