我在循环内使用Scipy的griddata时遇到问题.基本上发生的是,循环运行时内存无限增长.要重现该问题,只需将示例放在http://docs.scipy.org/doc/scipy/reference/generated/scipy.interpolate.griddata.html循环内:f...

我在循环内使用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')
提前致谢.
解决方法:
它是一个bug in Cython,应该在Scipy的最终0.12.0版本中解决.
沃梦达教程
本文标题为:python-Scipy griddata在循环/内存泄漏内不起作用


基础教程推荐
猜你喜欢
- python中列表添加元素的几种方式(+、append()、ext 2022-09-02
- Python 切片为什么不会索引越界? 2023-08-11
- centos7安装python3 以及tab补全功能 2023-09-03
- linux下安装python3 2023-09-03
- Python中10个常用的内置函数详解 2023-08-04
- python的进程和线程 2023-09-03
- Python 运算符Inplace 与Standard 2022-10-20
- windows下使用pycharm配置python的virtualenv环境 2023-09-04
- 基于Python创建语音识别控制系统 2023-08-11
- 关于Python Tkinter 复选框 ->Checkbutton 2022-10-20