开发者

Filling numpy array using [:,:] crashes python?

开发者 https://www.devze.com 2023-02-17 05:57 出处:网络
Greetings, I have come across an interesting error and was wondering if anyone knew the cause. I create several numpy arrays of dtype object and wish to initialize them with empty strings, so I did

Greetings,

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

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...

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

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

Thank you.

PS. I am using python 2.5 and numpy 1.0.4


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.

0

精彩评论

暂无评论...
验证码 换一张
取 消