I have a few functions that return an array of data corresponding to parameters ranges.
Example: for a 2d array a
, the a_{ij}
value corresponds to the parameter set (param1_i, param2_j)
. How do I return the result and keep the parameter-value correspondence?
- Calling the function for each and every of
param1_i, para2_j
and returning one value would take ages (far more efficient if you do it in one go) - Break the function into (many) smaller functions and make usage difficult? (the point is to get the values for a range of parameters, 1 value is completely useless)
The best I can come up with is make a new numpy dtype, for example for a 2d array:
tagged2d = np.dtype( [('vals', float, 1), ('params', float, (2,))] )
so that a['vals'][i,j]
contains the values and a['params'][i,j]
the corresponding parameters.
Any thoughts? Maybe I should just return 2 arrays, one with values, other with parameter tuples?