from scipy import ndimage
import numpy as np
with open("Data.dat", "r+") as f:
content = f.readlines()
content = [s.strip() for s in content]
content = np.asarray(content)
weights = np.array([1, 2, 4, 2, 1])
final = np.empty(content)
ndimage.filters.convolve1d(content, weights, -1, final, 'reflect', 0.0, 0.0)
这np
是numpy
包裹。的长度content
为 750,因此尝试使用 np.empty() 初始化输出数组的形状,因为我不希望其中有任何值。
但是当我运行我得到这个错误:
Traceback (most recent call last):
File "C:\Users\Animesh\Desktop\Smoothing.py", line 18, in <module>
final = np.empty(content)
ValueError: sequence too large; must be smaller than 32
应该做什么 ?