My code is available here because Stack Overflow kept giving me errors when I tried to post it here.
My error is below:
Traceback (most recent call last):
File "/tmp/DoubleIntegrate.py", line 30, in <module>
t = interpolate.UnivariateSpline(d1.values(), d2.values())
File "/Library/Python/2.7/site-packages/scipy-0.11.0.dev_1983db6_20120208-py2.7-macosx-10.7-x86_64.egg/scipy/interpolate/fitpack2.py", line 136, in __init__
xb=bbox[0],xe=bbox[1],s=s)
dfitpack.error: (m>k) failed for hidden m: fpcurf0:m=1
I combed through the source code and wasn’t able to make heads from tail out of it.
What does this error mean?
There are a few things which I think could cause problems.
d1 = d2 = {}This doesn’t make two separate dictionaries; it makes one, and the two names d1 and d2 both point at it. This should be
d1 = {}andd2 = {}.These lines blow the dictionaries away in each loop iteration:
In order to add to the dictionaries, these should be:
and you should probably convert the keys to floats as well, to make sure we can order them correctly.
Finally, dictionaries don’t have an order, so the line
is dangerous because you have no guarantee that they’re going to be in the same order, or the right order. If you want to spline the xvals against the yvals, you want something like
but I’d probably simply accumulate a list of xs and ys instead of using the dictionaries.
The particular error message you’re seeing is basically saying there aren’t enough data points to match the number of knots, which makes sense because it was only getting one data point due to bug #2.