QuTiP's function parallel_map provides the possibility to compute the value of a given function for several values of its argument in parallel. All the examples show cases where the first positional argument is varied, like the following:
def testFunc1(a, b):
return a, b
from qutip import parallel_map
parallel_map(testFunc1, (1, 2, 3), task_args=(4,))
This returns [(1, 4), (2, 4), (3, 4)]. Now I'm wondering if it's also possible to have a fixed value for a and a tuple for b. According to the documentation task_args can also be a dictionary, so I tried
parallel_map(testFunc1, (1, 2, 3), task_args={'a': 4})
parallel_map(testFunc1, (1, 2, 3), task_args={'a': 4, 'b': (1, 2, 3)})
but this results in TypeError: can only concatenate tuple (not "dict") to tuple.
When I try
parallel_map(testFunc1, b=(1, 2, 3), task_args={'a': 4})
I get TypeError: parallel_map() missing 1 required positional argument: 'values'.
Does somebody know how to use parallel_map for the n-th positional argument (without writing a function wrapper for each n)?
Avoid creating problems, where they are not, and place whatever your
n-th placed externally filled iterable in yourdef-ed function call-signature right into theparallel_map()-expected ( as documented ) and iteration-processing complianttuple:No,
the example is a clear path to unload
aand any and all n-th user-side code FED-IN iterable(s), right as was required above.show the way, a call to :
delivers -->
Exactly meeting both a) your wish to have free-hands for any N-th iterable, not just the first positional one and also the b) the very what the call-signature of the
parallel_map()expects and was documented to do so :