dfitpack.error: (m>k) 隐藏 m 失败:fpcurf0:m=1 [英] dfitpack.error: (m>k) failed for hidden m: fpcurf0:m=1

查看:54
本文介绍了dfitpack.error: (m>k) 隐藏 m 失败:fpcurf0:m=1的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的代码在此处可用,因为当我尝试在此处发布时,Stack Overflow 一直给我错误.

My code is available here because Stack Overflow kept giving me errors when I tried to post it here.

我的错误如下:

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.

这个错误是什么意思?

推荐答案

我认为有一些事情可能会导致问题.

There are a few things which I think could cause problems.

  1. d1 = d2 = {}

这不会制作两个单独的词典;它生成一个,并且两个名称 d1 和 d2 都指向它.这应该是 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 = {} and d2 = {}.

这些行在每次循环迭代中都把字典搞砸了:

These lines blow the dictionaries away in each loop iteration:

    d1 = {part[0] : xval}
    d2 = {part[0] : yval}

为了添加到词典中,这些应该是:

In order to add to the dictionaries, these should be:

    d1[part[0]] = xval
    d2[part[0]] = yval

并且您可能也应该将键转换为浮点数,以确保我们可以正确地对它们进行排序.

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

t = interpolate.UnivariateSpline(d1.values(), d2.values())

很危险,因为您无法保证它们的顺序相同或顺序正确.如果你想对 xvals 对 yvals 进行样条曲线,你需要像

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

keys = sorted(d1)
xs = [d1[k] for k in keys]
ys = [d2[k] for k in keys]
t = interpolate.UnivariateSpline(xs, ys)

但我可能只是简单地累积一个 xs 和 ys 列表,而不是使用字典.

but I'd probably simply accumulate a list of xs and ys instead of using the dictionaries.

您看到的特定错误消息基本上是说没有足够的数据点来匹配结的数量,这是有道理的,因为由于错误 #2,它只获得了一个数据点.

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.

这篇关于dfitpack.error: (m>k) 隐藏 m 失败:fpcurf0:m=1的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆