I have the following function:
def process_parameter(self, data, a_start=0.0004, a_stop=0.0006, b_start=0.05, b_stop=0.051, c_start=4560, c_stop=4620, tan_start=5, tan_stop=15):
"""Process the parameters"""
#create slice object
a_values = np.arange(a_start, a_stop, 0.00002)
b_values = np.arange(b_start, b_stop, 0.01)
c_values = np.arange(c_start, c_stop, 0.1)
tan_values = np.arange(tan_start, tan_stop, 5)
parameter_combs=list(product(a_values, b_values, c_values, tan_values))
print(f"Parameter combinations: {len(parameter_combs)}")
def compare(paramters):
a, b, c, tan = paramters
tun_fit = np.poly1d([a, b, c])
calc_data = data['I']
#Do some other small calc with calc_data
return result
results=Parallel(n_jobs=-1)(delayed(compare)(paramters) for paramters in parameter_combs)
return results
At the moment, it takes about 10 seconds to call up the function with my laptop. With a better laptop it could definitely be faster, I know.
But aside from that, maybe someone has a better idea on how I could speed up this code.
I thought about another way to include the C parameter. As this is by far the largest of the parameters.
Greetings