I have a function that calculates some ratios between two large np.arrays (>1000L, >1000L):
def error(crm1, crm2):
delta1 = np.zeros((crm1.shape[0], crm1.shape[1]))
delta2 = np.zeros((crm2.shape[0], crm2.shape[1]))
stt = np.int(crm1.shape[0])
stp = np.int(crm1.shape[1])
for m in xrange(stt):
for n in xrange(stp):
s1 = crm1[m, n]
s2 = crm2[m, n]
w1 = (min(s1, s2)**2)/s1
w2 = (min(s1, s2)**2)/s2
delta1[m, n] = w1
delta2[m, n] = w2
return (delta1, delta2)
Now I realised that I have to calculate this ratio between an variable amount of np.arrays (same dimension and data type) like:
# Case 1
error(array1, array2)
# Case 2
error(array1, array2, array3, array4)
# Case 3
error(array1, array2, array3, array4, array5, array6)
If it´s possible, I don´t want to write a code for each case because I have many function like the error() function. Is it possible to change the code with the result that the function works with an variable amount of np.arrays?