I'm trying to find a least squared cubic spline fit of data using the following code:
from scipy import interpolate
plt.subplot(223)
l_hits = np.array(l_hits)
list1 = np.log(l_hits)
knots = list1.sort()
xnew = np.arange(min(l_bins), max(l_bins))
tck = interpolate.splrep(l_bins,list1,s=0,k=3,task=-1,t=knots)
fnew = interpolate.splev(xnew, tck, der=0)
plt.plot(xnew, fnew, 'b-')
where the x-values are l_bins and the y-values are np.log(l_hits) = list1. But I keep getting the error:
TypeError: Knots must be given for task =-1
Why am I getting this error and how do I fix it?