casinotools.utilities.multiple_loop module¶
- casinotools.utilities.multiple_loop._outer(a, b)[source]¶
Return the outer product/combination of two lists. a is a multi- or one-dimensional list, b is a one-dimensional list, tuple, NumPy array or scalar (new parameter) Return: outer combination ‘all’.
The function is to be called repeatedly:
all_combination = _outer(all_combination, p)
- casinotools.utilities.multiple_loop.combine(prm_values)[source]¶
Compute the combination of all parameter values in the prm_values (nested) list. Main function in this module.
param prm_values: nested list
(parameter_name, list_of_parameter_values)or dictionaryprm_values[parameter_name] = list_of_parameter_values. return: (all, names, varied) whereall contains all combinations (experiments) all[i] is the list of individual parameter values in experiment no i
names contains a list of all parameter names
varied holds a list of parameter names that are varied (i.e. where there is more than one value of the parameter, the rest of the parameters have fixed values)
Code example:
>>> from numpy import array >>> dx = array([1.0/2**k for k in range(2, 5)]) >>> dt = 3*dx; dt = dt[:-1] >>> p = {'dx': dx, 'dt': dt} >>> p {'dt': [ 0.75 , 0.375,], 'dx': [ 0.25 , 0.125 , 0.0625,]} >>> all_combination, names, varied = combine(p) >>> all_combination [[0.75, 0.25], [0.375, 0.25], [0.75, 0.125], [0.375, 0.125], [0.75, 0.0625], [0.375, 0.0625]]