Scipy griddata在循环/内存泄漏中不起作用 [英] Scipy griddata doesn't work inside a loop / memory leak

查看:79
本文介绍了Scipy griddata在循环/内存泄漏中不起作用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在循环中使用Scipy的griddata时遇到问题.基本上,发生的是循环运行时内存无限增长.

I am having a problem using Scipy's griddata inside a loop. Basically what happens is that the memory grows without bound while the loop is running.

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

To reproduce the problem just put the example in

http://docs.scipy.org/doc/scipy/reference/generation/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上运行它.

My Python version is 2.7.3, my numpy version is 1.7.0 and my scipy version is 0.12.0b1. I'm running it on WIndows 7.

这是一个错误吗?如何在不引起内存泄漏问题的情况下多次重复插值?

Is this a bug? How can I repeat the interpolation many times without incurring in a memory leak problem?

其余的代码:

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')

谢谢.

推荐答案

这是

It's a bug in Cython, should be worked around in Scipy's final 0.12.0 release.

这篇关于Scipy griddata在循环/内存泄漏中不起作用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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