Update on Memory problem with NumPy arrays
Filip Wasilewski
filipwasilewski at gmail.com
Wed Jun 21 15:26:06 EDT 2006
sonjaa wrote:
> Hi
>
> last week I posted a problem with running out of memory when changing
> values in NumPy arrays. Since then I have tried many different
> approaches and
> work-arounds but to no avail.
[...]
Based on the numpy-discussion this seems to be fixed in the SVN now(?).
Anyway, you can use 'where' function to eliminate the loops:
from numpy import *
y = ones((501,501))
z = zeros((501,501))
it = 50
for kk in xrange(it):
y[1,1] = 4
y[1,2] = 4
y[1,0] = 4
y[2,1] = 6
print "Iteration #:%s" %(kk)
y = where((y == 4) | (y == 6), 2, y)
best,
fw
More information about the Python-list
mailing list