I get an error that indicates that minimize thinks f accepts arrays of data.
minimize() takes two arguments: a callable function that takes an array of values to be adjusted, and an array of starting values. Presumably, `x` is the array of values that you would like optimized, but you have to provide starting values.
I don't think you need the lambda, but you might want something like:
scipy.optimize.minimize(f, x0, args=(ode_soln,))
where x0 is an array of starting values.
I can remedy this by writing a little looped version,
for j in range(xvec.size):
fvals[j] = f(xvec[j], ode_soln)
but I’m wondering if:
1. Is there a smarter/more elegant solution to handling the vectorized input?
It does handle vectorized input, or perhaps I'm not understanding your question.
2. Is there a way to just tell minimize that it’s going to have to evaluate f one point at a time, rather than writing some other function?
No, or well it depends what you mean by "one point at a time". The objective function provided should take an array of candidate values for the parameters and return either an array to be minimized in the least-squares sense or the scalar cost value.