使用Scipy UnivariateSpline
函数时出现以下错误:
0-th dimension must be 100 but got 0 (not defined).
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/Users/phil/anaconda/lib/python2.7/site-packages/scipy/interpolate/fitpack2.py", line 181, in __init__
xb=bbox[0],xe=bbox[1],s=s)
dfitpack.error: failed in converting 1st keyword `w' of dfitpack.fpcurf0 to C/Fortran array
重新创建它的代码示例是:
import numpy as np
from scipy.interpolate import UnivariateSpline
X = np.arange(0, 100)
Y = np.random.randint(0, 100, size=100)
UnivariateSpline(X, Y, .1)
我重新塑造了X和Y,因此它们有两个维度,例如X.reshape(100, 1)
,并且还转换为浮点数,例如X.astype(float)
在Mac OSX上运行,Anaconda Python 2.7.12
和Scipy 0.18.1