Update on Memory problem with NumPy arrays

sonjaa sonja.coussell at gmail.com
Wed Jun 21 16:21:40 EDT 2006


I've been in contact with Travis O, and he said it was fixed in the
SVN.
thanks for the suggestions, I'll try them out now.

best
Sonja


Filip Wasilewski wrote:
> 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