2

我在循环中使用 Scipy 的 griddata 时遇到问题。基本上发生的事情是在循环运行时内存无限制地增长。

要重现问题,只需将示例放入

http://docs.scipy.org/doc/scipy/reference/generated/scipy.interpolate.griddata.html

在循环内:

for i in range(100000):

    grid_z1 = griddata(points, values, (grid_x, grid_y), method='linear')

我的 Python 版本是 2.7.3,我的 numpy 版本是 1.7.0,我的 scipy 版本是 0.12.0b1。我在 Windows 7 上运行它。

这是一个错误吗?如何多次重复插值而不发生内存泄漏问题?

剩下的代码:

def func(x, y):
    return x*(1-x)*np.cos(4*np.pi*x) * np.sin(4*np.pi*y**2)**2

grid_x, grid_y = np.mgrid[0:1:100j, 0:1:200j]
points = np.random.rand(1000, 2)
values = func(points[:,0], points[:,1])

for i in range(100000):

    grid_z1 = griddata(points, values, (grid_x, grid_y), method='linear')

提前致谢。

4

1 回答 1

0

这是Cython 中的一个错误,应该在 Scipy 的最终 0.12.0 版本中解决。

于 2013-03-17T17:21:35.523 回答