I am new using function generators. I am working with the following function:
def math_model(n: float):
def crrcn(x, t0: float, amp: float, tau: float, offset: float, dt: float, k: float):
crrcn = np.zeros(np.shape(x))
for i, a in enumerate(x):
if a < (t0 + dt):
crrcn[i] = offset
else:
crrcn[i] = offset + k * amp * (math.exp(n) / (n ** n)) * ((a - (t0 + dt)) / tau) ** n * math.exp( - (a - (t0 + dt)) / tau)
return crrcn
return crrcn
which defines a mathematical model I will use later to fit some data with scipy curve_fit. I wanted to use this same model to build a more complicated one with the following line.
model = partial(math_model(N), dt = 0, k = 1) + math_model(N)
which gives me:
TypeError: unsupported operand type(s) for +: 'functools.partial' and 'function'
From which I understand that I cannot build a function from two functions using this operator and as far as I know there are no function operands in python. How can one build a function from other functions without explicitly evaluating them?