灌装使用numpy的数组[:,:]崩溃蟒蛇? [英] Filling numpy array using [:,:] crashes python?

查看:175
本文介绍了灌装使用numpy的数组[:,:]崩溃蟒蛇?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

问候,

我所遇到的一个有趣的错误,并想知道是否有人知道原因。

I have come across an interesting error and was wondering if anyone knew the cause.

我创建DTYPE对象的多个numpy的阵列,并希望与空字符串初始化它们,所以我做了以下创建它们:

I create several numpy arrays of dtype object and wish to initialize them with empty strings, so I did the following to create them:

txtInputs=empty((7,12), dtype=object)
txtInputs[:, :]=''

repeated...

它们是如何使用后,是不相关的以外,这些变量是局部的功能,当它返回都没有了。然而,我发现,当我打电话,做了很多次连续的功能,我的程序有一个错误,说pythonw.exe已停止工作崩溃。这种崩溃是一贯的,呼叫的具体数目后,会发生,而且这个数字不会改变。

How they are used after is not relevant other than that these variables are local to the function and are gone when it returns. However, I have discovered that when I call the function that does this many times in a row, my program crashes with an error saying pythonw.exe has stopped working. This crash is consistent and happens after a specific number of calls, and that number never changes.

不过,如果我更换第二行:

However, if I replace the second line with:

txtInputs.fill('')

它不会崩溃。什么是错的使用[:,:] ='',以填补numpy的阵列?

It will not crash. What is wrong with using [:,:]='' to fill the numpy array??

感谢您。

PS。我使用python 2.5和1.0.4 numpy的

PS. I am using python 2.5 and numpy 1.0.4

推荐答案

不numpy的1.5.1出现此错误。我们周围numpy的1.0.4的时间来修复了不少错误,尤其是与对象和字符串dtypes。这可能是其中之一。这个bug显然已经固定从那时起。

This error does not occur with numpy 1.5.1. We were fixing quite a few bugs around the time of numpy 1.0.4, particularly with the object and string dtypes. This is probably one of them. The bug has apparently been fixed since then.

这篇关于灌装使用numpy的数组[:,:]崩溃蟒蛇?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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